I am new, so bear with me. I followed and fundamentally understand my first robot tutorial located here:
I'm a 30 year veteran of programming. so that was the easy part, and I have that robot working correctly. Because the IR sensor in that tutorial doesn't look down, the sides of the robot can sometimes get stuck on low-lying objects. So, I bought some simple buttons to use for bump sensors. I followed the example here:
I haven't written any code for the buttons yet, and have just wired them into the existing breadboard, attaching one button to pin 2 and the other to pin 3. The connection from the button with the 10ohm resistor connects to ground, and its opposing connector to power. Everything that previously existed on the robot appears to still work, but when a button is depressed, it seems to rob the whole robot of power.
I've tried a few things, but, still too new to this to make an educated guess. I'm not worried about the programming. Just how to wire everything up properly so they don't zap the power of the bot.
That tutorial explains the reason for using pull-up/pull-down resistors but IMO would be better illustrating the use of pull up resistors and then explaining that the Arduino has some internal pull-up resistors which can be enabled by software - these avoid the need to connect external resistors.
Remove the external resistor from the circuit, add code in setup() to enable the pull-up resistor on the input pin, connect the switch between the input pin and ground, design the sketch to treat a LOW input state as indicating the switch is closed.
josephmmorgan:
Thank you. That little K made all the difference.
As a matter of pure curiosity, why, when using the 10ohm resistor did depressing the button kill the power to everything?
Sorry for the delay... had to run out and get some 10Kohm resistors.
Because a resistor of 10R across 5V will draw a current of 5 / 10 = 0.5 Amp. This is called ohms law.
That is a lot of current and your supply could not cope.
With 10K you have a current of 0.0005 Amp, which as you can see is a lot smaller.
Thanks to both of you, PETERH and Grumpy_Mike for your help.
After I add a backup IR sensor, another front bump sensor, and a little speaker to go beep, beep, beep when it backs up, I'll probably max out this little guy.
Then I'll be looking for lessons on how to turn the whole thing into a single PCB and rebuild it so I can rescue this Arduino for the next bot.