Permalink
Browse files

Add code for the new spaceduino

  • Loading branch information...
Luke Closs Luke Closs
Luke Closs authored and Luke Closs committed Sep 8, 2010
1 parent f5f47e8 commit 7c1bd1040594bce0ee37130f8cf393c6d98833c6
Showing with 63 additions and 0 deletions.
  1. +3 −0 space_displayduino/README
  2. +60 −0 space_displayduino/vhsduino.c
@@ -0,0 +1,3 @@
+This code runs on the displayduino in the ammo box at the space.
+
+Make sure you use the displayduino modified arduino IDE.
@@ -0,0 +1,60 @@
+#define rPin1 13
+#define gPin1 14
+#define bPin1 15
+#define rPin2 3
+#define gPin2 4
+#define bPin2 12
+#define rPot 2
+#define gPot 1
+#define bPot 0
+#define toilet 2
+
+int flush_idle_state;
+void setup() {
+ pinMode(rPin1, OUTPUT); analogWrite(rPin1, 0);
+ pinMode(gPin1, OUTPUT); analogWrite(gPin1, 0);
+ pinMode(bPin1, OUTPUT); analogWrite(bPin1, 0);
+ pinMode(rPin2, OUTPUT); analogWrite(rPin2, 0);
+ pinMode(gPin2, OUTPUT); analogWrite(gPin2, 0);
+ pinMode(bPin2, OUTPUT); analogWrite(bPin2, 0);
+ pinMode(toilet, INPUT);
+ flush_idle_state = digitalRead(toilet);
+}
+
+void write_west_leds (int r, int g, int b) {
+ analogWrite(rPin2, r); analogWrite(gPin2, g); analogWrite(bPin2, b);
+}
+void write_east_leds (int r, int g, int b) {
+ analogWrite(rPin1, r); analogWrite(gPin1, g); analogWrite(bPin1, b);
+}
+
+void write_both_leds (int r, int g, int b) {
+ // For now, just set it but in the future a smoothing function would be
+ // best.
+ write_west_leds(r, g, b);
+ write_east_leds(r, g, b);
+}
+
+#define white_max 100
+void soothing_flushing_motion (void) {
+ int b = 255;
+ write_both_leds(0, 0, b);
+ int east = random(white_max);
+ int west = white_max - east;
+
+ write_west_leds(west, west, b);
+ write_east_leds(east, east, b);
+}
+
+void loop() {
+ int flushing = digitalRead(toilet);
+ if (flush_idle_state != flushing) {
+ soothing_flushing_motion();
+ }
+ else {
+ write_both_leds(analogRead(rPot) / 4,
+ analogRead(bPot) / 4,
+ analogRead(gPot) / 4);
+ }
+}
+

0 comments on commit 7c1bd10

Please sign in to comment.