Zagros Robotics for all your robotic parts and supplies

RobotBasic Create Example

RobotBasic is a simple to use but powerful programming language.   

The latest version of RobotBasic can be downloaded from www.robotbasic.com

This simple example program allows an iRobot Create to be controlled with the keyboard arrow keys. 

The program uses a serial port to send byte commands to the Create.  The serial port must be set in the following line of the program to match the computer serial ports the Create is connected to:

SetCommPort 3,11  <-- this is currently set to serial port 3 

Cut and Paste the following into the RobotBasic editor:

//----Remote controlled Robot Simulation
//----Define Constants
LEFT_ARROW = 37
UP_ARROW = 38
RIGHT_ARROW = 39
DOWN_ARROW = 40
//--------------------------------------------------------------
MainProgram:
print "Create Remote Control Program"
setcolor white,blue
SetCommPort 3,11
//rCommPort 0
rLocate 400,300

// init the create
print "comm port open"
SerialOut 130,128

Gosub RemoteControl
End

/---------------Subroutines------------------------------------
RemoteControl:
print "start loop"
while true
getkeyE K
if K <> 0
if K = UP_ARROW
if !(rBumper() & 4) then
rForward 1
SerialOut 130,137,0,255,128,0
elseif K = DOWN_ARROW
if !(rBumper() & 1) then
rForward -1
SerialOut 130,137,255,64,128,0 
elseif K = LEFT_ARROW
rTurn -1
SerialOut 130,137,0,255,0,0 
elseif K = RIGHT_ARROW
rTurn 1
SerialOut 130,137,0,255,255,255
else
SerialOut 130,137,0,0,0,0
endif
rectangle 0,0,800,25,blue,blue
xystring 1,2, "Bumpers=",rBumper()
endif
wend
Return
//-----------

 

Parts for all of your Electronics and Robotic projects

Copyright 2015 - Zagros Robotics, All Rights Reserved - Please send webpage comments or corrections to webmaster@zagrosrobotics.com - Zagros Robotics,12148 Lackland Road, St. Louis, MO 63146- 7342, (314)341-1836, info@zagrosrobotics.com for answers to any questions.

Zagros Robotics, Inc
ASP.NET Shopping Cart Software