Un script para cambiar el color

Dependencies:   PixelArray USBDevice mbed

Fork of blip_rainbow_ejemplo by JJ Merelo

Committer:
pighixxx
Date:
Thu Nov 26 09:28:37 2015 +0000
Revision:
3:2d84c8262139
Parent:
1:ca76237d2965
Child:
4:8eac4e92928a
miniblip demo program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pighixxx 3:2d84c8262139 1 // miniblip led matrix demo
pighixxx 3:2d84c8262139 2
JacobBramley 0:60499ad28ea9 3 #include "mbed.h"
JacobBramley 1:ca76237d2965 4 #include "neopixel.h"
JacobBramley 0:60499ad28ea9 5
pighixxx 3:2d84c8262139 6 // Matrix led output pin
pighixxx 3:2d84c8262139 7 #define DATA_PIN P0_9
JacobBramley 0:60499ad28ea9 8
JacobBramley 1:ca76237d2965 9 void generate(neopixel::Pixel * out, uint32_t index, uintptr_t extra)
JacobBramley 1:ca76237d2965 10 {
JacobBramley 1:ca76237d2965 11 uint32_t brightness = (index + extra) >> 3;
JacobBramley 1:ca76237d2965 12 out->red = ((index + extra) & 0x1) ? brightness : 0;
JacobBramley 1:ca76237d2965 13 out->green = ((index + extra) & 0x2) ? brightness : 0;
JacobBramley 1:ca76237d2965 14 out->blue = ((index + extra) & 0x4) ? brightness : 0;
JacobBramley 0:60499ad28ea9 15 }
JacobBramley 0:60499ad28ea9 16
JacobBramley 1:ca76237d2965 17 int main()
JacobBramley 1:ca76237d2965 18 {
pighixxx 3:2d84c8262139 19 // Turn off miniblip buzzer
pighixxx 3:2d84c8262139 20 PwmOut speaker(P0_8);
pighixxx 3:2d84c8262139 21 speaker=0.0;
JacobBramley 1:ca76237d2965 22 // Create a temporary DigitalIn so we can configure the pull-down resistor.
JacobBramley 1:ca76237d2965 23 DigitalIn(DATA_PIN, PullDown);
JacobBramley 1:ca76237d2965 24
JacobBramley 1:ca76237d2965 25 // The pixel array control class.
JacobBramley 1:ca76237d2965 26 neopixel::PixelArray array(DATA_PIN);
JacobBramley 1:ca76237d2965 27
JacobBramley 1:ca76237d2965 28 uint32_t offset = 0;
pighixxx 3:2d84c8262139 29 uint32_t i = 1;
JacobBramley 1:ca76237d2965 30 while (1) {
pighixxx 3:2d84c8262139 31 array.update(generate, 64, offset++);
pighixxx 3:2d84c8262139 32
pighixxx 3:2d84c8262139 33 //Play Sound
pighixxx 3:2d84c8262139 34 float note=500+(i*100);
pighixxx 3:2d84c8262139 35 //speaker.period(1.0/note);
pighixxx 3:2d84c8262139 36 //speaker = float(i)/50.0;
pighixxx 3:2d84c8262139 37
pighixxx 3:2d84c8262139 38 i++;
pighixxx 3:2d84c8262139 39 if (i>10) i=1;
pighixxx 3:2d84c8262139 40 // Rainbow delay
pighixxx 3:2d84c8262139 41 wait_ms(100);
JacobBramley 0:60499ad28ea9 42 }
JacobBramley 0:60499ad28ea9 43 }