setup neopixel control

bluepill
JbLb 6 years ago
parent eb50a5a0fb
commit fe9377cc28

@ -4,10 +4,11 @@
#include <Adafruit_SSD1306.h>
#include <Adafruit_NeoPixel.h>
#define PIN PB_5 // Pin where NeoPixels are connected
#define PIN PB5 // Pin where NeoPixels are connected
#define NB_LED 12 // number of LEDs
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(32, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip(NB_LED, PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
@ -70,6 +71,19 @@ SerialFeedback NewFeedback;
int cmd1; // normalized input values. -1000 to 1000
int cmd2;
// ########################## colorWipe ##########################
// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
// Serial1 PA_9 TX PA_10 RX
// ########################## SETUP ##########################
@ -93,6 +107,7 @@ void setup()
strip.begin(); // INITIALIZE NeoPixel strip object
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
while (!Serial)
;
@ -108,6 +123,14 @@ void setup()
display.println("Hoverboard Control");
display.setCursor(int((display.width() - (strlen("v STM32 0.1") * 6)) / 2), 8);
display.println("v STM32 0.1");
// Fill along the length of the strip in various colors...
colorWipe(strip.Color(255, 0, 0) , 20); // Red
colorWipe(strip.Color( 0, 255, 0) , 20); // Green
colorWipe(strip.Color( 0, 0, 255) , 20); // Blue
colorWipe(strip.Color( 0, 0, 0) , 20); // Black
}
// ########################## SEND ##########################
void Send(int16_t uSteer, int16_t uSpeed)
@ -257,5 +280,5 @@ void loop()
digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000);
Receive();
Nunchuk_control();
// Serial.println(timeNow);
Serial.println(timeNow);
}

Loading…
Cancel
Save