
PRO
robo rad
Canada
Asked
— Edited
Bumper Contact Switch Scripting
What is the best way to add a home made bumper contact sensor/switch as my sonar is not quite enough to avoid certain obstacles,is there a simple script example I could follow for a contact switch?
Code:
With electronics it helps to think of everything as a circle (that is what I was taught many years ago). So the digital port has 3 pins right, on the EZB, we have the signal or data line, then have positive power and negative ground.
So typically you would connect a contact switch between the signal and ground. With this setup ideally the signal pin would be in a "high" state until the contact switch is closed and the signal now is connected to the ground to make the state "low".
BUT, if you did nothing further this would not work very well, the signal line would just stay low because there is no return path for it to become "high" once the switch is released. So we use a resister to stay in-between the signal line and the positive power line. The resister is usually a 10k value. (I'm not sure if EZ-Robot has a recommended pull up resister value?). This resister "pulls up" the signal line to a contact state of "high" unless it is interrupted by the contact switch pulling the pin "low".
This state change can be read in ARC from the digital input control.
A "pull down" resister would be the reverse configuration where the resister ties the signal pin to the ground and the contact switch goes between the positive and the signal.
Does that make sense?