led
Dependencies: mbed PixelArray
main.cpp
- Committer:
- clementlignie
- Date:
- 2019-06-13
- Revision:
- 3:7559835b072a
- Parent:
- 1:ca76237d2965
File content as of revision 3:7559835b072a:
#include "mbed.h" #include "neopixel.h" // This must be an SPI MOSI pin. #define DATA_PIN p11 DigitalIn BPA(p17); DigitalIn BPB(p18); void generateTourne(neopixel::Pixel * out, uint32_t index, uintptr_t extra) { uint32_t brightness = 100; out->red = ((index + extra) & 0x1) ? brightness : 0; out->green = ((index + extra) & 0x2) ? brightness : 0; out->blue = ((index + extra) & 0x4) ? brightness : 0; } void generateRouge(neopixel::Pixel * out, uint32_t index, uintptr_t extra) { uint32_t brightness = 100; out->red = 255; out->green = 0; out->blue = 0; } void generateVert(neopixel::Pixel * out, uint32_t index, uintptr_t extra) { uint32_t brightness = 100; out->red = 0; out->green = 255; out->blue = 0; } int main() { // Create a temporary DigitalIn so we can configure the pull-down resistor. // (The mbed API doesn't provide any other way to do this.) // An alternative is to connect an external pull-down resistor. DigitalIn(DATA_PIN, PullDown); // The pixel array control class. neopixel::PixelArray array(DATA_PIN); uint32_t offset = 0; while (1) { if (!(BPA)){ array.update(generateVert, 100, offset++); wait(5); } if (!(BPB)){ array.update(generateRouge, 100, offset++); wait(5); } //if ((BPA == 1)&&(BPB == 1)) array.update(generateTourne, 100, offset++); wait_ms(250); } }