I checked the leads on the switch and they seem to be in order, but still my hand has to be near any switch. I am using the Arduino with the motor shield from sparkfun and I am making a basic turn on motor if switch is on and when I switch it to HIGH it will only run if my hand is near the switch anyone else ever have this problem?
I have connected the switch from digital pin 10 to ground and the motor shield has the motor set up to connect to digital pin 11 if anyone has seen this behavior before please tell me. and maybe why it is happening?
the software does work just to note.
Well I would have to see a wiring drawing to be sure, but I suspect you have a 'floating input pin' situation. If you indeed have a switch wired between the input pin and ground, when you open the switch there is no valid voltage to read as a high input. You need to either enable the internal pull-up for that input pin, or wire an external resistor between the pin and +5vdc pin.
Lefty
when you say +5VDC you mean between the digital pin 10 and the switch right?
also, sorry, what size resistor 220ohm?
also, sorry, what size resistor 220ohm?
No, 10K ohms is better so as not to draw more current then needed.
when you say +5VDC you mean between the digital pin 10 and the switch right?
No, the resistor would wire between the switch input pin 10 and the +5vdc pin on the arduino shield power connector. That should be avalible on the motor shield as a 'pass through' connection?
Easier yet would just to enable the pin 10 internal pull-up resistor:
void setup()
{
int Switch = 10;
pinMode(Switch, INPUT); // sets the digital pin as input
digitalWrite(Switch, HIGH); // turn on the internal pull-up for pin 10
}
void loop()
{
}
Lefty
awesome I used the pull up resistor works like a charm with no extra circuitry thanks
you can turn on multiple pull up resistors at the same time right?
ardlab:
you can turn on multiple pull up resistors at the same time right?
Not sure what you are asking here. If you mean can each and every input pin have it's own internal pull-up resistor enable or not, that would be correct.
Lefty