Asked
— Edited
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.
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
I don't understand the question?
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
Hi Dave, 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
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
Thanks guys.
@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.
@Frank's the man with the plan
also dave, now that i'm in front of a pc... you're missing a closing bracket on one line
Humm, nice. Thanks for catching that. I'm surprised that the script was running without sending an error message. On the other hand, there's so much going on in the project that I could be missing it. I'll fix it and see what happens.
Oh, you have plenty of errors in your log files. Hundreds in fact. Missing quotes, improperly formed conditions, etc.
The status debug window at the bottom of ARC displays it all. However, if it's ignored then they won't be resolved
Oh my, how embarrassing. I do know I've been going through all my scripts lately and either rewriting them or cleaning them up. I have been finding and creating lots of errors. Maybe this is what you're seeing. I'll be watching that debug window closer now.
Nothing to be embarrassed about. Learning is harmless. watch the window. Here's some examples from yesterday...
and
It goes on like that for pages and pages. 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...
@DJ Hey no fair, no hangin' out peoples dirty laundry man Oops I guess I'm next
Hey - that's helpful information for David. Far from dirty laundry. At least i suspect he'd see it as helpful
Yes , I do see this as helpful. Looking at the dates listed these were back in december when I was having "qiote" issues because I was having trouble with understanding Bianery among other things. You made some changes in ARC and I made some adjustments and that issue was solved.
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.
That's excellent to hear! Happy robot