Freedom Seeed Grove RGB LED Example

Dependencies:   Chainable_RGB_LED mbed

Fork of frdm_Grove_RGB_LED_Example by Freescale

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.

/media/uploads/GregC/rgb1.jpg

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

/media/uploads/GregC/rgb2.jpg

Your hyperterminal window should also now display the values for each Red Green Blue colors (see picture below)!!

/media/uploads/GregC/rgb3.jpg

Committer:
GregC
Date:
Sat Jan 02 01:45:30 2016 +0000
Revision:
0:dfdc616ec709
Freedom Seeed Grove RGB LED Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregC 0:dfdc616ec709 1 #include "mbed.h"
GregC 0:dfdc616ec709 2 #include "ChainableLED.h"
GregC 0:dfdc616ec709 3
GregC 0:dfdc616ec709 4 #define NUM_LED 3
GregC 0:dfdc616ec709 5
GregC 0:dfdc616ec709 6 // ChainableLED(clk, data, number_of_leds)
GregC 0:dfdc616ec709 7 ChainableLED color_led(D2, D3, NUM_LED);
GregC 0:dfdc616ec709 8
GregC 0:dfdc616ec709 9 int main()
GregC 0:dfdc616ec709 10 {
GregC 0:dfdc616ec709 11 uint8_t index = 0;
GregC 0:dfdc616ec709 12 while(1) {
GregC 0:dfdc616ec709 13 // generate random RGB values for LED's
GregC 0:dfdc616ec709 14 uint8_t R = rand();
GregC 0:dfdc616ec709 15 uint8_t G = rand();
GregC 0:dfdc616ec709 16 uint8_t B = rand();
GregC 0:dfdc616ec709 17 // print message to terminal
GregC 0:dfdc616ec709 18 printf("index = %d, R=%x,G=%x,B=%x,",index,R,G,B);
GregC 0:dfdc616ec709 19
GregC 0:dfdc616ec709 20 // ChainableLED.setColorRGB(index_of_led, red, green, blue)
GregC 0:dfdc616ec709 21 color_led.setColorRGB(index++, R, G, B); // increase brightness cascade down chain of LED's
GregC 0:dfdc616ec709 22 index = ((index+1) % NUM_LED); // cycle through LED's
GregC 0:dfdc616ec709 23 wait(0.05);
GregC 0:dfdc616ec709 24 }
GregC 0:dfdc616ec709 25 }
GregC 0:dfdc616ec709 26