Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: ioannis on February 27, 2008, 08:02:51 AM
-
I was wondering how it is possible to connect a couple of microswitches to the 50 $ robot? Anybody able to give advice?
-
do the same thing as the photoresistors, but replace the photocell with the switch. when the switch gets pressed the output goes HIGH.
-
what do you want the microswitch to do?
if you know to program for AVRs, you can even switch the bot from photovore to photophobe mode, or to other custom function.
otherwise, you can do little with switches. one idea is bumper switches, as ed1380 said. bot bounces around, when it hits something with the switch, it turns (or hits it again, s/m mode ;D).
you can put another switch on the battery pack, for example to have an on/off switch
-
remember to always search first ;)
http://www.societyofrobots.com/sensors_tactbumpswitch.shtml
the Vout goes to the ADC, just like the photoresistors
-
now to retype this for the 2nd time. darn avrstudio with it's undersize window. :(
admin i understand the elctronic part of that, but as usuall I'm baffled by the code side of it. if i wanted the $50 robot to do X when the first sensor is HIGH. do I do this:
variable=a2dConvert8bit(1);
if(variable==1)
X
-
if you want to use ADC, you'd do something more like:
variable=a2dConvert8bit(1);
if(variable>127)//0->127 is low, 128->255 is high
X
if you use a digital port (like what the servos use):
if(PORT_IS_ON( port_letter, number ))
X
-
if you want to use ADC, you'd do something more like:
variable=a2dConvert8bit(1);
if(variable>127)//0->127 is low, 128->255 is high
X]
thanks. so if i use that method i wont need to change the header file. I'd just try it out myself, but right now I'm kinda away
-
Yea, if you use the analog method, nothing else needs to be changed.
If you use the digital method, you will have to make a small mod to the SoR utils file to change the digital port to an input instead of an output. Instructions are written in that file.
-
Can someone explain to me how to switch one of the digital ports (for example PD2) to an input? I cant figure it out from the header file.
-
http://www.scienceprog.com/reading-avr-button-status-using-winavr/ (http://www.scienceprog.com/reading-avr-button-status-using-winavr/)