Introduction: 2 Wire 2 Button Remote Arduino
I needed to switch something with 2 buttons but only 2 wires are installed.
So this is how i solved this problem:
Step 1: Part List
2 pushbuttons
2 220 ohm resistors
2 LED's
Arduino (mini Pro in my case)
Some wires
2 220 ohm resistors
2 LED's
Arduino (mini Pro in my case)
Some wires
Step 2: How to Connect
1 resistor between the GND and the analoge port (A0).
The 2 wires from the analoge port and the 5v to the remote control.
In the remote control 1 220 ohm resistor after one of the 2 buttons (see drawing).
Connect the LED's to digital pin 11 and 13. For testing not with a resistor but if you gonna use LED's you need to put a resistor between the LED and the GND.
The 2 wires from the analoge port and the 5v to the remote control.
In the remote control 1 220 ohm resistor after one of the 2 buttons (see drawing).
Connect the LED's to digital pin 11 and 13. For testing not with a resistor but if you gonna use LED's you need to put a resistor between the LED and the GND.
Step 3: The Program
Upload the program to your arduino and you are ready!
/* 2 wire 2 button control
By floris@deboktor.nl
nov 2013
req:
-2 x 220 Ohm resistors,
-2 x push buttons,
-2 x LED's,
-Arduino
-some wires
*/
const int ledPin1 = 11;
const int ledPin2 = 13;
const int limit = 450; //if the 2 resistors have the same value then the limit should be about half of 1023
int AnalogeValue = 0;
void setup() {
Serial.begin(9600); //for testing purpose
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop(){
AnalogeValue = analogRead(0);
Serial.println (AnalogeValue);
if (AnalogeValue>(2*limit)){
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1, LOW);
}
else
if (AnalogeValue>limit){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
}
else {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}
}
/* 2 wire 2 button control
By floris@deboktor.nl
nov 2013
req:
-2 x 220 Ohm resistors,
-2 x push buttons,
-2 x LED's,
-Arduino
-some wires
*/
const int ledPin1 = 11;
const int ledPin2 = 13;
const int limit = 450; //if the 2 resistors have the same value then the limit should be about half of 1023
int AnalogeValue = 0;
void setup() {
Serial.begin(9600); //for testing purpose
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop(){
AnalogeValue = analogRead(0);
Serial.println (AnalogeValue);
if (AnalogeValue>(2*limit)){
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1, LOW);
}
else
if (AnalogeValue>limit){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
}
else {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}
}