Please have a look at this script. Will it run all the way through or will the Halt() command in the first "if" statement cause it to stop before it gets to the "Elseif" section? Thanks for looking. Code:
if ($ADC_Lft_Elbow => 160 )#160-350 is in Centered position
$Lft_Arm_Centered = 0 #Reset varable 1=not cnetered, 0=centered
Halt()
ELSEif ($ADC_Lft_Elbow < 160 #Below 160 is not centered
uartWrite(2, 0, "2,p2480", 0x0d) #Move Lft Elbow Motor down a little
$Lft_Arm_Centered = 0 #Reset varable 1=not centered, 0=centered
endif
Upgrade to ARC Pro
Get access to the latest features and updates with ARC Early Access edition. You'll have everything that's needed to unleash your robot's potential!
The halt command will run if the first condition is met. The halt command will not run if the first condition is not met.
Have you tried using blockly? A visual representation might be easier for you
There are a few issues with the code. especially the use of an "Elseif" instead of an "Else" will result in errors as you end up with TWO IFs and only ONE Endif
Also you were setting $Lft_Arm_Centered to "0" in both of the tests and I don't see the need for a Halt()
Anyway, try this code
Code:
Please note that the "Else clause only moves the arm a little bit and you will need to call this code again until the reading is greater than 160.
You can test $Lft_Arm_Centered variable to see if it needs to be called again
Regards,
Frank
@DJ, you answered my question. That's exactly what I wanted to know. I wasn't sure the Halt command would override the flow and stop it right there.
@Frank, Thanks for pointing out the Else issue. I'll make that change. I didn't post the entire script. Just the section I had a question about. What I'm trying to do here is to move the arm just a little bit if the ADC reading is below 160. If the ADC reading is above 160 then the arm is centered and I don't need to move it at all. You'er right though, to make sure it's in the desired place I should take another ADC reading.
also dave, now that i'm in front of a pc... you're missing a closing bracket on one line
Code:
I'll fix it and see what happens.
The status debug window at the bottom of ARC displays it all. However, if it's ignored then they won't be resolved
and
It goes on like that for pages and pages :D. Now, some of that may be during your testing as well. When your robot project runs, the debug window should never have to raise. It should only need to raise when...
1) project is loaded
2) ezb is connected
3) camera is connected
I don't mind my "dirty laundry" hanging out for all to see. Hopefull others can learn from my mistakes. I know I try to. LOL. I don't fear failure at all. However, it does get flustrating sometimes.
I went through all my scripts again last night and was able to get them all to eun error free. No Debug popup bugging me. I'm sure I'll make more as I move along. It seems like I cant write a script without an error popping up after the first draft. I'll be sure to use the debug wondow from now one. Thanks again.