2 "sensors" on one input?

jtbarclay

New Member
I've got a little zipzap rc car with a 08m hooked up to control it, unfortunately this takes up 4 outputs and I am left with one input. The input is currently a micro switch on the front to have it backup on collision. Here is a picture of it, it's being powered by the small internal battery and a 1F capacitor.

http://www.jonathanbarclay.com/img//Cam-20090410-215924.png

I would like to add a sharp ir distance sensor and turn it into a wall following robot, but if it gets into a corner it's going to be useless without the front bump switch.

What I'd like to know is if it would be possible to have the input, pin 3, reading the analog input from the sensor, but also have a loop in my code to check for that pin going low when the front switch is closed?
 

SgtB

Member
Shure. Just use the switch to pull the ADC high. That will overide the Sharp's output. Use logic to detect it.
 

westaust55

Moderator
I presume that by "pin 3" you mean physical leg 3 for In4/ADC4.
Pin3 on physical leg 4 of an 08M does not have ADC input capability.


to check for that pin going low when the front switch is closed
Yes, use the switch to pull the input low by conencting the switch between input3 and 0V. You might want a resistor between input 3 and the analogue signal to prevent shorting the analogue signal output.

Then you can just check READADC, b0
If b0 = 0 THEN ; the switch is closed.

Can the analogue signal go down to 0V? If using say a pot, you couldadd a small resistor to make the bottom/lowest value = say 5 or 10.
Not sure what you can do for you distance sensor. More information may help.
 
Last edited:

jtbarclay

New Member
Shure. Just use the switch to pull the ADC high. That will overide the Sharp's output. Use logic to detect it.
Would I have to use a diode to protect the sharp from the pin being pulled high?

I presume that by "pin 3" you mean physical leg 3 for In4/ADC4.
Pin3 on physical leg 4 of an 08M does not have ADC input capability.




Yes, use the switch to pull the input low by conencting the switch between input3 and 0V. You might want a resistor between input 3 and the analogue signal to prevent shorting the analogue signal output.

Then you can just check READADC, b0
If b0 = 0 THEN ; the switch is closed.

Can the analogue signal go down to 0V? If using say a pot, you couldadd a small resistor to make the bottom/lowest value = say 5 or 10.
Not sure what you can do for you distance sensor. More information may help.
I'm not sure what physical pin it is, it's pin 3 on the 08 proto board. It's the one pin that has to be an input, because the other 4 are outputs.

The sensor is a analog sharp ir distance sensor http://www.acroname.com/robotics/info/articles/sharp/sharp.html
 

Andrew Cowan

Senior Member
The pin that can only be an input cannot be used with readADC, or many of the other input commands (eg pulsin, I think).

A
 
Top