HomeTurtlegraficsGPanelRobotics WebTigerPython |
Python - Online |
Deutsch English |
YOU LEARN HERE... |
|
EXAMPLES |
Example 1: Drive and turn
Program: from callibot import * forward() delay(2000) left() delay(550) forward() delay(2000) stop() The angle of rotation that the robot covers in 550 milliseconds depends on the surface and, in particular, on the charge status of the batteries. If the robot moves too slowly and only rotates by a small angle, you must change the batteries. Also test the programme in simulation mode. Here the robot always turns exactly 90°. |
Program: from callibot import * forward() delay(4000) backward() setLED(1) delay(3000) setLED(0) delay(1000) stop() |
Program: from callibot import * setSpeed(30) leftArc(0.2) delay(5000) rightArc(0.2) delay(5000) stop() |
REMEMBER... |
The following commands are available for controlling the robot:
When programming robots, you have to think in terms of states. The forward() function sets the robot in a forward motion. While the motors are in this state, the microprocessor can issue commands to other actuators. You can cancel a running programme at any time by switching off the power supply with the blue button on the back of the robot chassis. |
TO SOLVE BY YOURSELF |
|
SUPPLEMENT: CONTROLLING MOTORS AND LEDs INDIVIDUALLY |
The forward(), left() etc. commands control the entire running gear, which consists of two synchronised motors. However, you can also switch on the individual motors and control their speed. To do this, you must import the callibotmot library. With motL.rotate(speed)the left motor is set to forward motion and rotates at the speed speed. For positive speed values the motor rotates forwards, for negative values it rotates backwards and for speed = 0the motor stops. The motR.rotate(speed) command works in the same way for the right motor. |
Example 5: Switching LEDs on and off individually You can use the setLED(1) and setLED(0) commands to switch both LEDs on and off at the same time. You can also address the LEDs individually:
Program: from callibot import * setLEDLeft(1) delay(2000) setLEDLeft(0) setLEDRight(1) delay(2000) setLEDRight(0) |
TO SOLVE BY YOURSELF |
|