I have got two EZBv4's connected to my project. As you can see in the code below, I have an Ultrasonic sensor connected to controller #1 and I am trying to get it to move a servo one controller #0. When I run it, the servo does not move. Am I missing something in communicating between the two controllers?
$trigport = 1.D0
$echoport = 1.D1
$proxclose = 50 # Change for minimum distance
$proxsense = GetPing($trigport, $echoport)
IF($proxsense < $proxclose)
elseif($proxsense > $proxclose)
Upgrade to ARC Pro
Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.
However, and I know that I am guilty of this but ports shouldn't really be defined by variables. If they aren't going to change in your project you might as well hard code them in.
Also, I'm not sure if it's the forums or if it's the way you intended but it doesn't show the less than sign in the if statement.
And finally, where's the code to move the servo? It looks like it's missing the line
Presuming the servo is on board 0 and needs to move to position 90.
note: if board 0 is used you needn't use the preceding 0. as part of the port number, it will always assume the board is board 0 unless otherwise stated.
It does what it should when I run it on the console.
Also, the elseif isn't needed. If the first argument is false (i.e. ping less than 50) then just using the goto(start) will work fine. The elseif is practically doing the same thing. The sleep after the goto in the elseif is redundant as it'll never get to be executed.
Try this code, it should work;
If it doesn't work try running just the following piece of code;