-
Notifications
You must be signed in to change notification settings - Fork 1
/
BubbleBot.ino
117 lines (97 loc) · 4.28 KB
/
BubbleBot.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Bubble bot code for Midsouth Makers and Artist Ghetto
// Thanks for the members insperation and helping in debugging!
#include <Servo.h> // Sevro library
// Physical Hardware
int trayButtonHigh = 0; // Button located on top of tray used
int trayButtonLow = 0; // Button locate below tray used
int ledPin = 13; // Led pin for feed back used
// Ez Driver Lines
int dirPin = 3; // Direction pin for EZ-Driver
int motionPin = 4; // Motion pin for EZ-Driver
// Software Globals
// int travel = 1; // Timer 1 Global obsolete
int timer2 = 0; // Timer 2 Global used
// int timer3 = 0; // Timer 3 Global obsolete
int dirct = 0; // Direction Global used
int pos = 140; // Position Global used
int DirButton = 0; // Dirc Button Global used
// Servro global
Servo myServo;
//set Digital Pins use
void setup() {
pinMode(2, INPUT); // High Button #2
pinMode(3, OUTPUT); // Direction Pin #3
pinMode(4, OUTPUT); // Motion Pin #4
pinMode(5, INPUT); // Low Button #5
pinMode(6, INPUT); // Low Button #6
pinMode(12, INPUT); // Spare Pin
pinMode(13, OUTPUT); // LED Pin #13
{
myServo.attach(7); // Servo pin #7
}
// open serial port for debug
Serial.begin(9600); // Open serial port
// set pins
digitalWrite(2, HIGH); // trayButtonHigh fuse set
digitalWrite(3, LOW); // Dirct set
digitalWrite(4, LOW); // Motion pin reset
digitalWrite(5, HIGH); // trayButtonLow fuse set
digitalWrite(6, HIGH); // DirButton fuse set
digitalWrite(13, LOW); // LED is turned off
}
void loop()
{
timer2 = (timer2 + 1); // Timer to jumpstart the motion ater button event
trayButtonHigh = digitalRead(2); // Check the trayButtonHigh
trayButtonLow = digitalRead(5); // Check the trayButtonLow
DirButton = digitalRead(6); // Check the DirButton
dirct = digitalRead(3); // Check the dirct
if (timer2 % 100 == 0) // Debug code - pulls ever 100th pass
{ // Debug code
Serial.print("High B = "); // Debug code
Serial.print(trayButtonHigh); // Debug code
Serial.print(" . dirct = "); // Debug code
Serial.print(dirct ); // Debug code
Serial.print(" . DirButton = "); // Debug code
Serial.print(DirButton ); // Debug code
// Debug code
} // Debug code
if (DirButton == 0) //Wrong direction reset button code
{ //
timer2 = (10001); // Advance the timer
trayButtonLow = (0); // trigger low tray return
}
if (timer2 > 1000 ) // The global that allows movement
{ // while button is down
if ( trayButtonHigh == 0) //
{
digitalWrite(3,LOW); // write direction low
while (pos < 140) // tell servo to move to 140
{
(pos = pos + 1); // move + 1
delay (100); // go slow as to not pop the bubble film
myServo.write(pos); // move the servo
}
delay(5000); // wait to blow bubble
while (pos > 100) // reset move servo to 100
{
(pos = pos - 1); // move - 1
delay (100); //go slow keep strings untangle
myServo.write(pos); // move the servo
}
timer2 = (0); // set global so we can move while
} // button is down
if ( trayButtonLow == 0) // completed drip
{
digitalWrite(3,HIGH); // change direction
delay (1000); // let the string soak 1 sec
timer2 = (0); // set global so we can move while
} // button is down
}
digitalWrite(4, HIGH); // move stepper
digitalWrite(13, HIGH); // light LED
delay(1); // delay
digitalWrite(4, LOW); // move stepper
digitalWrite(13, LOW); // dim LED
delay(1); // delay
}