So, I’ve been working on getting the kill switch working, and today, after much deliberation, I have! I required quite a bit of forum talk and plenty of reading with no small amount of breadboarding involved, but I have the kill switch working!
Simply, it was first off bad wiring and then second a bad jumper cable after I got the wiring sorted out.
I was reading over an Arduino projects book I got from the library looking for solutions to features I thought would be fun to implement and followed the wiring they used for buttons. I wired up a breadboard with a simple, no-arduino-involved solution that instead of transfering the power through the button to the Arduino it transferred the power to an LED. You can see the wiring here:
Basically the power comes from the source and then feeds into the right side of the button (the red wire.) Negative is also connected and the negative side of the LED and the negative side of the button (after feeding through a 10kOhm resistor) connect to that. When the button is pressed the power comes through the button and into the Blue wire. Normally, this would be going to pin 2 on the Arduino, but in this case, as it was an experiment, it is going to the LED. The power passes through a 1kOhm resistor (to protect the LED. Always, always, always have a resistor between power and your LED) and then powers the LED.
So onwards with the project! I wired up the Arduino with this new configuration and it ran great! Now I can just push a button and have my robot stop, without having to mess with the power cord, and I can move on with the next part of this project, the programming for the comparison of distance.
Basically what I want to do is make it so that the robot, when it detects an object close enough, turns first to the right and then to the left, getting measurements both times. It then compares the values and whichever side is farther away (larger value), head towards. So I wrote up some code, which is really very simple if you understand the basics, but it doesn’t work right now. If I upload that software to the Arduino the robot spins one way, then very slowly the other and loops that way forever, with the kill switch having no effect. I’m going to keep working at fixing this error, but for now the kill-switch software is stable and the distance detect is most definitely not.