
RoboHappy
Im a little confused here. I'm simply trying to read the value coming from my IR sensor (one of the Sharp IR ones).
The script I wrote should should be a simple loop and display the value, can continue to display the value until I tell it to stop.Code:
goto(sensor)
:sensor
$IRSensor = GetADC(ADC4)
# Sharp IR Sensor
print($IRSensor)
sleep(1000)
Return()
It seems to run only a couple of times then stops. That's my issue, why it displays the values twice then stops. What am I missing?
*confused*
Code:
let's follow the execution:
1) goto sensor
2) arrive at sensor label
3) read & print & sleep 1 second
4) call return => do a stack pop => founds a goto (quote point 1)
5) arrive :sensor
6) read & print & sleep 1 second
7) call return => do a stack pop => stack is empty no goto (quote point 2) => do nothing
conclusion 2 readings
ok, I think I see it now.I was following a method I've used when programming a Basic Stamp. next test will be to add a ping sensor, then to add a specific value to each to cause some action to happen.
This was my next test, which am happy to say works!
Code:
Next, since I have 3 stationary ping sensors to add in, and want to run the IR on a servo to sweep.
Code:
*confused* *confused* *confused*
Code:
is similar to:
Code:
it's easy to understand each ADC_Wait blocks the script until the condition is met, the delay is used to define how frequent ARC pulls an ADC reading from the EZB.
The question is this what you want ?
if you don't want ADC_Wait to block the script you should change to :
Code:
Morning! yes that is correct, I don't want the ADC to Wait. I want to run and loop just like the sensors are doing. In most cares the bumpers will act as a secondary if any of the other sensors failed to stop the robots forward motion.
The ultimate goal will be to have the IR sensor on a servo to sweep, but will only sweep after one of the other sensors have been triggered. Then the robot performs another task,etc.
Thank you again. I will try some more experiments tonight,love to see what happens!
Code:
*eek*
Regards.
That is true, I could use the digital ports. At least now I could since I've ported all the servos over to the SSC32 and in fact freed up the digital ports. At the time I did not have any more ports left except the adc, so wanted to learn best way to use with the switches since I've seen it done before on the forums earlier. I still may do the digital route again, but for now I'm sticking with the adc, and the best, for me, at least it is getting some more programming experience out of it the best part with the help of this great community here.