Skip to content

Commit 944116e

Browse files
committed
Committing the content
1 parent 34e801a commit 944116e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+157414
-1
lines changed

Diff for: HackPHx_servotest/HackPHx_servotest.pde

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <Servo.h>
2+
3+
Servo myservo;
4+
Servo myservo2;
5+
Servo myservo3;
6+
7+
const int sw1_pin = 33;
8+
int sw1_state = 0;
9+
const int sw2_pin = 34;
10+
int sw2_state = 0;
11+
const int sw3_pin = 35;
12+
int sw3_state = 0;
13+
14+
15+
16+
void setup()
17+
{
18+
myservo.attach(30);
19+
pinMode(sw1_pin, INPUT);
20+
myservo.attach(29);
21+
pinMode(sw2_pin, INPUT);
22+
myservo.attach(28);
23+
pinMode(sw3_pin, INPUT);
24+
25+
}
26+
27+
void loop()
28+
{
29+
sw1_state = digitalRead(sw1_pin);
30+
sw2_state = digitalRead(sw2_pin);
31+
sw3_state = digitalRead(sw3_pin);
32+
33+
if (sw1_state == HIGH){
34+
myservo.write(100);
35+
delay(2500);
36+
myservo.write(50);
37+
}
38+
39+
if (sw2_state == HIGH){
40+
myservo2.write(100);
41+
delay(2500);
42+
myservo3.write(50);
43+
}
44+
45+
if (sw3_state == HIGH){
46+
myservo2.write(100);
47+
delay(2500);
48+
myservo3.write(50);
49+
}
50+
51+
52+
}

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SHOT BOT
22
========
33

4-
This is the results of #hackphx arduino hack-a-thon. Thanks to the team: @rob_rich, @virgilvox, @ben
4+
This is the results of #hackphx arduino hack-a-thon. Thanks to the team: @virgilvox, @benstinnett, @rob_rich

Diff for: backsplash.cdr

8.77 KB
Binary file not shown.

Diff for: backsplash.pdf

377 KB
Binary file not shown.

Diff for: bottlecarriage.cdr

11.4 KB
Binary file not shown.

Diff for: drankshield/drankshield.ino

+251
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
//Make sure the dip switches are turned ON, and none of your shields are using pins A0,A1,A2,A3 or D4
2+
3+
#include <Shieldbot.h> //includes the Shieldbot Library
4+
#include <Servo.h>
5+
6+
Shieldbot shieldbot = Shieldbot(); //decares a Shieldbot object
7+
8+
Servo myservo;
9+
int servopin = 12;
10+
11+
int switch1pin = 11;
12+
int switch2pin = 12;
13+
int switch3pin = 13;
14+
15+
int switch1state = 0;
16+
int switch2state = 0;
17+
int switch3state = 0;
18+
19+
// Bot sensors
20+
int S1,S2,S3,S4,S5; //values to store state of sensors
21+
22+
// Bot speed controls
23+
int fwdhi = 127;
24+
int bwdhi = -128;
25+
int fwdlo = 64;
26+
int bwdlo = -64;
27+
int fwdoff = 0;
28+
29+
// servo position
30+
int pos = 0;
31+
int posMin = 0;
32+
int posMax = 180;
33+
int posSpeed = 5;
34+
35+
// wait = 0, fill-up = 1-3, deliver = 4
36+
int fillState = 0;
37+
38+
void setup(){
39+
Serial.begin(9600);//Begin serial comm for debugging
40+
shieldbot.setMaxSpeed(50,50);//255 is max, if one motor is faster than another, adjust values
41+
/*
42+
myservo.attach(servopin);
43+
myservo.write(posMin);
44+
*/
45+
pinMode(switch1pin, INPUT);
46+
pinMode(switch2pin, INPUT);
47+
pinMode(switch3pin, INPUT);
48+
49+
}
50+
51+
void loop(){
52+
/*
53+
debugloop();
54+
driveBot();
55+
*/
56+
57+
switch (fillState) {
58+
case 0:
59+
// Waiting for button push, is it pushed?
60+
getSwitches();
61+
if (switch1state == HIGH || switch2state == HIGH || switch3state == HIGH) {
62+
fillState = 1;
63+
shieldbot.drive(fwdhi,fwdhi);
64+
delay(200); // Get off of the line
65+
}
66+
break;
67+
default:
68+
// Fill or deliver
69+
driveBot();
70+
break;
71+
}
72+
73+
}
74+
75+
void debugloop() {
76+
//Read all the sensors
77+
S1 = shieldbot.readS1();
78+
S2 = shieldbot.readS2();
79+
S3 = shieldbot.readS3();
80+
S4 = shieldbot.readS4();
81+
S5 = shieldbot.readS5();
82+
83+
switch1state = digitalRead(switch1pin);
84+
switch2state = digitalRead(switch2pin);
85+
switch3state = digitalRead(switch3pin);
86+
87+
//Print the status of each sensor to the Serial console
88+
Serial.print(" S1: ");
89+
Serial.print(S1);
90+
Serial.print(" S2: ");
91+
Serial.print(S2);
92+
Serial.print(" S3: ");
93+
Serial.print(S3);
94+
Serial.print(" S4: ");
95+
Serial.print(S4);
96+
Serial.print(" S5: ");
97+
Serial.print(S5);
98+
Serial.print(" sw1 ");
99+
Serial.print(switch1state);
100+
Serial.print(" sw2 ");
101+
Serial.print(switch2state);
102+
Serial.print(" sw3 ");
103+
Serial.print(switch3state);
104+
Serial.println();
105+
/*
106+
for(pos = posMin; pos < posMax; pos += posSpeed) {
107+
analogWrite(servopin, pos);
108+
delay(15);
109+
}
110+
*/
111+
}
112+
113+
void getSwitches() {
114+
switch1state = digitalRead(switch1pin);
115+
Serial.print("sw1 ");
116+
Serial.print(switch1state);
117+
switch2state = digitalRead(switch2pin);
118+
Serial.print(" sw2 ");
119+
Serial.print(switch2state);
120+
switch3state = digitalRead(switch3pin);
121+
Serial.print(" sw3 ");
122+
Serial.print(switch3state);
123+
Serial.println();
124+
}
125+
126+
void driveBot() {
127+
128+
//Read all the sensors
129+
S1 = shieldbot.readS1();
130+
S2 = shieldbot.readS2();
131+
S3 = shieldbot.readS3();
132+
S4 = shieldbot.readS4();
133+
S5 = shieldbot.readS5();
134+
135+
//Print the status of each sensor to the Serial console
136+
Serial.print(" S1: ");
137+
Serial.print(S1);
138+
Serial.print(" S2: ");
139+
Serial.print(S2);
140+
Serial.print(" S3: ");
141+
Serial.print(S3);
142+
Serial.print(" S4: ");
143+
Serial.print(S4);
144+
Serial.print(" S5: ");
145+
Serial.print(S5);
146+
Serial.print(" sw1 ");
147+
Serial.print(switch1state);
148+
Serial.print(" sw2 ");
149+
Serial.print(switch2state);
150+
Serial.print(" sw3 ");
151+
Serial.print(switch3state);
152+
Serial.print(" ");
153+
154+
//Note about IR sensors
155+
//if a sensor sees HIGH, it means that it just sees a reflective surface background(ex. whie)
156+
//if a sensor sees LOW, it means that it sees a non-reflective surface or empty space (ex. black tape line, or empty space off ledge)
157+
158+
if (S3 == LOW && S2 == LOW && S4 == LOW && S1 == LOW && S5 == LOW) {
159+
// get drink
160+
shieldbot.stop();
161+
fillOrDeliver();
162+
} else if (S3 == LOW && S4 == LOW && S2 == LOW) {
163+
// forward slower
164+
Serial.println("forward low");
165+
shieldbot.drive(fwdlo,fwdlo);
166+
} else if (S3 == LOW && S2 == LOW) {
167+
// lean right
168+
Serial.println("lean right");
169+
shieldbot.drive(fwdhi,fwdlo);
170+
} else if (S3 == LOW && S4 == LOW) {
171+
// lean left
172+
Serial.println("lean left");
173+
shieldbot.drive(fwdlo,fwdhi);
174+
} else if (S3 == LOW) {
175+
// go foward
176+
Serial.println("forward");
177+
shieldbot.drive(fwdhi,fwdhi);
178+
} else if (S2 == LOW) {
179+
// right low
180+
Serial.println("right low");
181+
shieldbot.drive(fwdhi,fwdoff);
182+
delay(100);
183+
} else if (S4 == LOW) {
184+
// left low
185+
Serial.println("left low");
186+
shieldbot.drive(fwdoff,fwdhi);
187+
delay(100);
188+
} else if (S1 == LOW) {
189+
// right hard
190+
Serial.println("left high");
191+
shieldbot.drive(fwdhi,bwdhi);
192+
delay(100);
193+
} else if (S5 == LOW) {
194+
// left hard
195+
Serial.println("left high");
196+
shieldbot.drive(bwdhi,fwdhi);
197+
delay(100);
198+
} else {
199+
// find the line
200+
Serial.println("find the line");
201+
shieldbot.drive(fwdhi,fwdhi);
202+
}
203+
}
204+
205+
int doTheFill = 0;
206+
void shouldFill() {
207+
doTheFill = 0;
208+
if (fillState == 1) {
209+
doTheFill = switch1state;
210+
} else if (fillState == 2) {
211+
doTheFill = switch2state;
212+
} else if (fillState == 3) {
213+
doTheFill = switch3state;
214+
}
215+
}
216+
217+
void fillOrDeliver() {
218+
if (fillState < 4) {
219+
// fill
220+
fillState++;
221+
222+
shouldFill();
223+
if (doTheFill == 1) {
224+
Serial.print("fill ");
225+
Serial.println(fillState);
226+
227+
// push the fill button
228+
for(pos = posMin; pos < posMax; pos += posSpeed) {
229+
myservo.write(pos);
230+
delay(15);
231+
}
232+
delay(15);
233+
for(pos = posMax; pos>=posMin; pos-=posSpeed) {
234+
myservo.write(pos);
235+
delay(15);
236+
}
237+
delay(2500); // Wait for fill-up
238+
} else {
239+
Serial.print("no need to fill ");
240+
Serial.println(fillState);
241+
}
242+
243+
shieldbot.drive(fwdhi,fwdhi);
244+
delay(100); // Get off of the line
245+
} else {
246+
// delivered
247+
fillState = 0;
248+
Serial.println("delivered");
249+
}
250+
}
251+

Diff for: hackPHX_backplate.cdr

7.1 KB
Binary file not shown.

Diff for: hackphx_team7.cdr

400 KB
Binary file not shown.

Diff for: lasercuts/1.G00

363 KB
Binary file not shown.

0 commit comments

Comments
 (0)