From c73bcfb19e2418277985ad02c7d52093d573943c Mon Sep 17 00:00:00 2001 From: alexvotofuture Date: Thu, 22 Feb 2018 19:51:35 -0800 Subject: [PATCH] Update ArduinoSerialToLEDStrip.ino --- ArduinoSerialToLEDStrip.ino | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/ArduinoSerialToLEDStrip.ino b/ArduinoSerialToLEDStrip.ino index 0b2a7ea..e071e99 100644 --- a/ArduinoSerialToLEDStrip.ino +++ b/ArduinoSerialToLEDStrip.ino @@ -1,42 +1,32 @@ - #include -// Because conditional #includes don't work w/Arduino sketches... #include // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET -#define NUMPIXELS 60 // Number of LEDs in strip // Here's how to control the LEDs from any two pins: #define DATAPIN 5 #define CLOCKPIN 6 +#define NUMPIXELS 60 // Number of LEDs in strip Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN); -const int potPin = 5; -int potVal = 0; -int mapPotVal = 0; int serialMessage = 0; +int temporaryIncrement = 1; void setup() { - Serial.begin(9600); - pinMode(potPin, INPUT_PULLUP); + Serial.begin(115200); strip.begin(); // Initialize pins for output strip.show(); // Turn all LEDs off ASAP } // This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel. -//int head = 0, tail = -30; // Index of first 'on' and 'off' pixels -//uint32_t color = 0x000000; // 'On' color (starts red) - void loop() { if (Serial.available() > 0) { - serialMessage = (Serial.read(), DEC); + serialMessage = (Serial.read(),DEC); + Serial.print(serialMessage); } int r=random(0,255); int g=random(0,255); int b=random(0,255); - potVal = analogRead(potPin); - mapPotVal = map(potVal, 0, 1023, 0, 59); selectWipe(strip.Color(r, g, b), serialMessage, 5); //Uncomment this to make the led count respond to a serial message sent from Python -// selectWipe(strip.Color(r, g, b), mapPotVal, 5); //Uncomment this to make the led count respond to the potentiometer } void selectWipe(uint32_t c, int pixelLength, int wait) { //converts mapPotVal to pixelLength