Getting strange readings from digital input
August 24, 2011
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?