Author Topic: Can i use a microswitch on the 50 $ robot?  (Read 2356 times)

0 Members and 1 Guest are viewing this topic.

Offline ioannisTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
Can i use a microswitch on the 50 $ robot?
« 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?

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: Can i use a microswitch on the 50 $ robot?
« Reply #1 on: February 27, 2008, 02:45:59 PM »
do the same thing as the photoresistors, but replace the photocell with the switch. when the switch gets pressed the output goes HIGH.
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: Can i use a microswitch on the 50 $ robot?
« Reply #2 on: February 27, 2008, 03:00:31 PM »
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
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Can i use a microswitch on the 50 $ robot?
« Reply #3 on: March 01, 2008, 10:58:04 PM »
remember to always search first ;)
http://www.societyofrobots.com/sensors_tactbumpswitch.shtml

the Vout goes to the ADC, just like the photoresistors

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: Can i use a microswitch on the 50 $ robot?
« Reply #4 on: March 01, 2008, 11:27:17 PM »
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
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Can i use a microswitch on the 50 $ robot?
« Reply #5 on: March 02, 2008, 11:39:53 AM »
if you want to use ADC, you'd do something more like:

Code: [Select]
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):
Code: [Select]
if(PORT_IS_ON( port_letter, number ))
   X

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: Can i use a microswitch on the 50 $ robot?
« Reply #6 on: March 02, 2008, 11:57:09 AM »
if you want to use ADC, you'd do something more like:

Code: [Select]
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
« Last Edit: March 02, 2008, 11:57:57 AM by ed1380 »
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,632
  • Helpful? 169
    • Society of Robots
Re: Can i use a microswitch on the 50 $ robot?
« Reply #7 on: March 02, 2008, 12:49:23 PM »
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.

Offline spizzak

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 1
Re: Can i use a microswitch on the 50 $ robot?
« Reply #8 on: July 13, 2009, 10:06:54 PM »
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.


 


Get Your Ad Here

data_list