Freedom Seeed Grove RGB LED Example
Dependencies: Chainable_RGB_LED mbed
Fork of frdm_Grove_RGB_LED_Example by
Simply Import this Program
into your mbed compiler
Select Compile
to generate the binary file
Open an Hyperterminal window and connect to the mbed Serial Port (COMxx)
peripheral using speed 9600bps
Plug the Grove Shield v2 on the top of your FRDM-K64F
Connect on end of the 4-pin Grove cable to the Chainable RGB LED module and the other end to the port D2 of the Grove Adapter
.
Drag n drop the frdm_Grove_RGB_LED_Example_K64F.bin
into the mbed drive from your file explorer
Wait for download to complete
Press the Reset/SW1 button of your FRDM-K64F board
to launch the program
The RGB LED should lite up changing colors randomly
Your hyperterminal window should also now display the values for each Red Green Blue colors (see picture below)!!
Diff: main.cpp
- Revision:
- 0:dfdc616ec709
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jan 02 01:45:30 2016 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "ChainableLED.h" + +#define NUM_LED 3 + +// ChainableLED(clk, data, number_of_leds) +ChainableLED color_led(D2, D3, NUM_LED); + +int main() +{ + uint8_t index = 0; + while(1) { + // generate random RGB values for LED's + uint8_t R = rand(); + uint8_t G = rand(); + uint8_t B = rand(); + // print message to terminal + printf("index = %d, R=%x,G=%x,B=%x,",index,R,G,B); + + // ChainableLED.setColorRGB(index_of_led, red, green, blue) + color_led.setColorRGB(index++, R, G, B); // increase brightness cascade down chain of LED's + index = ((index+1) % NUM_LED); // cycle through LED's + wait(0.05); + } +} +