# HG changeset patch # User drewp@bigasterisk.com # Date 2015-06-13 04:33:52 # Node ID b174f95a3b8dd0e0cebcc8dc46559e376179d87a # Parent b5b841cee380abd8b4981fd24da13e419491fed2 use proper pwm pins Ignore-this: 97267b7dc54b2c5187603a00829ea7eb diff --git a/rgbled/makefile b/rgbled/makefile --- a/rgbled/makefile +++ b/rgbled/makefile @@ -1,6 +1,6 @@ BOARD_TAG = nano328 ARDUINO_LIBS = Adafruit_NeoPixel USER_LIB_PATH := $(realpath .) -MONITOR_PORT = /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027JI6-if00-port0 +MONITOR_PORT = /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A7027NYX-if00-port0 include /usr/share/arduino/Arduino.mk diff --git a/rgbled/nanostrip.cc b/rgbled/nanostrip.cc --- a/rgbled/nanostrip.cc +++ b/rgbled/nanostrip.cc @@ -2,13 +2,15 @@ #include /* + PWM is available on 3,5,6,9,10,11 + Pin D3: blacklight pwm -Pin D5: neo strip 1 -Pin D6: neo strip 2 -Pin D7: R -Pin D8: G -Pin D9: B -Pin D10: blacklight 2 +Pin D4: neo strip 1 +Pin D6: R +Pin D8: neo strip 2 +Pin D9: G +Pin D10: B +Pin D11: blacklight 2 */ @@ -19,10 +21,11 @@ Pin D10: blacklight 2 // NEO_GRB Pixels are wired for GRB bitstream // NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels) // NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip) -Adafruit_NeoPixel strip0 = Adafruit_NeoPixel(50, 5, NEO_RGB + NEO_KHZ800); -Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(50, 6, NEO_RGB + NEO_KHZ800); +Adafruit_NeoPixel strip0 = Adafruit_NeoPixel(50, 4, NEO_RGB + NEO_KHZ800); +Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(50, 8, NEO_RGB + NEO_KHZ800); #define debugLed 13 + void intro() { uint32_t red = strip0.Color(255,0,0), black = strip0.Color(0,0,0); for (Adafruit_NeoPixel* strip = &strip0; strip != &strip1; strip = &strip1) { @@ -33,17 +36,17 @@ void intro() { } } -void setStrip(Adafruit_NeoPixel& strip) { +void setStrip(Adafruit_NeoPixel* strip) { digitalWrite(debugLed, 1); - for (uint8_t i=0; i < strip.numPixels(); i++) { + for (uint8_t i=0; i < strip->numPixels(); i++) { while (Serial.available() < 3) { } byte r = Serial.read(); byte g = Serial.read(); byte b = Serial.read(); - strip.setPixelColor(i, strip.Color(g, r, b)); + strip->setPixelColor(i, strip->Color(g, r, b)); } - strip.show(); + strip->show(); digitalWrite(debugLed, 0); } @@ -53,11 +56,11 @@ int main(void) { pinMode(debugLed, OUTPUT); pinMode(3, OUTPUT); - pinMode(7, OUTPUT); - pinMode(8, OUTPUT); + pinMode(6, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); - + pinMode(11, OUTPUT); + strip0.begin(); strip1.begin(); intro(); @@ -73,23 +76,23 @@ int main(void) { } i = Serial.read(); // command if (i == 0) { // set strip: 0x60 0x00 - setStrip(strip0); + setStrip(&strip0); } else if (i == 1) { // strip 1 - setStrip(strip1); - } else if (i == 2) { // set pwm on D3: 0x60 0x02 + setStrip(&strip1); + } else if (i == 2) { // set pwm on uv1: 0x60 0x02 while (Serial.available() < 1) { } analogWrite(3, Serial.read()); - } else if (i == 3) { // set pwm on D10: 0x60 0x03 + } else if (i == 3) { // set pwm on uv2: 0x60 0x03 while (Serial.available() < 1) { } - analogWrite(10, Serial.read()); + analogWrite(11, Serial.read()); } else if (i == 4) { // set r/g/b: 0x60 0x04 while (Serial.available() < 3) { } - analogWrite(7, Serial.read()); - analogWrite(8, Serial.read()); + analogWrite(6, Serial.read()); analogWrite(9, Serial.read()); + analogWrite(10, Serial.read()); } else { // unknown command }