![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Un script para cambiar el color
Dependencies: PixelArray USBDevice mbed
Fork of blip_rainbow_ejemplo by
main.cpp
- Committer:
- jjmerelo
- Date:
- 2015-11-30
- Revision:
- 6:482c4dccb291
- Parent:
- 4:8eac4e92928a
- Child:
- 7:e5c1d481ad40
File content as of revision 6:482c4dccb291:
// potenciometro controla la matriz // y buzzer al mismo tiempo envia por // el puerto serie #include "mbed.h" #include "neopixel.h" #include "USBSerial.h" // Matrix led output pin #define MATRIX_PIN P0_9 #define NLEDS 25 AnalogIn ain(P0_22); unsigned int counter = 0; USBSerial serial; neopixel::Pixel buffer[NLEDS]; PwmOut speaker(P0_8); void setPixel(uint32_t posicion, uint8_t red, uint8_t green, uint8_t blue) { buffer[posicion].red=red; buffer[posicion].green=green; buffer[posicion].blue=blue; } int main() { // Turn off miniblip buzzer speaker=0.0; serial.printf("Hello world!\n"); while(true) { float pot = ain.read() * 50.0f; serial.printf("mini blip is alive for %i seconds.\n", counter); serial.printf("Pot: %3.3f%%\n", pot); counter++; neopixel::PixelArray array(MATRIX_PIN); for(int i=0;i<NLEDS;i++) { setPixel(i, pot, 0, 0); } float note=500+(pot); speaker.period(1.0/note); speaker = 50.0; array.update(buffer, NLEDS); //wait(1); } }// miniblip led matrix demo