[quote author=James C4S link=topic=189720.msg1403467#msg1403467 date=1380029222]
How is the button wired? Are you using a pull-up or pull-down resistor? Are you sure you are connected to pin 14 of the ATmega328 or pin 8 of the Arduino Uno? How are you preventing button bounce?
Pin 0 to 7 are going to a resistor. After the resistor there is a led. All the leds are going to the GND.
Pin 8 is connected to a resistor. After the resistor there is the button. The button goes to the 5V.
I am not using the pull-up or pull-down resistor and I am not preventing button bounce.
- Is that your whole program ?
- What programming environment are you using ?
- What is that main() function doing in an Arduino sketch (may be connected to 2 above) ?
- Why use an unsigned char ?
- Did you put multiple statements on one line to make the program difficult to read ?
1: Yes, this is all.
2: I am using Eclipse with the AVR Arduino plugin. (Code isn't working in the Arduino programming environment either)
3: The main() function is a function I use instead of the setup(), loop() etc.
4: Cause the char is never below 0, I used the unsigned char. (unsigned char is: 0 - 255, signed char is: -128 - 127)
5: No, I did that for no reason. That part of the code is running correct when there is now if statement and a little delay of some miliseconds. So there is no problem over there.
But when I press the button, there is just nothing. (it is a software problem)
Or so you assume. Provide some data so that we can confirm that.
Why are you not using setup(), loop(), digitalRead(), pinMode(), digitalWrite(), etc.?
If you delete the if statement (and so the button detection) and add a little delay. You can see the lights turning on and of like the Knight Rider. As you can see in my answer above, the wires are connected correctly.
That is because setup(), loop(), digitalRead() etc. uses more space and is slower. Using the main() method and some portmanupilations makes the program using less space and act faster.