summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-09-22 16:35:59 -0400
committerAnthony Wang2022-09-22 16:35:59 -0400
commit4c588943fc8c29b74664f23e9305fcfa5e16e200 (patch)
tree32542576ba45fa2cba568b737f823c8e53283335
parentd78c18b6a3214f43635863a0c49bb35413d83306 (diff)
Finish week3 simple simon code
-rw-r--r--week2/week2.ino (renamed from week2/main.ino)0
-rw-r--r--week3/week3.ino21
2 files changed, 21 insertions, 0 deletions
diff --git a/week2/main.ino b/week2/week2.ino
index 87f07bc..87f07bc 100644
--- a/week2/main.ino
+++ b/week2/week2.ino
diff --git a/week3/week3.ino b/week3/week3.ino
new file mode 100644
index 0000000..4051901
--- /dev/null
+++ b/week3/week3.ino
@@ -0,0 +1,21 @@
+void setup() {
+ pinMode(0, OUTPUT);
+ pinMode(1, OUTPUT);
+ analogReadResolution(8);
+}
+
+void loop() {
+ int light = random(0, 2);
+ delay(1000);
+ digitalWrite(light, HIGH);
+ delay(1000);
+ digitalWrite(light, LOW);
+ while (analogRead(A0) < 240 && analogRead(A1) < 240);
+ int correct = (analogRead(A0) < 128) ^ light;
+ for (int i = 0; i < 4; ++i) {
+ digitalWrite(correct, HIGH);
+ delay(200);
+ digitalWrite(correct, LOW);
+ delay(200);
+ }
+}