From: feste Date: Sat, 7 Sep 2013 20:01:46 +0000 (-0700) Subject: Merge branch 'master' of git://gitorious.org/ozzloy/challenge-bot X-Git-Url: http://challenge-bot.com/repos/?p=challenge-bot;a=commitdiff_plain;h=e092686dfff99c65158ced79b1d7a806f73c700b;hp=664a13f8ff7970c6ef1d6efe6ec7ab2dda67a838 Merge branch 'master' of git://gitorious.org/ozzloy/challenge-bot --- diff --git a/.gitignore b/.gitignore index 2bdc956..0d8de0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,12 @@ *.html *.pdf *~ +*.jpg +*.mp4 +*.png +*.gz +*.zip +*.net +*.stl +*.gcode +*.x3g diff --git a/phase0/phase0.ino b/phase0/phase0.ino index 8a80269..523ca5f 100644 --- a/phase0/phase0.ino +++ b/phase0/phase0.ino @@ -1,5 +1,5 @@ /* - This program is free software: you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -12,12 +12,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -/* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - This example code is in the public domain. - */ int red0 = 12; int yellow0 = 11; int green0 = 10; @@ -27,9 +21,6 @@ int yellow1 = 6; int green1 = 5; void setup() { - // initialize the digital pin as an output. - // Pin 13 has an LED connected on most Arduino boards: - pinMode(red0, OUTPUT); pinMode(red1, OUTPUT); pinMode(yellow0, OUTPUT); @@ -38,53 +29,64 @@ void setup() { pinMode(green1, OUTPUT); } -void on(int led) { - digitalWrite(led, HIGH); +/* + on(pinNumber); + turn on pin 'pinNumber'. + digitalWrite(pinNumber, HIGH); turns the voltage on for that pin. + */ +void on(int pinToTurnOn) { + digitalWrite(pinToTurnOn, HIGH); } -void off(int led) { - digitalWrite(led, LOW); +/* + off(pinNumber); + turn off pin 'pinNumber'. + digitalWrite(pinNumber, LOW); turns the voltage off for that pin. +*/ +void off(int pinToTurnOff) { + digitalWrite(pinToTurnOff, LOW); } -void ons_offs(int* ons, int onsc, - int* offs, int offsc, - int delay_time) { - int ii; - for(ii = 0; ii < offsc; ii++) { - off(offs[ii]); +void onsOffs(int* pinsToTurnOn, int numberOfPinsToTurnOn, + int* pinsToTurnOff, int numberOfPinsToTurnOff){ + // generic index used for arrays of pins to turn on or off + int index; + // turn off pins in pinsToTurnOff + for(index = 0; index < numberOfPinsToTurnOff; index++) { + off(pinsToTurnOff[index]); } - for(ii = 0; ii < onsc; ii++) { - on(ons[ii]); + // turn on pins in pinsToTurnOn + for(index = 0; index < numberOfPinsToTurnOn; index++) { + on(pinsToTurnOn[index]); } - delay(delay_time); } void loop() { - int red_wait = 300; - int yellow_wait = 800; - int green_wait = 1600; + int redWait = 300; + int yellowWait = 800; + int greenWait = 1600; - ons_offs((int[]){red0, green1}, 2, - (int[]){yellow0, green0, red1, yellow1}, 4, - green_wait); + onsOffs((int[]){red0, green1}, 2, + (int[]){yellow0, green0, red1, yellow1}, 4); + delay(greenWait); - ons_offs((int[]){red0, yellow1}, 2, - (int[]){yellow0, green0, red1, green1}, 4, - yellow_wait); + onsOffs((int[]){red0, yellow1}, 2, + (int[]){yellow0, green0, red1, green1}, 4); + delay(yellowWait); - ons_offs((int[]){red0, red1}, 2, - (int[]){yellow0, green0, yellow1, green1}, 4, - red_wait); + onsOffs((int[]){red0, red1}, 2, + (int[]){yellow0, green0, yellow1, green1}, 4); + delay(redWait); - ons_offs((int[]){green0, red1}, 2, - (int[]){red0, yellow0, yellow1, green1}, 4, - green_wait); + onsOffs((int[]){green0, red1}, 2, + (int[]){red0, yellow0, yellow1, green1}, 4); + delay(greenWait); - ons_offs((int[]){yellow0, red1}, 2, - (int[]){red0, green0, yellow1, green1}, 4, - yellow_wait); + onsOffs((int[]){yellow0, red1}, 2, + (int[]){red0, green0, yellow1, green1}, 4); + delay(yellowWait); - ons_offs((int[]){red0, red1}, 2, - (int[]){yellow0, green0, yellow1, green1}, 4, - red_wait); + onsOffs((int[]){red0, red1}, 2, + (int[]){yellow0, green0, yellow1, green1}, 4); + delay(redWait); } diff --git a/phase1/phase1.ino b/phase1/phase1.ino index 642bb7f..7c18373 100644 --- a/phase1/phase1.ino +++ b/phase1/phase1.ino @@ -1,5 +1,5 @@ /* - This program is free software: you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -12,80 +12,74 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -/* - Motor. - Runs both motors back and forth. - - This example code is in the public domain. - */ -// Pin 13 has an LED connected on most Arduino boards. -// give it a name: +// use pin 13's LED to indicate intended travel direction. +// on == forward, off == backward int led = 13; -int motor1_enable = 10; -int motor1a = 9; -int motor1b = 8; -int motor2_enable = 3; -int motor2a = 4; -int motor2b = 5; + +int leftMotorEnable = 10; +int leftMotorA = 9; +int leftMotorB = 8; + +int rightMotorEnable = 3; +int rightMotorA = 4; +int rightMotorB = 5; + +void setupMotor(int motorEnable, int motorA, int motorB){ + pinMode(motorEnable, OUTPUT); + pinMode(motorA, OUTPUT); + pinMode(motorB, OUTPUT); + + digitalWrite(motorEnable, LOW); + digitalWrite(motorA, LOW); + digitalWrite(motorB, LOW); +} // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. - pinMode(led, OUTPUT); - pinMode(motor1_enable, OUTPUT); - pinMode(motor1a, OUTPUT); - pinMode(motor1b, OUTPUT); - pinMode(motor2_enable, OUTPUT); - pinMode(motor2a, OUTPUT); - pinMode(motor2b, OUTPUT); + setupMotor(leftMotorEnable, leftMotorA, leftMotorB); + setupMotor(rightMotorEnable, rightMotorA, rightMotorB); - digitalWrite(led, HIGH); - digitalWrite(motor1_enable, LOW); - digitalWrite(motor1a, LOW); - digitalWrite(motor1b, LOW); - digitalWrite(motor2_enable, LOW); - digitalWrite(motor2a, LOW); - digitalWrite(motor2b, LOW); + pinMode(led, OUTPUT); } -void motorsRun(int left, int right, int ms_delay) { +void motorsRun(int left, int right, int msDelay) { // Set left motor direction: if (left > 0) { // Set left motor to go forward: - digitalWrite(motor1a, HIGH); - digitalWrite(motor1b, LOW); + digitalWrite(leftMotorA, HIGH); + digitalWrite(leftMotorB, LOW); } else { // Set left motor to go backward: - digitalWrite(motor1a, LOW); - digitalWrite(motor1b, HIGH); + digitalWrite(leftMotorA, LOW); + digitalWrite(leftMotorB, HIGH); left = -left; // Make left a positive value: } - analogWrite(motor2_enable, left); // Start motor in right direction + analogWrite(rightMotorEnable, left); // Start motor in right direction // Set left motor direction: if (right > 0) { // Set right motor to go forward: - digitalWrite(motor2a, HIGH); - digitalWrite(motor2b, LOW); + digitalWrite(rightMotorA, HIGH); + digitalWrite(rightMotorB, LOW); } else { // Set right motor to go backward: - digitalWrite(motor2a, LOW); - digitalWrite(motor2b, HIGH); + digitalWrite(rightMotorA, LOW); + digitalWrite(rightMotorB, HIGH); right = -right; // Make right a positive value: } - analogWrite(motor1_enable, left); // Start motor in right direction + analogWrite(leftMotorEnable, left); // Start motor in right direction - delay(ms_delay); // Wait the specified amount of time + delay(msDelay); // Wait the specified amount of time // Stop both motors: - analogWrite(motor1_enable, 0); - analogWrite(motor2_enable, 0); + analogWrite(leftMotorEnable, 0); + analogWrite(rightMotorEnable, 0); } // the loop routine runs over and over again forever: void loop() { - digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) motorsRun(100, 100, 2000);// Run the robot forward digitalWrite(led, LOW); // turn the LED off by making the voltage LOW diff --git a/phase3/phase3.ino b/phase3/phase3.ino index 0d94518..5356110 100644 --- a/phase3/phase3.ino +++ b/phase3/phase3.ino @@ -15,8 +15,6 @@ // This program implements table top challenge level 1 -- // The robot stays on the table without falling off. -// This example code is in the public domain. - // Set *debug* to 1 to enable debugging statements: int debug = 1; diff --git a/schematic-3d-printable.scad b/schematic-3d-printable.scad new file mode 100644 index 0000000..ee5050d --- /dev/null +++ b/schematic-3d-printable.scad @@ -0,0 +1,72 @@ +// challenge-bot phase-2 +// GNU AGPLv3 (or later at your option) +// project available at these locations: +// https://gitorious.org/ozzloy/challenge-bot +// https://github.com/waynegramlich/challenge-bot + +// using +// https://github.com/josefprusa/Prusa3/blob/master/box_frame/x-carriage.scad +// as an example of how to code in scad + +scale=10; + +deck_z = 3/16; +deck_x = 8; +deck_y = 8; +deck_dimensions = [deck_x, deck_y, deck_z]; + +module deck(scale){ + cube(deck_dimensions * scale, center = true);} + +module collar_hole(scale){ + cylinder(h = 5/16 * scale, r = 0.362/2 * scale, $fn = 100);} + +module nubbin_hole(scale){ + cylinder(h = 5/16 * scale, r = 0.145/2 * scale, $fn = 100);} + +module mounting_screw_hole(scale){ + cylinder(h = 5/16 * scale, r = 0.114/2 * scale, $fn = 100);} + +module wheel_mount_reinforcement(scale){ + diagonal = sqrt(deck_z * deck_z + deck_z * deck_z); + difference(){ + cube([deck_z * 2, deck_z * 2, deck_z * 2] * scale); + translate([-(diagonal - deck_z) / 2, 0, 0] * scale) + rotate([45, 0, 0]) + translate([0, -(diagonal * 1.1 - deck_z) / 2, 0]) + cube([diagonal * 2, diagonal * 2 * 1.1, deck_z * 2] * scale);}} + +module wheel_mount(scale){ + difference(){ + cube([1.5, 2, 3/16] * scale); + // motor shaft collar hole + translate([0.5, 0.938, -1/16] * scale) { + collar_hole(scale);} + // nubbin hole + translate([0.5 + 0.875 - 0.425, 0.938, -1/16] * scale){ + nubbin_hole(scale);} + // mounting screw hole + translate([0.5 + 1.213 - 0.425, 0.938 - 0.687/2, -1/16] * scale){ + mounting_screw_hole(scale);} + translate([0.5 + 1.213 - 0.425, 0.938 + 0.687/2, -1/16] * scale){ + mounting_screw_hole(scale);}}} + +translate([0, 0, (3/16)/2 * scale]){ + color("blue") deck(scale); + rotate([90, 0, 0]) + translate([1.5, (deck_z)/2, -4] * scale) wheel_mount(scale); + rotate([90, 0, 0]) + translate([1.5, (deck_z)/2, 4 - deck_z] * scale) wheel_mount(scale); +} + +translate([1.5, deck_y/2 - deck_z * 3, deck_z] * scale){ + wheel_mount_reinforcement(scale);} +translate([1.5 * 2 - deck_z * 2, deck_y / 2 - deck_z * 3, deck_z] * scale){ + wheel_mount_reinforcement(scale);} + +translate([1.5 + deck_z * 2, 3 * deck_z - deck_y / 2, deck_z] * scale){ + rotate([0, 0, 180]){ + wheel_mount_reinforcement(scale);}} +translate([1.5 * 2, 3 * deck_z - deck_y / 2, deck_z] * scale){ + rotate([0, 0, 180]){ + wheel_mount_reinforcement(scale);}}