[vc_row][vc_column][vc_column_text]In this post , I will demo how to use Linker Relay and button to control Desk Lamp on pcDuino.
[/vc_column_text][vc_tour][vc_tab title=”Part List” tab_id=”1414716956-1-2″][vc_column_text]Do this experiment , we need
1 x pcDuino[/vc_column_text][/vc_tab][vc_tab title=”Assemble procedure” tab_id=”1414716956-2-87″][vc_column_text]First, we need to split the desk temp base
Then take off the two lines connect to the button of the desk lamp, and connect the two lines to Linker Relay
Last, we install the Linker relay and button to the linker Base
[/vc_column_text][/vc_tab][vc_tab title=”Test code” tab_id=”1414719021349-2-0″][vc_column_text]The work of the hardware part is done
Then we need to input the code to the Arduino IDE
int relay = 5 ; int button = 6; void setup() { pinMode(relay,OUTPUT); pinMode(button,INPUT); } void loop() { static int LED_Status = 0; if(digitalRead(button)) { delay(20); if(digitalRead(button)) { LED_Status ++; if((LED_Status&0x01)) digitalWrite(relay,HIGH); else digitalWrite(relay,LOW); delay(200); } } }
[/vc_column_text][/vc_tab][vc_tab title=”Test result” tab_id=”1414719022349-3-3″][vc_column_text]Power for the pcDuino, and input the code to the Arduino IDE.
Then click the button, and you will see the desk lamp will change light on or off.
Comments are closed.