i started to build an infrared transmitter (commander). I use 4 pushbuttons for left, right, up, down. These buttons are pulling down when pressed. I used internal pullup resistors. My prboblem is that the arduino is seeing one pin as high (not changeable by pressing button) and the other pins as low (not changeable by pressing buttons). It is not recognizing the changes.
I tried the following to solve:
- First i used Pulldowns and the result was the same. Then i searched for an alternative and found pullupp. The same Problem.
- I tried other pins. Same Problem.
- Checked the soldering connections. Everything is OK.
- Then i measured the voltages for the first pin. When nothing is pressed the voltage between pin A0 and Ground is 0V and when pressed the voltage between pin A0 and Ground is 0V.
- I took external resistor (1k) instead of internal pullup. Know the probelm with the single one is solved. The voltages when pressed and not pressed are OK. But the controller pins are not recognizing the changes.
The last point is very strange i expected 5V when not pressed and 0V when pressed.
Here is my code:
#include <IRremote.h>
#include <IRremoteInt.h>
IRsend irsend;
// The configuration of the output pin will be made by the library
// The output pin is a different one for different arduinos
// Arduino UNO: Output = D3
// Arduino MEGA: Output = D9
// You will find a full list of output pins on the website:
// http://z3t0.github.io/Arduino-IRremote/
#define TASTE_HOCH 19 //A0
#define TASTE_RECHTS 22 //A3
#define TASTE_UNTEN 21 //A2
#define TASTE_LINKS 20 //A1
int aktiveTaste = 0; //Taste die momentan gedrückt ist
void setup()
{
pinMode(TASTE_HOCH, INPUT_PULLUP);
pinMode(TASTE_RECHTS, INPUT_PULLUP);
pinMode(TASTE_UNTEN, INPUT_PULLUP);
pinMode(TASTE_LINKS, INPUT_PULLUP);
Serial.begin(9600);
}
// main program loop
void loop() {
Serial.print("TASTE_HOCH: ");
Serial.println(digitalRead(TASTE_HOCH), DEC);
Serial.print("TASTE_RECHTS: ");
Serial.println(digitalRead(TASTE_RECHTS), DEC);
Serial.print("TASTE_UNTEN: ");
Serial.println(digitalRead(TASTE_UNTEN), DEC);
Serial.print("TASTE_LINKS: ");
Serial.println(digitalRead(TASTE_LINKS), DEC);
delay(3000);
if(digitalRead(TASTE_HOCH) == LOW){
aktiveTaste = 1;
}
else if(digitalRead(TASTE_RECHTS) == LOW){
aktiveTaste = 2;
}
else if(digitalRead(TASTE_UNTEN) == LOW){
aktiveTaste = 3;
}
else if(digitalRead(TASTE_LINKS) == LOW){
aktiveTaste = 4;
}
if(aktiveTaste > 0){
// The transmitter sends in this example the signal A90 (hex. dezimal form) in the encoding "RC5"
// It will be transmitted 3 times after that it will make a 5 second break
for (int i = 0; i < 3; i++) {
irsend.sendRC5(aktiveTaste, 12); // [0xA90] signal | [12] Bit-length signal (hex A90=1010 1001 0000)
delay(40);
}
aktiveTaste = 0; //Keine Taste gedrückt
}
}
And This is the output of serial print:
What is the cause for not recognizing changes?