You are on page 1of 10

Function of each sensor

- SENSOR1 : Left wall follower sensor - SENSOR2 : Left floor sensor - SENSOR3 : Front wall sensor - SENSOR4 : Right floor sensor - SENOSR5 : Right wall follower sensor - SENSORL : Senses whether there is wall on the left - SENSORR : Senses whether there is wall on the right

IR sensors can easily be bent. Make sure it stays horizontal


START(use buzzer or not); Initiation of robot program <Description> It lays initial setting and defines whether to turn on buzzer for debugging purpose. When the buzzer is set, the robot may tremble a little. <Range of parameters> 1. To use buzzer or not: 0, 1 - If 0: No buzzer - If 1: Buzzer sounds each time a function is completed (for debugging purpose) start(1); // sounds each time a function is completed (for debugging purpose)

DRIVER(speed ratio 1, speed ratio 2, speed ratio 3, speed ratio 4); Setting the method of following the wall <Description> Using Driver function, you can set how accurately the robot should follow the wall. The speed ratio should gradually decrease between 1 and 4. Overall higher values make robot sway less but also less accurate, while lower values make robot trace wall precisely but it is likely to sway more. <Range of parameters> driver (speed ratio 1, speed ratio 2, speed ratio 3, speed ratio 4); speed ratio: 0 ~ 20 - You need to set driver with accuracy when collecting or discharging objects. - driver (20,15,10,5); - Other times, you may like to increase the straight tendency of robot to operate it in higher speed. - driver (20,18,15,13);

FFSPEED, BBSPEED(left motor speed, right motor speed); Balancing the motor speed <Description> It balances speed of motors. When moving forward or backward, you decrease the speed of motor with higher RPM. In the motor Function, you achieve it by increasing the parameter value of the motor with higher RPM. <Range of parameters> ffspeed (left motor forward speed value, right motor forward speed value); bbspeed (left motor backward speed value, right motor backward speed value); 1. left motor forward speed value, left motor backward speed value: 0 ~ 255; 2. right motor forward speed value, right motor backward speed value: 0 ~ 255; - If robot sways left moving forward, you gradually increase the parameter of right motor speed - If robot sways right moving forward, you gradually increase the parameter of left motor speed - If robot sways left moving backward, you gradually increase the parameter of right motor speed - If robot sways right moving backward, you gradually increase the parameter of left motor speed Example

Ex1) If robot sways left, moving forward ffspeed(0,13); // Increase parameter of right motor speed value motor(20,20,500); // Check whether it moves straight for 0.5 second Ex2) If robot sways right, moving forward
ffspeed(21,0); // Increase parameter of left motor speed value motor(20,20,500); // Check whether it moves straight for 0.5 second

Ex3) If robot sways left moving backward bbspeed(0,18); // Increase parameter of right motor speed value motor(-20,-20,500); // Check whether it moves straight for 0.5 second Ex4) If robot sways right moving backward bbspeed(0,18); // Increase parameter of left motor speed value motor(-20,-20,500); // Check whether it moves straight for 0.5 second

GROUND(value of sensor2, value of sensor4); Sensing the pitfalls <Description> Functions as motor, line, inmotor and outmotor work with walls only. Ground function is used to make robot stop when it comes to pitfalls. When values for light amount are given to floor sensors No.2 and 4, robot stops function when its reading is lower than the given value. It applies to the functions after the Ground function. Since Ground function applies to all functions except bline, you will need to reset with ground(0,0); if you do not want to use this function. <Range of parameters> 1. Value of sensor2: 0, 1 ~ 160 2. Value of sensor4: 0, 1 ~ 160 - If 0: Not using ground function - If 1 ~ 160: Robot stops when its reading is lower than pre-set value. Example ground(0,0); Sensing pitfalls not defined. motor(20,20,1000); Run motors without setting pitfall sensing ground(120,0); Set the value of light amount for sensor2 as 120 motor(20,20,1000); Robot stops when sensor No. 2 senses pitfall. ground(120,120); Set the value of light amount for sensor 2 and 4 as 120 motor(20,20,1000); Robot stops when sensor No. 2 and 4 sense pitfall. MOTOR(left motor speed, right motor speed, run time); Running motors <Description> It is used to run the motors <Range of Parameters> 1. Left motor speed: -20 ~ 20 2. Right motor speed: -20 ~ 20 3. Run time: 0 ~ 65000 (100=0.1 sec) motor(20,20,500); // Move robot forward for 0.5 second motor(0,0,500); //Halt robot for 0.5 second motor(-20,-20,500); //Move robot backward for 0.5 second motor(0,0,500); //Halt robot for 0.5 second DELAY_MS(delay time); Delay <Description> It maintains action for the time given. <Range of Parameters> 1. Delay value: 0 ~ 65000 (100 =0.1 second)

LINE(front sensor value, wall distance value, moving direction, speed, forward run time); Basic function for sensing walls <Description> This is the most basic function which sets moving direction, speed, etc., by sensing the walls. Sensor1 and Sensor5 can sense left and right walls, respectively. You need to set run time if you want the robot to move further after the task has been completed. Front sensor value and wall distance value does NOT represent actual distance but the amount of IR ray received. The amount varies depending on the color of walls. <Range of parameters> line (front sensor value, wall distance value, moving direction, speed, forward run time); 1. front sensor value: 0, 1 ~ 160 - If 0: No wall in front - If 1 ~ 160: Higher the value, higher the amount of IR ray. If you want robot to halt near the wall, set a high value. 2. wall sensor value: 1 ~ 160 (constant), SS1, SSL, SS5, SSR (sensor value) - Using constant: Robot traces wall using the value 1 ~ 160. (Higher the value, higher the amount of IR ray.) - Using sensor: Given sensors, SS1, SSL, SS5, SSR, robot traces the wall using the initial reading of distance. (The current value of IR ray amount is stored in SS1, SSL, SS5 and SSR.) 3. Moving direction: FL, FR, LL, RR - FL: Robot follows left wall using sensor 1. The task is completed when sensorL does not sense the wall. -FR: Robot follows right wall using sensor 5. The task is completed when sensorR does not sense the wall. - LL: After completing FL action, robot turns left until the pre-set sensor1 value is met. - RR: After completing FR action, robot turns right until the pre-set sensor5 value is met. 4. Speed: 0 ~ 20 5. forward run time: 0 ~ 65000 (100=0.1sec) In case of LL or RR, forward run time has to be defined in order for the robot to clear the corner. Example

LEFT, RIGHT(moving speed); Left turn, right turn <Description> The robot spins left or right on the spot. Spinning action involves two motors rotating opposite direction in given speed. Since this function uses sensor to spin, the spinning radius can differ depending on the wall color. The spinning angle may not be consistent, <Range of parameters> 1. moving speed: 0 ~ 20 Examples:

LINEDELAY(sensor selection, wall distance sensor value, speed, moving time); Following wall for the given time <Description> Robot will follow the wall for the given time, but without considering wall distance. It is recommended to use linedelay function before using Line function, to prevent robot from going out of the way. <Range of parameters> 1. sensor selection: SENSOR1,SENSORL,SENSOR5,SENSORR 2. wall distance sensor value: 1 ~ 160 (constant), SS1, SSL, SS5, SSR (sensor value) - Using constant: Follows wall using the given constant value. (higher value, higher amount of IR ray) - Using sensor: Given sensors, SS1, SSL, SS5, SSR, robot traces the wall using the initial reading of distance. (The current value of IR ray amount is stored in SS1, SSL, SS5 and SSR.) 3. moving speed: 0 ~ 20 4. Moving time: 0 ~ 65000 (100=0.1sec) INMOTOR, OUTMOTOR(sensor selection, wall distance sensor value, left motor speed, right motor speed); Running motors using sensor <Description> This function enables you to run both motors using the pre-set value of light amount. As for inmotor, robot stops when its reading is bigger than wall distance sensor value, whereas outmotor makes robot stop when its reading is smaller than wall distance sensor value. <Range of parameters> 1. Sensor selection: sensor1, sensorL, sensor5, sensor 2. Wall distance sensor value: 1 ~ 160 - If inmotor, robot stops when sensor reading is higher than pre-set value. - If outmotor, robot stops when sensor reading is lower than pre-set value. 3. Left motor speed: -20 ~ 20 4. Right motor speed: -20 ~ 20

inmotor(SENSOR3,100,-20,20);

BLINE(value of sensor reading front, left and right, speed, motor delay after sensing); Passing bridges <Description> Your robot can go over bridges without falling, using sensors 2 and 4 (left and right). When a sensor recognize a drop, it runs opposite side motor backwards for the given delay time. When BLine function is used, your robot stops when the reading from front sensor3, left sensor1 or right sensor5 exceeds the pre-set amount of light. <Range of parameters> 1. Value of light amount from sensors front, left and right: 1 ~ 160 2. Speed: 0 ~ 20 3. Motor delay after sensing: 0 ~ 65000 (100=0.1sec) - When a sensor recognize a drop, the opposite side motor will run backwards so that the robot can safely pass the bridge. Example Bline(100,20,200); The function ceases when the reading of light amount at sensors 1, 3 or 5 exceeds 100. It will turn for about 0.2 seconds.)

BUZZER, LED(Times, On time, Off time); Turning on buzzer, led <Description> This function is used when you control buzzer or LED. You can set the number of times, On time and Off time respectively. The last Off time is disregarded. <Range of parameters> Buzzer(Times, On time, Off time); Led(Times, On time, Off time); 1. Times: 0 ~ 255 2. On time: 0 ~ 65000 (100=0.1sec) 3. Off time: 0 ~ 65000 (100=0.1sec) Example Ex1) Make buzzer sound 2 times at 1 second interval Buzzer(2,1000,1000); - On 1 second > Off 1 second > On 1 second > Finish (total 3 seconds) Buzzer(2,1000,100); - On 1 second > Off 0.1 second > On 1 second > Finish (total 2.1 seconds) Ex2) Turn on the LED 3 times at 0.5 second interval led(2,500,500); - On 0.5 second > Off 0.5 second > On 0.5 second > Off 0.5 second > On 0.5 second > Finish (total 2.5 seconds) led(2,500,100); - On 0.5 second > Off 0.1 second > On 0.5 second > Off 0.1 second > On 0.5 second > Finish (total 1.7 seconds)

BUZZERLED(use buzzer?, use LED?, Times, Interval); Turning on buzzer and LED at the same tiem <Description> The function is used when you control buzzer and LED at the same time. Operation times and interval can be set. The last Off time is disregarded. <Range of parameters> 1. Use buzzer or not: 0, 1 - 0: Not using buzzer - 1: Using buzzer 2. Use LED or not: 0, 1 - 0: Not using LED - 1: Using LED 3. Times of operation: 0 ~ 255 4. Operation interval: 0 ~ 65000 (100=0.1 sec) Ex1) Turn on buzzer and LED twice at the same time at 1 second interval. buzzerled(1,1,2,1000); On 1 second > Off 1 second > On 1 second > Finish (total 3 seconds) Ex2) Turn on buzzer only twice at 1 second interval buzzerled(1,0,2,1000); On 1 second > Off 1 second > On 1 second > Finish (total 3 seconds) Ex3) Turn on LED only twice at 1 second interval buzzerled(0,1,2,1000); On 1 second > Off 1 second > On 1 second > Finish (total 3 seconds)

SERVO(servo motor value); MOTOR1, MOTOR2 (Turning direction); Servo operation + Motor1 + Motor2 <Description> This function is to control RC servo motors. 4 ports are available for servo motors. You can operate DC motor, too, if you put DC motor driver, instead of Servo, in which case the DC motor will run at the maximum speed without speed control. <Range of parameters> Servo1(servo motor value); 01 port Servo2(servo motor value); 02 port Servo3(servo motor value); 03 port Servo4(servo motor value); 04 port 1. servo motor value: 0 ~ 100 motor1(Turning direction); 01 + 02 port motor2(Turning direction); 03 + 04 port 1. Turning direction: -1, 0, 1 - If -1: turning reverse - If 0: stop - If 1: turning Ex1) Servo1(0); Servo2(50); Motor2(1);

The servo at 01 port will stop at position 0. The servo at 02 port will stop at position 50. The motors connected to Motor Driver at port 03 and 04 will turn

IN1, IN2 Taking sensor input <Description> You can receive input from IR sensor, Contact sensor, etc. using this function. Ex1) Runnig a motor by pressing contact sensor at IN1 port while(1) { if(IN1) { motor(20,20,10); } else { motor(0,0,0); } } Ex2) Running motor when both IN1 and IN2 are pressed at the same time while(1) { if(IN1&&IN2) { motor(20,20,10); } else { motor(0,0,0); } } Ex3) Running motor when either IN1 or IN2 was pressed. while(1) { if(IN1 II IN2) { motor(20,20,10); } else { motor(0,0,0); } } Ex4) Making motor run when IN1 is not pressed and making it stop when IN1 is released while(1) { if(IN1==0) { motor(20,20,10); } else { motor(0,0,0); } }

You might also like