Asked — Edited
Resolved Resolved by Rich!

How Do I Make A Script?

hi i managed to find the sonar and got the sound to. i have the rgb,so how do i wright all this in a script. what i want is that the sonar turn whit sound and when he spot an object. the rgb flach red whit sound danger danger danger.

thanks


ARC Pro

Upgrade to ARC Pro

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

PRO
Belgium
#2  

rr

nope that doesn work?

United Kingdom
#3  

Nomad, I suggest you check out the EZ-Script Tutorial. It covers the basics.

Once you have understood the EZ-Script Tutorial you will have a better understanding of what a script is, the available commands, which commands are required for the task you have described and how to easily create the script without much typing at all.

In addition to the EZ-Script Tutorial there is also the EZ-Script Manual which I recommend reading through so that you can understand which commands do what, how they work and the correct syntax.

PRO
Belgium
#4  

rich

thank you for the link.

#5  

@Nomad ... I don't think you need our help anymore to find the tutorials how to do all this stuff, do you?

#6  

OK nomad, what you'll need to do is make a script which does the following.

  1. It has to track the position of the sonar servo. This can be done by:
$sonar=GetServo(d3)#sets the sonar variable to the servo position
  1. You need to get the sonar scanning. Here's what you do for a sonar script:
:loop
#start scaning
servo(d3, + 1) #Takes the current servo position and adds 1 position to it.

  1. The detection part. This either moves your rgb bar and turns it red or loops around.
If (GetPing(d5, d6) < 20)  #set to your min distance, this is what triggers the warning
Servo(d9, $sonar) #this moves the light bar to the same position as the sonar
sayezb("Danger, Danger, Danger") #your audible warning
#Light code goes here
Endif

Goto(loop)# this loops the warning code

Any problems please tell me and ill fix it(anyone).

United Kingdom
#7  

Techno, just curious as to what the + 1 is in the code.

servo(d3, + 1)

Have I missed a function in EZ-Script?

#8  

That was meant as take the current position and add one. Should be $sonar +1.

Final code V1

#Default light code goes here, AKA blue or safe color

#Default servo positions
Servo(d3, 1)
Servo(d9, 90)

:loop
#Set this to the sonar servo port.
$sonar=GetServo(d3)


#start scaning

#Set your max position here
If ($sonar = 180)
servo(d3, 1)
Elseif ($sonar <180)
servo(d3, $sonar + 1)
Endif


#Set distance min here
If (GetPing(d5, d6) < 20)
Servo(d9, $sonar)
sayezb("Danger, Danger, Danger")
#Light code goes here
Endif

Goto(loop)