Okay so my bot (I promise, the page for it is almost done, will post tonight hopefully) is now wandering around my living room (kind of) seeking light, and quite often running into things. I've now added a bump sensor (okay, I've put two wires with bare ends next to eachother on the front of the bot), added some basic code to tell the bot to back up and turn once it bumps into something, and run into a huge problem. Reading the value of pin 2 (which is connected to one of the wires, the other is connected to 3.3v) the value fluctuates randomly between 1 and 0 when the wires are not in contact, and will only stay constant when the wires are in contact. I took the wire out of the pin, and then opened the serial monitor again, and the same thing is happening. How is this possible? and how can I fix it? Noise from the motors made sense when I had the wire hooked into the pin, but with no wire connected to the pin how could the pin be noisy like that?
The input is “floating” it
The input is “floating” it sounds like, where stray signals are being picked up and turning the gate on and off quickly. Use a pull down resistor, that is take a resistor, 10K will work, from the input and tie it to ground. That way the input is no longer floating (tristate) between high and low, and is pulled low until the bumper is pressed.
Not only does that make
Not only does that make sense, it works. Thank you so much, one more problem solved
Oh, and Michelle Corndog is awesome.