-
1Run a Program
#include
//#define ON 1
//#define OFF 0
/*
* Pin Description
*/
int Touch_Sensor = A5;
int LED = 13;
int Relay = A4;
/*
* Programme flow Description
*/
int condition = 0;
int state = 0; //To hold the switch state.
/*
* Pin mode setup
*/
void setup() {
pinMode(Touch_Sensor, INPUT);
pinMode(LED, OUTPUT);
pinMode(Relay, OUTPUT);
}
void loop() {
condition = digitalRead(A5); // Reading digital data from the A5 Pin of the Arduino.
if(condition == 1){
delay(250); // de-bounce delay.
if(condition == 1){
state = ~state; // Changing the state of the switch.
digitalWrite(LED, state);
digitalWrite(Relay, state);
}
}
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.