GalileoBotball revised this gist 1 month ago. Go to revision
1 file changed, 0 insertions, 0 deletions
Compiled_Code.c renamed to Test_Program.c
File renamed without changes
GalileoBotball revised this gist 2 months ago. Go to revision
16 files changed, 436 insertions, 419 deletions
Analog_Sensor.c(file created)
| @@ -0,0 +1,110 @@ | |||
| 1 | + | #include <kipr/wombat.h> | |
| 2 | + | ||
| 3 | + | // ============================================================ | |
| 4 | + | // ET SENSOR - DISTANCE | |
| 5 | + | // ============================================================ | |
| 6 | + | // Drive forward until ET sensor reads an obstacle (analog > 2900) | |
| 7 | + | void et_sensor_example() { | |
| 8 | + | while (analog(1) <= 2900) { | |
| 9 | + | motor(0, 50); | |
| 10 | + | motor(3, 50); | |
| 11 | + | } | |
| 12 | + | ao(); | |
| 13 | + | msleep(100); | |
| 14 | + | } | |
| 15 | + | ||
| 16 | + | // ============================================================ | |
| 17 | + | // IR SENSOR / TOPHAT (Large or Small) | |
| 18 | + | // ============================================================ | |
| 19 | + | ||
| 20 | + | // Find black: move forward until black detected, then back up off it | |
| 21 | + | void find_black() { | |
| 22 | + | // Move forward until black is detected | |
| 23 | + | while (analog(1) <= 1580) { | |
| 24 | + | printf("start loop move forward\n"); | |
| 25 | + | motor(0, 80); | |
| 26 | + | motor(3, 80); | |
| 27 | + | } | |
| 28 | + | // Move backward until black is no longer detected | |
| 29 | + | while (analog(1) >= 1580) { | |
| 30 | + | printf("start loop move backward\n"); | |
| 31 | + | motor(0, -80); | |
| 32 | + | motor(3, -80); | |
| 33 | + | } | |
| 34 | + | printf("start loop stops\n"); | |
| 35 | + | ao(); | |
| 36 | + | msleep(100); | |
| 37 | + | } | |
| 38 | + | ||
| 39 | + | // Follow the line (single sensor, basic) | |
| 40 | + | void follow_line_basic() { | |
| 41 | + | cmpc(0); | |
| 42 | + | while (gmpc(0) < 40000) { | |
| 43 | + | if (analog(1) < 3500) { | |
| 44 | + | motor(0, 80); | |
| 45 | + | motor(3, 5); | |
| 46 | + | } else { | |
| 47 | + | motor(0, 5); | |
| 48 | + | motor(3, 80); | |
| 49 | + | } | |
| 50 | + | } | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | // Follow the line (single sensor, race speed with correction) | |
| 54 | + | void follow_line_race() { | |
| 55 | + | printf("follow the line 23.95\n"); | |
| 56 | + | int right = 0; | |
| 57 | + | int left = 0; | |
| 58 | + | cmpc(0); | |
| 59 | + | while (gmpc(0) < 20000) { | |
| 60 | + | if (analog(0) > 3750) { | |
| 61 | + | motor(0, 25 - right); | |
| 62 | + | motor(3, 100); | |
| 63 | + | msleep(1); | |
| 64 | + | right = right + 1; | |
| 65 | + | left = left - 1; | |
| 66 | + | msleep(1); | |
| 67 | + | } | |
| 68 | + | if (analog(0) < 3750) { | |
| 69 | + | motor(3, 25 - left); | |
| 70 | + | motor(0, 100); | |
| 71 | + | msleep(1); | |
| 72 | + | left = left + 1; | |
| 73 | + | right = right - 1; | |
| 74 | + | msleep(1); | |
| 75 | + | } | |
| 76 | + | printf("left %d and right %d\n", left, right); | |
| 77 | + | } | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | // Follow the line (two sensors, with lever sensor stop) | |
| 81 | + | void follow_line_two_sensors() { | |
| 82 | + | int difference = 2000; | |
| 83 | + | while (digital(0) == 0) { // while lever sensor is not pressed | |
| 84 | + | if (analog(1) <= difference && analog(0) <= difference) { | |
| 85 | + | // Both sensors on white: go forward | |
| 86 | + | motor(0, 50); | |
| 87 | + | motor(3, 50); | |
| 88 | + | msleep(25); | |
| 89 | + | printf("1\n"); | |
| 90 | + | } else if (analog(1) <= difference) { | |
| 91 | + | // Sensor 1 on white: turn right | |
| 92 | + | motor(0, -10); | |
| 93 | + | motor(3, 50); | |
| 94 | + | msleep(25); | |
| 95 | + | printf("2\n"); | |
| 96 | + | } else if (analog(0) <= difference) { | |
| 97 | + | // Sensor 0 on white: turn left | |
| 98 | + | motor(0, 50); | |
| 99 | + | motor(3, -10); | |
| 100 | + | msleep(25); | |
| 101 | + | printf("3\n"); | |
| 102 | + | } else { | |
| 103 | + | // Both sensors on black: go forward | |
| 104 | + | motor(0, 100); | |
| 105 | + | motor(3, 100); | |
| 106 | + | msleep(25); | |
| 107 | + | printf("4\n"); | |
| 108 | + | } | |
| 109 | + | } | |
| 110 | + | } | |
Arm.c(file created)
| @@ -0,0 +1,56 @@ | |||
| 1 | + | #include <kipr/wombat.h> | |
| 2 | + | ||
| 3 | + | // ============================================================ | |
| 4 | + | // ENABLE / DISABLE SERVOS | |
| 5 | + | // ============================================================ | |
| 6 | + | void turn_arm_on() { | |
| 7 | + | enable_servos(); | |
| 8 | + | } | |
| 9 | + | ||
| 10 | + | void turn_arm_off() { | |
| 11 | + | disable_servos(); | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | // ============================================================ | |
| 15 | + | // SET START POSITION | |
| 16 | + | // ============================================================ | |
| 17 | + | void set_start_position() { | |
| 18 | + | set_servo_position(0, 734); | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | // ============================================================ | |
| 22 | + | // ARM ROTATION | |
| 23 | + | // ============================================================ | |
| 24 | + | void rotate_up() { | |
| 25 | + | set_servo_position(0, 724); | |
| 26 | + | msleep(1000); | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | void rotate_down() { | |
| 30 | + | set_servo_position(0, 1824); | |
| 31 | + | msleep(1000); | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | // ============================================================ | |
| 35 | + | // CLAW | |
| 36 | + | // ============================================================ | |
| 37 | + | void claw_open() { | |
| 38 | + | set_servo_position(3, 724); | |
| 39 | + | msleep(1000); | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | void claw_close() { | |
| 43 | + | set_servo_position(3, 1933); | |
| 44 | + | msleep(1000); | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | // ============================================================ | |
| 48 | + | // HELPER: RUN SERVO TO POSITION | |
| 49 | + | // ============================================================ | |
| 50 | + | // Moves servo on 'port' to 'position', then stops all motors | |
| 51 | + | void RunStart(int port, int position) { | |
| 52 | + | enable_servos(); | |
| 53 | + | set_servo_position(port, position); | |
| 54 | + | ao(); | |
| 55 | + | msleep(100); | |
| 56 | + | } | |
Botball Code Library(Drive).csv (file deleted)
| @@ -1,44 +0,0 @@ | |||
| 1 | - | Drive,, | |
| 2 | - | Task,Code,Notes | |
| 3 | - | ,, | |
| 4 | - | Pause,"// pause | |
| 5 | - | ao(); | |
| 6 | - | msleep(2000);", | |
| 7 | - | ,, | |
| 8 | - | Forward,"// forward | |
| 9 | - | motor (0,100); | |
| 10 | - | motor (3,100); | |
| 11 | - | msleep (250);","//if using MAV | |
| 12 | - | void Move(int l_power,int r_power,int time) | |
| 13 | - | {mav(0,l_power); | |
| 14 | - | mav(3,r_power); | |
| 15 | - | msleep(time); | |
| 16 | - | ao(); | |
| 17 | - | sleep(100); }" | |
| 18 | - | ,, | |
| 19 | - | Backward,"// backward | |
| 20 | - | motor (0,-100); | |
| 21 | - | motor (3,-100); | |
| 22 | - | msleep (250);", | |
| 23 | - | ,, | |
| 24 | - | Turn 90 Degrees Right,"// 90 degree turn right | |
| 25 | - | motor(0,0); | |
| 26 | - | motor(3,100); | |
| 27 | - | msleep (1500);", | |
| 28 | - | ,, | |
| 29 | - | Turn 90 Degrees Left,"// 90 degree turn Left | |
| 30 | - | motor(0,100); | |
| 31 | - | motor(3,0); | |
| 32 | - | msleep (1500);", | |
| 33 | - | ,, | |
| 34 | - | Motor Position Counter,"// motor position counter | |
| 35 | - | clear_motor_position_counter(3); | |
| 36 | - | while (get_motor_position_counter(3) < 4000) | |
| 37 | - | { | |
| 38 | - | motor(3,50); | |
| 39 | - | motor (0,50); | |
| 40 | - | } | |
| 41 | - | ao();","Counts ""ticks""-complete wheel rotation | |
| 42 | - | Your motors have approximately 1820 ticks per revolution" | |
| 43 | - | ,, | |
| 44 | - | ,, | |
Botball Code Library.xlsx (file deleted)
Binary file changes are not shown
Camera.c(file created)
| @@ -0,0 +1,9 @@ | |||
| 1 | + | #include <kipr/wombat.h> | |
| 2 | + | ||
| 3 | + | // ============================================================ | |
| 4 | + | // CAMERA - FIND OBJECTS | |
| 5 | + | // ============================================================ | |
| 6 | + | // No code has been added here yet. | |
| 7 | + | // | |
| 8 | + | // Reference: KIPR Camera Curriculum | |
| 9 | + | // https://www.kipr.org/wombat-curriculum/camera | |
Compiled_Code.c(file created)
| @@ -0,0 +1,38 @@ | |||
| 1 | + | // Test program: verifies all motors and servos are functioning. | |
| 2 | + | // Run this on the robot before competition to check hardware. | |
| 3 | + | ||
| 4 | + | #include <kipr/wombat.h> | |
| 5 | + | ||
| 6 | + | void test_servo(int port) { | |
| 7 | + | printf("testing servo %d\n", port); | |
| 8 | + | printf("\tup 2 seconds\n"); | |
| 9 | + | enable_servo(port); | |
| 10 | + | enable_servos(); | |
| 11 | + | set_servo_position(port, 0); | |
| 12 | + | msleep(2000); | |
| 13 | + | set_servo_position(port, 2047); | |
| 14 | + | msleep(2000); | |
| 15 | + | disable_servo(port); | |
| 16 | + | disable_servos(); | |
| 17 | + | } | |
| 18 | + | ||
| 19 | + | void test_motor(int port) { | |
| 20 | + | printf("testing motor %d\n", port); | |
| 21 | + | printf("\tforward 2 seconds\n"); | |
| 22 | + | motor(port, 100); | |
| 23 | + | msleep(2000); | |
| 24 | + | printf("\tbackward 2 seconds\n"); | |
| 25 | + | motor(port, -100); | |
| 26 | + | msleep(2000); | |
| 27 | + | ao(); | |
| 28 | + | } | |
| 29 | + | ||
| 30 | + | int main() { | |
| 31 | + | test_motor(0); | |
| 32 | + | test_motor(1); | |
| 33 | + | test_motor(2); | |
| 34 | + | test_motor(3); | |
| 35 | + | test_servo(0); | |
| 36 | + | test_servo(1); | |
| 37 | + | return 0; | |
| 38 | + | } | |
Digital_Sensor.c(file created)
| @@ -0,0 +1,44 @@ | |||
| 1 | + | #include <kipr/wombat.h> | |
| 2 | + | ||
| 3 | + | // ============================================================ | |
| 4 | + | // TOUCH SENSOR (Lever, Small Touch, Large Touch) | |
| 5 | + | // ============================================================ | |
| 6 | + | // Drive forward until touch sensor 0 is pressed, | |
| 7 | + | // then drive backward until touch sensor 1 is pressed | |
| 8 | + | void touch_sensor_example() { | |
| 9 | + | while (digital(0) == 0) { | |
| 10 | + | motor(0, 100); | |
| 11 | + | motor(3, 100); | |
| 12 | + | } | |
| 13 | + | ao(); | |
| 14 | + | msleep(1000); | |
| 15 | + | ||
| 16 | + | while (digital(1) == 0) { | |
| 17 | + | motor(0, -100); | |
| 18 | + | motor(3, -100); | |
| 19 | + | } | |
| 20 | + | ao(); | |
| 21 | + | msleep(1000); | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | // ============================================================ | |
| 25 | + | // WAIT FOR LIGHT | |
| 26 | + | // ============================================================ | |
| 27 | + | void wait_for_light_example() { | |
| 28 | + | wait_for_light(0); | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | // Wait for light with button confirmation | |
| 32 | + | void wait_for_light_with_button() { | |
| 33 | + | if (push_button() == 1) { | |
| 34 | + | wait_for_light(0); | |
| 35 | + | } | |
| 36 | + | } | |
| 37 | + | ||
| 38 | + | // ============================================================ | |
| 39 | + | // SHUT DOWN | |
| 40 | + | // ============================================================ | |
| 41 | + | // Shuts down all motors after 119 seconds (just under 2 minutes) | |
| 42 | + | void shutdown_example() { | |
| 43 | + | shut_down_in(119); | |
| 44 | + | } | |
Drive.c
| @@ -1,43 +1,69 @@ | |||
| 1 | - | // pause | |
| 1 | + | #include <kipr/wombat.h> | |
| 2 | + | ||
| 3 | + | // ============================================================ | |
| 4 | + | // PAUSE | |
| 5 | + | // ============================================================ | |
| 6 | + | // Stop all motors and wait 2 seconds | |
| 7 | + | void pause_example() { | |
| 2 | 8 | ao(); | |
| 3 | - | msleep(2000);" | |
| 9 | + | msleep(2000); | |
| 10 | + | } | |
| 4 | 11 | ||
| 12 | + | // ============================================================ | |
| 13 | + | // FORWARD | |
| 14 | + | // ============================================================ | |
| 15 | + | void forward_example() { | |
| 16 | + | motor(0, 100); | |
| 17 | + | motor(3, 100); | |
| 18 | + | msleep(250); | |
| 19 | + | } | |
| 5 | 20 | ||
| 6 | - | // forward | |
| 7 | - | motor (0,100); | |
| 8 | - | motor (3,100); | |
| 9 | - | msleep (250);" | |
| 21 | + | // Forward using MAV (Motor Absolute Velocity) | |
| 22 | + | void Move(int l_power, int r_power, int time) { | |
| 23 | + | mav(0, l_power); | |
| 24 | + | mav(3, r_power); | |
| 25 | + | msleep(time); | |
| 26 | + | ao(); | |
| 27 | + | sleep(100); | |
| 28 | + | } | |
| 10 | 29 | ||
| 30 | + | // ============================================================ | |
| 31 | + | // BACKWARD | |
| 32 | + | // ============================================================ | |
| 33 | + | void backward_example() { | |
| 34 | + | motor(0, -100); | |
| 35 | + | motor(3, -100); | |
| 36 | + | msleep(250); | |
| 37 | + | } | |
| 11 | 38 | ||
| 12 | - | // 90 degree turn right | |
| 13 | - | motor(0,0); | |
| 14 | - | motor(3,100); | |
| 15 | - | msleep (1500);" | |
| 39 | + | // ============================================================ | |
| 40 | + | // TURN 90 DEGREES RIGHT | |
| 41 | + | // ============================================================ | |
| 42 | + | void turn_right_90() { | |
| 43 | + | motor(0, 0); | |
| 44 | + | motor(3, 100); | |
| 45 | + | msleep(1500); | |
| 46 | + | } | |
| 16 | 47 | ||
| 48 | + | // ============================================================ | |
| 49 | + | // TURN 90 DEGREES LEFT | |
| 50 | + | // ============================================================ | |
| 51 | + | void turn_left_90() { | |
| 52 | + | motor(0, 100); | |
| 53 | + | motor(3, 0); | |
| 54 | + | msleep(1500); | |
| 55 | + | } | |
| 17 | 56 | ||
| 18 | - | // 90 degree turn Left | |
| 19 | - | motor(0,100); | |
| 20 | - | motor(3,0); | |
| 21 | - | msleep (1500); | |
| 22 | - | ||
| 23 | - | ||
| 24 | - | /*Counts "ticks"-complete wheel rotation | |
| 25 | - | Your motors have approximately 1820 ticks per revolution | |
| 26 | - | */ | |
| 27 | - | // motor position counter | |
| 28 | - | clear_motor_position_counter(3); | |
| 29 | - | while (get_motor_position_counter(3) < 4000) | |
| 30 | - | { | |
| 31 | - | motor(3,50); | |
| 32 | - | motor (0,50); | |
| 57 | + | // ============================================================ | |
| 58 | + | // MOTOR POSITION COUNTER | |
| 59 | + | // ============================================================ | |
| 60 | + | // Counts "ticks" - one complete wheel rotation | |
| 61 | + | // Motors have approximately 1820 ticks per revolution | |
| 62 | + | void motor_position_counter_example() { | |
| 63 | + | clear_motor_position_counter(3); | |
| 64 | + | while (get_motor_position_counter(3) < 4000) { | |
| 65 | + | motor(3, 50); | |
| 66 | + | motor(0, 50); | |
| 33 | 67 | } | |
| 34 | 68 | ao(); | |
| 35 | - | ||
| 36 | - | ||
| 37 | - | //if using MAV | |
| 38 | - | void Move(int l_power,int r_power,int time) | |
| 39 | - | {mav(0,l_power); | |
| 40 | - | mav(3,r_power); | |
| 41 | - | msleep(time); | |
| 42 | - | ao(); | |
| 43 | - | sleep(100); } | |
| 69 | + | } | |
Mecanum_Drive.c(file created)
| @@ -0,0 +1,119 @@ | |||
| 1 | + | #include <kipr/wombat.h> | |
| 2 | + | ||
| 3 | + | // ============================================================ | |
| 4 | + | // BACKWARD | |
| 5 | + | // ============================================================ | |
| 6 | + | void backward() { | |
| 7 | + | motor(0, -100); | |
| 8 | + | motor(1, -100); | |
| 9 | + | motor(2, -100); | |
| 10 | + | motor(3, -100); | |
| 11 | + | msleep(3000); | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | // ============================================================ | |
| 15 | + | // FORWARD | |
| 16 | + | // ============================================================ | |
| 17 | + | void forward() { | |
| 18 | + | motor(1, 100); | |
| 19 | + | motor(2, 100); | |
| 20 | + | motor(3, 100); | |
| 21 | + | msleep(3000); | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | // ============================================================ | |
| 25 | + | // LEFT DIAGONAL | |
| 26 | + | // ============================================================ | |
| 27 | + | // ⚠️ NOTE: This function is named turn_left_90 but implements | |
| 28 | + | // a LEFT DIAGONAL movement, not a 90-degree turn. Rename before | |
| 29 | + | // using in competition code. | |
| 30 | + | void turn_left_90_LEFT_DIAGONAL() { | |
| 31 | + | cmpc(1); | |
| 32 | + | while (gmpc(1) < 1350) { | |
| 33 | + | motor(0, 0); | |
| 34 | + | motor(1, 100); | |
| 35 | + | motor(2, 0); | |
| 36 | + | motor(3, 100); | |
| 37 | + | } | |
| 38 | + | ao(); | |
| 39 | + | } | |
| 40 | + | ||
| 41 | + | // ============================================================ | |
| 42 | + | // LEFT SIDEWAYS | |
| 43 | + | // ============================================================ | |
| 44 | + | // ⚠️ NOTE: This function is named turn_left_90 but implements | |
| 45 | + | // a LEFT SIDEWAYS (strafe) movement. Rename before using in | |
| 46 | + | // competition code. | |
| 47 | + | void turn_left_90_LEFT_SIDEWAYS() { | |
| 48 | + | cmpc(0); | |
| 49 | + | while (gmpc(0) < 1350) { | |
| 50 | + | motor(0, 100); | |
| 51 | + | motor(1, -100); | |
| 52 | + | motor(2, 100); | |
| 53 | + | motor(3, -100); | |
| 54 | + | } | |
| 55 | + | ao(); | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | // ============================================================ | |
| 59 | + | // RIGHT DIAGONAL | |
| 60 | + | // ============================================================ | |
| 61 | + | // ⚠️ NOTE: This function is named turn_left_90 but implements | |
| 62 | + | // a RIGHT DIAGONAL movement. Rename before using in competition | |
| 63 | + | // code. | |
| 64 | + | void turn_left_90_RIGHT_DIAGONAL() { | |
| 65 | + | cmpc(0); | |
| 66 | + | while (gmpc(0) < 1350) { | |
| 67 | + | motor(0, 100); | |
| 68 | + | motor(1, 0); | |
| 69 | + | motor(2, 100); | |
| 70 | + | motor(3, 0); | |
| 71 | + | } | |
| 72 | + | ao(); | |
| 73 | + | } | |
| 74 | + | ||
| 75 | + | // ============================================================ | |
| 76 | + | // RIGHT SIDEWAYS | |
| 77 | + | // ============================================================ | |
| 78 | + | // ⚠️ NOTE: This function is named turn_left_90 but implements | |
| 79 | + | // a RIGHT SIDEWAYS (strafe) movement. Rename before using in | |
| 80 | + | // competition code. | |
| 81 | + | void turn_left_90_RIGHT_SIDEWAYS() { | |
| 82 | + | cmpc(0); | |
| 83 | + | while (gmpc(0) < 1350) { | |
| 84 | + | motor(0, -100); | |
| 85 | + | motor(1, 100); | |
| 86 | + | motor(2, -100); | |
| 87 | + | motor(3, 100); | |
| 88 | + | } | |
| 89 | + | ao(); | |
| 90 | + | } | |
| 91 | + | ||
| 92 | + | // ============================================================ | |
| 93 | + | // MOTOR POSITION COUNTER (FORWARD WITH MPC) | |
| 94 | + | // ============================================================ | |
| 95 | + | // ⚠️ NOTE: This snippet has structural issues — the forward() | |
| 96 | + | // function is defined inside turn_left_90() and the code is | |
| 97 | + | // missing closing braces. Needs a full rewrite before use. | |
| 98 | + | // Preserved here as-is for reference only. | |
| 99 | + | /* | |
| 100 | + | void turn_left_90_MPC_BROKEN() { | |
| 101 | + | cmpc(0); | |
| 102 | + | while (gmpc(0) < 1350) { | |
| 103 | + | motor(0, 100); | |
| 104 | + | motor(1, -100); | |
| 105 | + | motor(2, 100); | |
| 106 | + | motor(3, -100); | |
| 107 | + | ao(); | |
| 108 | + | } | |
| 109 | + | void forward() { // <-- function defined inside function: NOT valid C | |
| 110 | + | cmpc(0); | |
| 111 | + | while (gmpc(0) < 2000) { | |
| 112 | + | motor(0, 100); | |
| 113 | + | motor(1, 100); | |
| 114 | + | motor(2, 100); | |
| 115 | + | motor(3, 100); | |
| 116 | + | msleep(3000); | |
| 117 | + | ao(); | |
| 118 | + | // missing closing braces | |
| 119 | + | */ | |
Untitled spreadsheet - Analog Sensor.csv (file deleted)
| @@ -1,99 +0,0 @@ | |||
| 1 | - | Analog Sensor,,,, | |
| 2 | - | Task,Code,,Notes, | |
| 3 | - | ,,,, | |
| 4 | - | ET,"//measure distance | |
| 5 | - | while (analog (1)<=2900) | |
| 6 | - | { | |
| 7 | - | motor(0,50); | |
| 8 | - | motor(3,50); | |
| 9 | - | } | |
| 10 | - | //pause | |
| 11 | - | ao(); | |
| 12 | - | msleep(100);",,, | |
| 13 | - | ,,,, | |
| 14 | - | "IR Sensor: | |
| 15 | - | Large/ | |
| 16 | - | Small Tophat","//Find Black | |
| 17 | - | //move forward until black is detected | |
| 18 | - | while (analog(1)<=1580)//stop on black | |
| 19 | - | { | |
| 20 | - | printf(""start loop move forawrd\n""); | |
| 21 | - | motor (0,80); | |
| 22 | - | motor (3,80); | |
| 23 | - | } | |
| 24 | - | //move bakward until black is no longer deteted | |
| 25 | - | while (analog (1)>=1580)//stop on black | |
| 26 | - | ||
| 27 | - | { | |
| 28 | - | printf(""start loop move backward\n""); | |
| 29 | - | motor(0,-80); | |
| 30 | - | motor(3,-80); | |
| 31 | - | } | |
| 32 | - | ||
| 33 | - | printf(""start loop stops\n""); | |
| 34 | - | ||
| 35 | - | //pause | |
| 36 | - | ao(); | |
| 37 | - | msleep(100); ","//follow the line | |
| 38 | - | cmpc(0); | |
| 39 | - | while (gmpc(0) < 40000){ | |
| 40 | - | if (analog(1)<3500){ | |
| 41 | - | motor (0,80); | |
| 42 | - | motor (3,5); | |
| 43 | - | } | |
| 44 | - | else{ | |
| 45 | - | motor (0,5); | |
| 46 | - | motor (3,80);} | |
| 47 | - | } | |
| 48 | - | return 0; | |
| 49 | - | }","//Follow the line Race | |
| 50 | - | #include <kipr/wombat.h> #define black 3750 int main() | |
| 51 | - | { printf(""follow the line 23.95\n""); | |
| 52 | - | int right = 0; | |
| 53 | - | //3 biger then one int left = 0; | |
| 54 | - | cmpc(0); | |
| 55 | - | while (gmpc(0) < 20000) { if (analog(0) > black) { motor (0,25 - right); | |
| 56 | - | motor (3,100); | |
| 57 | - | msleep(1); | |
| 58 | - | right = right + 1; | |
| 59 | - | left = left - 1; | |
| 60 | - | msleep(1); | |
| 61 | - | } if (analog(0) < black) { motor(3,25 - left); motor (0,100); | |
| 62 | - | msleep(1); | |
| 63 | - | left = left + 1; | |
| 64 | - | right = right - 1; | |
| 65 | - | msleep(1); | |
| 66 | - | } printf(""left %d and right %d\n"",left, right); | |
| 67 | - | } | |
| 68 | - | return 0; | |
| 69 | - | }","//Follow the line with 2 sensors | |
| 70 | - | #include <kipr/wombat.h> int main() { int difference=2000; | |
| 71 | - | while(digital(0)==0) { //while lever sensor is not pressed | |
| 72 | - | if (analog(1)<=difference && analog(0)<=difference){ //if both tophat sensors are on white go forwards | |
| 73 | - | motor(0,50); | |
| 74 | - | motor(3,50); | |
| 75 | - | msleep(25); | |
| 76 | - | printf(""1\n""); | |
| 77 | - | } | |
| 78 | - | else if (analog(1)<=difference) { //if tophat sensor 1 is on white, turn right motor(0,-10); | |
| 79 | - | motor(3,50); | |
| 80 | - | msleep(25); | |
| 81 | - | printf(""2\n""); | |
| 82 | - | } | |
| 83 | - | else if (analog(0)<=difference) { //if tophat sensor 0 is on white, turn left motor(0,50); | |
| 84 | - | motor(3,-10); | |
| 85 | - | msleep(25); | |
| 86 | - | printf(""3\n""); | |
| 87 | - | } | |
| 88 | - | else{ //if both sensors are on black go forwards | |
| 89 | - | motor(0,100); | |
| 90 | - | motor(3,100); | |
| 91 | - | msleep(25); | |
| 92 | - | printf(""4\n""); | |
| 93 | - | } | |
| 94 | - | } | |
| 95 | - | return 0; }" | |
| 96 | - | ,,,, | |
| 97 | - | ,,,, | |
| 98 | - | ,,,, | |
| 99 | - | Linear Slide,,,, | |
GalileoBotball revised this gist 2 months ago. Go to revision
7 files changed, 341 insertions
Untitled spreadsheet - Analog Sensor.csv (file created)
| @@ -0,0 +1,99 @@ | |||
| 1 | + | Analog Sensor,,,, | |
| 2 | + | Task,Code,,Notes, | |
| 3 | + | ,,,, | |
| 4 | + | ET,"//measure distance | |
| 5 | + | while (analog (1)<=2900) | |
| 6 | + | { | |
| 7 | + | motor(0,50); | |
| 8 | + | motor(3,50); | |
| 9 | + | } | |
| 10 | + | //pause | |
| 11 | + | ao(); | |
| 12 | + | msleep(100);",,, | |
| 13 | + | ,,,, | |
| 14 | + | "IR Sensor: | |
| 15 | + | Large/ | |
| 16 | + | Small Tophat","//Find Black | |
| 17 | + | //move forward until black is detected | |
| 18 | + | while (analog(1)<=1580)//stop on black | |
| 19 | + | { | |
| 20 | + | printf(""start loop move forawrd\n""); | |
| 21 | + | motor (0,80); | |
| 22 | + | motor (3,80); | |
| 23 | + | } | |
| 24 | + | //move bakward until black is no longer deteted | |
| 25 | + | while (analog (1)>=1580)//stop on black | |
| 26 | + | ||
| 27 | + | { | |
| 28 | + | printf(""start loop move backward\n""); | |
| 29 | + | motor(0,-80); | |
| 30 | + | motor(3,-80); | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | printf(""start loop stops\n""); | |
| 34 | + | ||
| 35 | + | //pause | |
| 36 | + | ao(); | |
| 37 | + | msleep(100); ","//follow the line | |
| 38 | + | cmpc(0); | |
| 39 | + | while (gmpc(0) < 40000){ | |
| 40 | + | if (analog(1)<3500){ | |
| 41 | + | motor (0,80); | |
| 42 | + | motor (3,5); | |
| 43 | + | } | |
| 44 | + | else{ | |
| 45 | + | motor (0,5); | |
| 46 | + | motor (3,80);} | |
| 47 | + | } | |
| 48 | + | return 0; | |
| 49 | + | }","//Follow the line Race | |
| 50 | + | #include <kipr/wombat.h> #define black 3750 int main() | |
| 51 | + | { printf(""follow the line 23.95\n""); | |
| 52 | + | int right = 0; | |
| 53 | + | //3 biger then one int left = 0; | |
| 54 | + | cmpc(0); | |
| 55 | + | while (gmpc(0) < 20000) { if (analog(0) > black) { motor (0,25 - right); | |
| 56 | + | motor (3,100); | |
| 57 | + | msleep(1); | |
| 58 | + | right = right + 1; | |
| 59 | + | left = left - 1; | |
| 60 | + | msleep(1); | |
| 61 | + | } if (analog(0) < black) { motor(3,25 - left); motor (0,100); | |
| 62 | + | msleep(1); | |
| 63 | + | left = left + 1; | |
| 64 | + | right = right - 1; | |
| 65 | + | msleep(1); | |
| 66 | + | } printf(""left %d and right %d\n"",left, right); | |
| 67 | + | } | |
| 68 | + | return 0; | |
| 69 | + | }","//Follow the line with 2 sensors | |
| 70 | + | #include <kipr/wombat.h> int main() { int difference=2000; | |
| 71 | + | while(digital(0)==0) { //while lever sensor is not pressed | |
| 72 | + | if (analog(1)<=difference && analog(0)<=difference){ //if both tophat sensors are on white go forwards | |
| 73 | + | motor(0,50); | |
| 74 | + | motor(3,50); | |
| 75 | + | msleep(25); | |
| 76 | + | printf(""1\n""); | |
| 77 | + | } | |
| 78 | + | else if (analog(1)<=difference) { //if tophat sensor 1 is on white, turn right motor(0,-10); | |
| 79 | + | motor(3,50); | |
| 80 | + | msleep(25); | |
| 81 | + | printf(""2\n""); | |
| 82 | + | } | |
| 83 | + | else if (analog(0)<=difference) { //if tophat sensor 0 is on white, turn left motor(0,50); | |
| 84 | + | motor(3,-10); | |
| 85 | + | msleep(25); | |
| 86 | + | printf(""3\n""); | |
| 87 | + | } | |
| 88 | + | else{ //if both sensors are on black go forwards | |
| 89 | + | motor(0,100); | |
| 90 | + | motor(3,100); | |
| 91 | + | msleep(25); | |
| 92 | + | printf(""4\n""); | |
| 93 | + | } | |
| 94 | + | } | |
| 95 | + | return 0; }" | |
| 96 | + | ,,,, | |
| 97 | + | ,,,, | |
| 98 | + | ,,,, | |
| 99 | + | Linear Slide,,,, | |
Untitled spreadsheet - Arm.csv (file created)
| @@ -0,0 +1,31 @@ | |||
| 1 | + | Arm,, | |
| 2 | + | Task,Code,Notes | |
| 3 | + | ,, | |
| 4 | + | Turn Arm On,enable_servos();, | |
| 5 | + | ,, | |
| 6 | + | Turn Arm Off,disable_servos();, | |
| 7 | + | ,, | |
| 8 | + | Set Start Position,"set_servo_position(0,734);", | |
| 9 | + | ,, | |
| 10 | + | Rotate Up,"//up | |
| 11 | + | set_servo_position(0,724); | |
| 12 | + | msleep(1000);", | |
| 13 | + | ,, | |
| 14 | + | Rotate Down,"//down | |
| 15 | + | set_servo_position(0,1824); | |
| 16 | + | msleep(1000);", | |
| 17 | + | ,, | |
| 18 | + | Claw Open ,"//open | |
| 19 | + | set_servo_position(3,724); | |
| 20 | + | msleep(1000);", | |
| 21 | + | ,, | |
| 22 | + | Claw Closed,"//close | |
| 23 | + | set_servo_position(3,1933); | |
| 24 | + | msleep(1000);", | |
| 25 | + | ,, | |
| 26 | + | Servos Movement,"void RunStart(int port,int sleep) | |
| 27 | + | { | |
| 28 | + | enable_servos(); set_servo_position(port,sleep); | |
| 29 | + | ao(); | |
| 30 | + | msleep(100); | |
| 31 | + | }", | |
Untitled spreadsheet - Camera.csv (file created)
| @@ -0,0 +1,13 @@ | |||
| 1 | + | Camera,, | |
| 2 | + | Task,Code,Notes | |
| 3 | + | Find Objects,, | |
| 4 | + | ,, | |
| 5 | + | ,, | |
| 6 | + | ,, | |
| 7 | + | ,, | |
| 8 | + | ,, | |
| 9 | + | ,, | |
| 10 | + | ,, | |
| 11 | + | ,, | |
| 12 | + | ,,"KIP Camera Curriculum Link | |
| 13 | + | https://www.kipr.org/wombat-curriculum/camera " | |
Untitled spreadsheet - Compiled Code.csv (file created)
| @@ -0,0 +1,3 @@ | |||
| 1 | + | "//Code to test if all on bot is working | |
| 2 | + | ||
| 3 | + | #include <kipr/wombat.h> void test_servo(port) { printf(""testing servo%d\n"",port); printf(""\tup 2 seconds\n""); enable_servo(port); enable_servos(); set_servo_position(port,0); msleep(2000); set_servo_position(port,2047); msleep(2000); disable_servo(port); disable_servos(); } void test_motor(port) { printf(""testing motor%d\n"",port); printf(""\tforward 2 seconds\n""); motor(port,100); msleep(2000); printf(""\tbackwords 2 seconds\n""); motor(port,-100); msleep(2000); ao(); } int main() { test_motor(0); test_motor(1); test_motor(2); test_motor(3); test_servo(0); test_servo(1); return 0; }" | |
Untitled spreadsheet - Digital Sensor.csv (file created)
| @@ -0,0 +1,27 @@ | |||
| 1 | + | Digital Sensor,, | |
| 2 | + | Task,Code,Notes | |
| 3 | + | ,, | |
| 4 | + | "Touch Sensor: | |
| 5 | + | -Lever | |
| 6 | + | -Small Touch | |
| 7 | + | -Large Touch"," //Touch Sensor | |
| 8 | + | while (digital (0)==0) | |
| 9 | + | { | |
| 10 | + | motor (0,100); | |
| 11 | + | motor (3,100); | |
| 12 | + | } | |
| 13 | + | ao(); | |
| 14 | + | msleep(1000); | |
| 15 | + | ||
| 16 | + | while (digital(1)==0) | |
| 17 | + | { | |
| 18 | + | motor (0,-100); | |
| 19 | + | motor (3,-100); | |
| 20 | + | } | |
| 21 | + | ao(); | |
| 22 | + | msleep(1000);",buttons | |
| 23 | + | wait for light code,"//wait for light | |
| 24 | + | wait_for_light (0);","//wait for light with button | |
| 25 | + | if(push_button() ==1 {wait_for_light (0);}" | |
| 26 | + | shut down,"// Shuts down all motors after 119 seconds (just less than 2 minutes). | |
| 27 | + | shut_down_in(119);", | |
Untitled spreadsheet - Drive.csv (file created)
| @@ -0,0 +1,42 @@ | |||
| 1 | + | Drive,, | |
| 2 | + | Task,Code,Notes | |
| 3 | + | ,, | |
| 4 | + | Pause,"// pause | |
| 5 | + | ao(); | |
| 6 | + | msleep(2000);", | |
| 7 | + | ,, | |
| 8 | + | Forward,"// forward | |
| 9 | + | motor (0,100); | |
| 10 | + | motor (3,100); | |
| 11 | + | msleep (250);","//if using MAV | |
| 12 | + | void Move(int l_power,int r_power,int time) | |
| 13 | + | {mav(0,l_power); | |
| 14 | + | mav(3,r_power); | |
| 15 | + | msleep(time); | |
| 16 | + | ao(); | |
| 17 | + | sleep(100); }" | |
| 18 | + | ,, | |
| 19 | + | Backward,"// backward | |
| 20 | + | motor (0,-100); | |
| 21 | + | motor (3,-100); | |
| 22 | + | msleep (250);", | |
| 23 | + | ,, | |
| 24 | + | Turn 90 Degrees Right,"// 90 degree turn right | |
| 25 | + | motor(0,0); | |
| 26 | + | motor(3,100); | |
| 27 | + | msleep (1500);", | |
| 28 | + | ,, | |
| 29 | + | Turn 90 Degrees Left,"// 90 degree turn Left | |
| 30 | + | motor(0,100); | |
| 31 | + | motor(3,0); | |
| 32 | + | msleep (1500);", | |
| 33 | + | ,, | |
| 34 | + | Motor Position Counter,"// motor position counter | |
| 35 | + | clear_motor_position_counter(3); | |
| 36 | + | while (get_motor_position_counter(3) < 4000) | |
| 37 | + | { | |
| 38 | + | motor(3,50); | |
| 39 | + | motor (0,50); | |
| 40 | + | } | |
| 41 | + | ao();","Counts ""ticks""-complete wheel rotation | |
| 42 | + | Your motors have approximately 1820 ticks per revolution" | |
Untitled spreadsheet - Mecanum Drive.csv (file created)
| @@ -0,0 +1,126 @@ | |||
| 1 | + | backwards,"//backward | |
| 2 | + | motor(0,-100); | |
| 3 | + | motor(1,-100); | |
| 4 | + | motor(2,-100); | |
| 5 | + | motor(3,-100); | |
| 6 | + | msleep(3000); | |
| 7 | + | " | |
| 8 | + | , | |
| 9 | + | forwards,"//forward | |
| 10 | + | motor(1,100); | |
| 11 | + | motor(2,100); | |
| 12 | + | motor(3,100); | |
| 13 | + | msleep(3000); | |
| 14 | + | " | |
| 15 | + | , | |
| 16 | + | left diagonal,"//left diagonal | |
| 17 | + | void turn_left_90(); | |
| 18 | + | ||
| 19 | + | int main() | |
| 20 | + | { | |
| 21 | + | turn_left_90(); | |
| 22 | + | return 0; | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | void turn_left_90() | |
| 26 | + | { | |
| 27 | + | cmpc(1); | |
| 28 | + | while (gmpc(1)< 1350) | |
| 29 | + | { | |
| 30 | + | motor(0,0); | |
| 31 | + | motor(1,100); | |
| 32 | + | motor(2,0); | |
| 33 | + | motor(3,100); | |
| 34 | + | } | |
| 35 | + | ao(); | |
| 36 | + | }" | |
| 37 | + | , | |
| 38 | + | left sideways,"//left sideways | |
| 39 | + | int main() | |
| 40 | + | { | |
| 41 | + | turn_left_90(); | |
| 42 | + | return 0; | |
| 43 | + | } | |
| 44 | + | ||
| 45 | + | void turn_left_90() | |
| 46 | + | { | |
| 47 | + | cmpc(0); | |
| 48 | + | while (gmpc(0)< 1350) | |
| 49 | + | { | |
| 50 | + | motor(0,100); | |
| 51 | + | motor(1,-100); | |
| 52 | + | motor(2,100); | |
| 53 | + | motor(3,-100); | |
| 54 | + | } | |
| 55 | + | ao(); | |
| 56 | + | }" | |
| 57 | + | , | |
| 58 | + | right diagonal,"//right diagonal | |
| 59 | + | int main() | |
| 60 | + | { | |
| 61 | + | turn_left_90(); | |
| 62 | + | return 0; | |
| 63 | + | } | |
| 64 | + | ||
| 65 | + | void turn_left_90() | |
| 66 | + | { | |
| 67 | + | cmpc(0); | |
| 68 | + | while (gmpc(0)< 1350) | |
| 69 | + | { | |
| 70 | + | motor(0,100); | |
| 71 | + | motor(1,0); | |
| 72 | + | motor(2,100); | |
| 73 | + | motor(3,0); | |
| 74 | + | } | |
| 75 | + | ao(); | |
| 76 | + | }" | |
| 77 | + | , | |
| 78 | + | right sideways,"//right sideways | |
| 79 | + | int main() | |
| 80 | + | { | |
| 81 | + | turn_left_90(); | |
| 82 | + | return 0; | |
| 83 | + | } | |
| 84 | + | ||
| 85 | + | void turn_left_90() | |
| 86 | + | { | |
| 87 | + | cmpc(0); | |
| 88 | + | while (gmpc(0)< 1350) | |
| 89 | + | { | |
| 90 | + | motor(0,-100); | |
| 91 | + | motor(1,100); | |
| 92 | + | motor(2,-100); | |
| 93 | + | motor(3,100); | |
| 94 | + | } | |
| 95 | + | ao(); | |
| 96 | + | }" | |
| 97 | + | , | |
| 98 | + | Motor Position Counter (maybe),"int main() | |
| 99 | + | { | |
| 100 | + | turn_left_90(); | |
| 101 | + | return 0; | |
| 102 | + | //mpc | |
| 103 | + | } | |
| 104 | + | ||
| 105 | + | void turn_left_90() | |
| 106 | + | { | |
| 107 | + | cmpc(0); | |
| 108 | + | while (gmpc(0)< 1350) | |
| 109 | + | { | |
| 110 | + | motor(0,100); | |
| 111 | + | motor(1,-100); | |
| 112 | + | motor(2,100); | |
| 113 | + | motor(3,-100); | |
| 114 | + | ao(); | |
| 115 | + | } | |
| 116 | + | void forward() | |
| 117 | + | { | |
| 118 | + | cmpc (0); | |
| 119 | + | while (gmpc(0)<2000) | |
| 120 | + | { | |
| 121 | + | motor(0,100); | |
| 122 | + | motor(1,100); | |
| 123 | + | motor(2,100); | |
| 124 | + | motor(3,100); | |
| 125 | + | msleep(3000); | |
| 126 | + | ao();" | |
GalileoBotball revised this gist 2 months ago. Go to revision
2 files changed, 16 insertions, 16 deletions
Botball Code Library(Drive).csv
| @@ -1,10 +1,10 @@ | |||
| 1 | - | Drive,, | |
| 2 | - | Task,Code,Notes | |
| 3 | - | ,, | |
| 1 | + | Drive,, | |
| 2 | + | Task,Code,Notes | |
| 3 | + | ,, | |
| 4 | 4 | Pause,"// pause | |
| 5 | 5 | ao(); | |
| 6 | - | msleep(2000);", | |
| 7 | - | ,, | |
| 6 | + | msleep(2000);", | |
| 7 | + | ,, | |
| 8 | 8 | Forward,"// forward | |
| 9 | 9 | motor (0,100); | |
| 10 | 10 | motor (3,100); | |
| @@ -14,23 +14,23 @@ void Move(int l_power,int r_power,int time) | |||
| 14 | 14 | mav(3,r_power); | |
| 15 | 15 | msleep(time); | |
| 16 | 16 | ao(); | |
| 17 | - | sleep(100); }" | |
| 18 | - | ,, | |
| 17 | + | sleep(100); }" | |
| 18 | + | ,, | |
| 19 | 19 | Backward,"// backward | |
| 20 | 20 | motor (0,-100); | |
| 21 | 21 | motor (3,-100); | |
| 22 | - | msleep (250);", | |
| 23 | - | ,, | |
| 22 | + | msleep (250);", | |
| 23 | + | ,, | |
| 24 | 24 | Turn 90 Degrees Right,"// 90 degree turn right | |
| 25 | 25 | motor(0,0); | |
| 26 | 26 | motor(3,100); | |
| 27 | - | msleep (1500);", | |
| 28 | - | ,, | |
| 27 | + | msleep (1500);", | |
| 28 | + | ,, | |
| 29 | 29 | Turn 90 Degrees Left,"// 90 degree turn Left | |
| 30 | 30 | motor(0,100); | |
| 31 | 31 | motor(3,0); | |
| 32 | - | msleep (1500);", | |
| 33 | - | ,, | |
| 32 | + | msleep (1500);", | |
| 33 | + | ,, | |
| 34 | 34 | Motor Position Counter,"// motor position counter | |
| 35 | 35 | clear_motor_position_counter(3); | |
| 36 | 36 | while (get_motor_position_counter(3) < 4000) | |
| @@ -39,6 +39,6 @@ Motor Position Counter,"// motor position counter | |||
| 39 | 39 | motor (0,50); | |
| 40 | 40 | } | |
| 41 | 41 | ao();","Counts ""ticks""-complete wheel rotation | |
| 42 | - | Your motors have approximately 1820 ticks per revolution" | |
| 43 | - | ,, | |
| 44 | - | ,, | |
| 42 | + | Your motors have approximately 1820 ticks per revolution" | |
| 43 | + | ,, | |
| 44 | + | ,, | |
Botball Code Library.xlsx(file created)
Binary file changes are not shown
GalileoBotball revised this gist 2 months ago. Go to revision
1 file changed, 44 insertions
Botball Code Library(Drive).csv (file created)
| @@ -0,0 +1,44 @@ | |||
| 1 | + | Drive,, | |
| 2 | + | Task,Code,Notes | |
| 3 | + | ,, | |
| 4 | + | Pause,"// pause | |
| 5 | + | ao(); | |
| 6 | + | msleep(2000);", | |
| 7 | + | ,, | |
| 8 | + | Forward,"// forward | |
| 9 | + | motor (0,100); | |
| 10 | + | motor (3,100); | |
| 11 | + | msleep (250);","//if using MAV | |
| 12 | + | void Move(int l_power,int r_power,int time) | |
| 13 | + | {mav(0,l_power); | |
| 14 | + | mav(3,r_power); | |
| 15 | + | msleep(time); | |
| 16 | + | ao(); | |
| 17 | + | sleep(100); }" | |
| 18 | + | ,, | |
| 19 | + | Backward,"// backward | |
| 20 | + | motor (0,-100); | |
| 21 | + | motor (3,-100); | |
| 22 | + | msleep (250);", | |
| 23 | + | ,, | |
| 24 | + | Turn 90 Degrees Right,"// 90 degree turn right | |
| 25 | + | motor(0,0); | |
| 26 | + | motor(3,100); | |
| 27 | + | msleep (1500);", | |
| 28 | + | ,, | |
| 29 | + | Turn 90 Degrees Left,"// 90 degree turn Left | |
| 30 | + | motor(0,100); | |
| 31 | + | motor(3,0); | |
| 32 | + | msleep (1500);", | |
| 33 | + | ,, | |
| 34 | + | Motor Position Counter,"// motor position counter | |
| 35 | + | clear_motor_position_counter(3); | |
| 36 | + | while (get_motor_position_counter(3) < 4000) | |
| 37 | + | { | |
| 38 | + | motor(3,50); | |
| 39 | + | motor (0,50); | |
| 40 | + | } | |
| 41 | + | ao();","Counts ""ticks""-complete wheel rotation | |
| 42 | + | Your motors have approximately 1820 ticks per revolution" | |
| 43 | + | ,, | |
| 44 | + | ,, | |
GalileoBotball revised this gist 2 months ago. Go to revision
1 file changed, 43 insertions
Drive.c(file created)
| @@ -0,0 +1,43 @@ | |||
| 1 | + | // pause | |
| 2 | + | ao(); | |
| 3 | + | msleep(2000);" | |
| 4 | + | ||
| 5 | + | ||
| 6 | + | // forward | |
| 7 | + | motor (0,100); | |
| 8 | + | motor (3,100); | |
| 9 | + | msleep (250);" | |
| 10 | + | ||
| 11 | + | ||
| 12 | + | // 90 degree turn right | |
| 13 | + | motor(0,0); | |
| 14 | + | motor(3,100); | |
| 15 | + | msleep (1500);" | |
| 16 | + | ||
| 17 | + | ||
| 18 | + | // 90 degree turn Left | |
| 19 | + | motor(0,100); | |
| 20 | + | motor(3,0); | |
| 21 | + | msleep (1500); | |
| 22 | + | ||
| 23 | + | ||
| 24 | + | /*Counts "ticks"-complete wheel rotation | |
| 25 | + | Your motors have approximately 1820 ticks per revolution | |
| 26 | + | */ | |
| 27 | + | // motor position counter | |
| 28 | + | clear_motor_position_counter(3); | |
| 29 | + | while (get_motor_position_counter(3) < 4000) | |
| 30 | + | { | |
| 31 | + | motor(3,50); | |
| 32 | + | motor (0,50); | |
| 33 | + | } | |
| 34 | + | ao(); | |
| 35 | + | ||
| 36 | + | ||
| 37 | + | //if using MAV | |
| 38 | + | void Move(int l_power,int r_power,int time) | |
| 39 | + | {mav(0,l_power); | |
| 40 | + | mav(3,r_power); | |
| 41 | + | msleep(time); | |
| 42 | + | ao(); | |
| 43 | + | sleep(100); } | |