Freedom Seeed Grove Relay Example

Dependencies:   mbed

Fork of frdm_Grove_Relay_Example by Freescale

Simply Import this Program into your mbed compiler
Select Compile to generate the binary file
Plug the Grove Shield v2 on the top of your FRDM-K64F
Connect on end of the 4-pin Grove cable to the Relay module and the other end to the port D6 of the Grove Adapter.

/media/uploads/GregC/relay1.jpg

Drag n drop the frdm_Grove_Relay_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 relay should now switch On and Off each time you press the SW2 button of your FRDM-K64F (see picture below)!!

/media/uploads/GregC/relay2.jpg

Committer:
GregC
Date:
Fri Jan 01 16:33:29 2016 +0000
Revision:
0:3b9b4fce896e
Freedom Seeed Grove Relay Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregC 0:3b9b4fce896e 1 #include "mbed.h"
GregC 0:3b9b4fce896e 2
GregC 0:3b9b4fce896e 3 DigitalOut relay(D6);
GregC 0:3b9b4fce896e 4 InterruptIn sw2(SW2);
GregC 0:3b9b4fce896e 5
GregC 0:3b9b4fce896e 6 void sw2_release(void)
GregC 0:3b9b4fce896e 7 {
GregC 0:3b9b4fce896e 8 relay = !relay;
GregC 0:3b9b4fce896e 9 }
GregC 0:3b9b4fce896e 10
GregC 0:3b9b4fce896e 11 int main()
GregC 0:3b9b4fce896e 12 {
GregC 0:3b9b4fce896e 13 sw2.rise(&sw2_release);
GregC 0:3b9b4fce896e 14 while (true) {
GregC 0:3b9b4fce896e 15 }
GregC 0:3b9b4fce896e 16 }