-
Notifications
You must be signed in to change notification settings - Fork 0
/
gender_revealer_3000.ino
156 lines (153 loc) · 3.85 KB
/
gender_revealer_3000.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <AFMotor.h>
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
const int buttonPin= 22;
const int ledPin1= 31;
const int ledPin2=33;
const int ledPin3= 35;
const int ledPin4= 37;
const int ledPin5 = 39;
const int ledPin6 = 41;
AF_Stepper motor(400,1);
int position = 10;
AF_Stepper motor2(64,1);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Gender Revealer 3000");
servo1.attach(9); //attach servo1 to pin 9
servo2.attach(10);
servo3.attach(28);
servo4.attach(30);
motor.setSpeed(20);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(26, OUTPUT);
}
void loop() {
int buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
servo2.write(179); //move servo2 to the outward position
servo1.write(179); //move sevor1 to the outward position
servo3.write(0);
servo4.write(179);
if (buttonState ==LOW){
Serial.print("button press");
delay(2000);
servo1.write(91);
delay(2000);
servo2.write(83);
delay(2000);
servo3.write(89);
delay(300);
digitalWrite(ledPin1, HIGH); //this series of flashing LED's could likely be reduced to repeating
delay(200);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(200);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, HIGH);
delay(200);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, HIGH);
delay(200);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, HIGH);
delay(200);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, HIGH);
delay(200);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin1, HIGH);
delay(200);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(200);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, HIGH);
delay(200);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, HIGH);
delay(200);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, HIGH);
delay(200);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, HIGH);
delay(200);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin1, HIGH);
delay(200);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(200);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, HIGH);
delay(200);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, HIGH);
delay(200);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, HIGH);
delay(200);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, HIGH);
delay(200);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin1, HIGH);
delay(200);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(200);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, HIGH);
delay(200);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, HIGH);
delay(200);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, HIGH);
delay(200);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, HIGH);
delay(200);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin1, HIGH);
delay(200);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(200);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, HIGH);
delay(200);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, HIGH);
delay(200);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, HIGH);
delay(200);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, HIGH);
delay(200);
digitalWrite(ledPin6, LOW);
motor.step(400, FORWARD, DOUBLE);
delay(10000);//remove when adding servo5
motor.step(400, BACKWARD, DOUBLE);
}
else {
motor.step(1, FORWARD, MICROSTEP);
delay(1000);
motor.step(1, BACKWARD, MICROSTEP);
servo2.write(179); //move servo2 to the outward position
servo1.write(179); //move sevor1 to the outward position
servo3.write(0);
digitalWrite(24,HIGH);
}
}