Robot code for searching an object and charging at it.

Dependencies:   HCSR04 Motor mbed

Committer:
alex0612
Date:
Wed Oct 12 11:13:45 2016 +0000
Revision:
37:a08d2e37b7e6
Parent:
30:8a5570b2de68
Cleaned up functions names and added functions to turn and light LEDs

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abdsha01 4:0507835a3dce 1 // Header file for functions.cpp
abdsha01 4:0507835a3dce 2
alex0612 30:8a5570b2de68 3 // Speed adjustment to take into account different motor speeds
alex0612 30:8a5570b2de68 4 // Changes speed of left motor
alex0612 30:8a5570b2de68 5 #define ADJUSTMENT 0.1
alex0612 30:8a5570b2de68 6
abdsha01 20:37a89edd1cde 7 // Global parameters
alex0612 30:8a5570b2de68 8 // Speed at which it moves forward
abdsha01 20:37a89edd1cde 9 // optimum value: 0.4 to 0.8
alex0612 30:8a5570b2de68 10 extern float forwardspeed;
alex0612 30:8a5570b2de68 11 // Global parameters
alex0612 30:8a5570b2de68 12 // Speed at which it reverses
alex0612 30:8a5570b2de68 13 // optimum value: 0.4 to 0.6
alex0612 30:8a5570b2de68 14 extern float reversespeed;
abdsha01 20:37a89edd1cde 15 // Speed at which it rotates to find an object
abdsha01 20:37a89edd1cde 16 // optimum value: 0.3 to 0.5
abdsha01 20:37a89edd1cde 17 extern float searchspeed;
abdsha01 20:37a89edd1cde 18 // Range of detection
abdsha01 20:37a89edd1cde 19 // optimum value: 30 to 50
abdsha01 20:37a89edd1cde 20 extern unsigned int range;
abdsha01 20:37a89edd1cde 21
alex0612 30:8a5570b2de68 22
alex0612 30:8a5570b2de68 23
alex0612 19:67ea4e8be9e1 24 void flash_leds();
alex0612 37:a08d2e37b7e6 25 void turn_led_on(int LED);
alex0612 19:67ea4e8be9e1 26 void turn_leds_on();
abdsha01 26:5ee2a32949e6 27 void turn_led_right();
abdsha01 26:5ee2a32949e6 28 void turn_led_left();
abdsha01 4:0507835a3dce 29 int read_line1();
abdsha01 4:0507835a3dce 30 int read_line2();
abdsha01 4:0507835a3dce 31 int detect_line();
alex0612 30:8a5570b2de68 32 void move_random(float speed = forwardspeed);
alex0612 30:8a5570b2de68 33 void reverse(float speed = reversespeed, float adj = ADJUSTMENT);
alex0612 37:a08d2e37b7e6 34 void turn_left(float speed = forwardspeed);
alex0612 37:a08d2e37b7e6 35 void turn_right(float speed = forwardspeed);
alex0612 30:8a5570b2de68 36 void reverse_and_turn(float speed = reversespeed);
alex0612 37:a08d2e37b7e6 37 void forwards(float speed = forwardspeed, float adj = ADJUSTMENT);
abdsha01 4:0507835a3dce 38 void stop();
alex0612 30:8a5570b2de68 39 int detect_object(int range_t = range, float speed = searchspeed);
lhartfield 27:96a0ff2f474c 40 void move_detect(float speed, int fwd_bck, int time, int wait=0);