Today i'm going to explain,How to control any electronics equipment by switch using Arduino.
for these we need some hardware which are mentioned below
1> Computer
2> Cable
3> Arduino
4> Switch
5> Resistor
This project is based on the reading of the digital signal.Write the code shown below to your Arduino ide software in your computer,the connect the Arduino to your PC & upload the program to your arduino by using the botton in your ide.
code :-
int led=12;//input pin of led
int signal=7;//input pin of signal via switch
void setup() {
pinMode(led,OUTPUT);//declare the led is for output
pinMode(signal,INPUT);//declare the signal as input
}
void loop() {
int val=digitalRead(signal);//measure input signal value
if (val==1)//if measure value is equal to 1
digitalWrite(led,HIGH);//led pin is on
else
digitalWrite(led,LOW); //led is off
}
connect one pin of switch to the ground(GND) and another pin to the port no 7 of arduino.
for these we need some hardware which are mentioned below
1> Computer
2> Cable
3> Arduino
4> Switch
5> Resistor
This project is based on the reading of the digital signal.Write the code shown below to your Arduino ide software in your computer,the connect the Arduino to your PC & upload the program to your arduino by using the botton in your ide.
code :-
int led=12;//input pin of led
int signal=7;//input pin of signal via switch
void setup() {
pinMode(led,OUTPUT);//declare the led is for output
pinMode(signal,INPUT);//declare the signal as input
}
void loop() {
int val=digitalRead(signal);//measure input signal value
if (val==1)//if measure value is equal to 1
digitalWrite(led,HIGH);//led pin is on
else
digitalWrite(led,LOW); //led is off
}
connect one pin of switch to the ground(GND) and another pin to the port no 7 of arduino.