Basic Atom
hey everyone, well, i’ve get the IR hooked up to a servo and i have commands going out, and im getting what i want, im having the micro give serouts whenever it sees anything closer than 250, the problem is the sensor picks up data when the servo is moving heres the code:
left_detect var word
main:
adin ax2, 2, AD_RON, left_detect
serout S_OUT, i57600 ," Right ", dec left_detect, 13]
servo P0, -700
if left_detect >= 250 then
serout S_OUT, i57600 ,"Hi everyone, right_scan works :)", 13]
endif
Pause 2000
adin ax2, 2, AD_RON, left_detect
serout S_OUT, i57600 ," Center ", dec left_detect, 13]
servo P0, 25
if left_detect >= 250 then
serout S_OUT, i57600 ,"Hi everyone, center_scan works :)", 13]
endif
Pause 2000
adin ax2, 2, AD_RON, left_detect
serout S_OUT, i57600 ," Left ", dec left_detect, 13]
servo P0, 700
if left_detect >= 250 then
serout S_OUT, i57600 ,"Hi everyone, left_scan works :)", 13]
endif
Pause 2000
servo P0, 25
goto main
so, i guess my question it, how can i make the micro stop recieving information before the servo moves?
, nvm i fixed, i had the command to get the sensor data in the wrong place heres the results in the terminal 1 window
Left 71
Center 127
Right 345
Hi everyone, right_scan works :)
Center 174
Left 80
Center 344
Hi everyone, center_scan works :)
Right 138
Center 171
Left 401
Hi everyone, left_scan works :)
Center 204
Right 128
Center 396
Hi everyone, center_scan works :)
Left 102
Center 154
Right 425
Hi everyone, right_scan works :)
Center 187
Left 80
Center 390
Hi everyone, center_scan works :)
Right 145
Center 178
Left 453
Hi everyone, left_scan works :)
Center 197
Right 130
Center 349
Hi everyone, center_scan works :)
Left 102
Center 135
i geuss you need an interupt in the program
ok well, i got the program to work, and i want to add something to my code that will allow it to gradually go one way until the object is no longer in sight, how would i go about doing this?
i think if you used the pulsout command
then you can controll the speed depending on what number you use
just think about it
you know that the servo uses this to move to certin position
basic atom 28:
servo p0,#
so if you used a pulsout command
then what use would the position be
cause gear motors dont have pots in them
so how could they read the position
well they dont, they use this to controll the speed
pulsout p0,#
do you think that this would work?
I wrote a couple of nice little subroutines that can be used to read any number of the Sharp IR Ranging sensors, which might interest you. This routine could be used as a template to create a routine to read any number of any single type of sensor. One of the routines is just a power of 2 routine that returns the correct decimal power of 2 value for given bit number. You will find these in my code for W.A.L.T.E.R., downloadable from my website.
This routine just reads the data from the sensors. Other code uses the data to make decisions and take any required action, like turning, etc. Most of my code is in subroutines, so you may find other stuff you can use too.
8-Dale