I have a strange issue that I am not able to solve.
I have a circuit that has a switch connected to pin D8 as INPUT and have an LED connected to pin D7 for OUTPUT.
I have the switch connected as per this circuit: http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/img/pic_switch.jpg
The resistor I am using is a 10K resistor with the circuit running of 5V.
my code in the loop() procedure is:
iState = digitalRead(buttonPin);
The problem I have is, when I turn the switch off, it acts as expects, the LED goes off …thats all good, BUT when I turn the switch back on again, the digitalRead() does not seem to work !
I have used digitalWrite(yellowled, iState); straight after the digitalRead() and is STILL doesnt work…that is the LED doesnt light up.
I have checked and I do get power hitting D8 when the switch is on, and no power when turned off, so that part of the circuit is working. It just doesnt seem to function when the digitalRead() is performed.
2 Ideas I had were: 1. the program is trying to read the input but it cant and get stuck and cant move on, 2. the resistor might need to be more like 1K instead of 10.
I hope I have provided enough information for someone to be able to help.