Lights and Tilt Sensors
Simple, A/C Solution
I realized that the Godzilla Bowling (formerly Godzilla Town / Hovercraft Bowling) concept would be more interesting if the boxes responded to being knocked over, so I started imagining ways of switching between two bulbs (or an alternative AC circuit that blinks). Here's one that I came up with. It uses a PVC end cap, zinc-coated bolts, and a steel ball.
It works pretty well, but each one is a ton of work to build, and getting the sizing just right is tricky. You have to be very careful to ensure that it remains lit when upright while simultaneously avoiding shorts. I've got some other ideas for tilt sensors, but so far nothing has quite been the trifecta of cheap/easy/reliable.
Moving to Digital
I really like the AC LED bulbs from Philips that Home Depot has. They're really bright, $7 a piece, and basically indestructible. Plus, the world of AC is a lot simpler for someone that's only done basic house wiring in the past 15 years. It seemed like running with AC would be cheaper than buying a ton of LED 5050 strips, power supplies, etc, but after some investigating, that doesn't seem so true. So I bit the bullet and got the basic blinking circuit working with a 555 IC.
In truth, I was first looking at this to simply control my blinking AC circuit, but then I got ambitious. What if I jumped over to an Arduino to control each box? Well here are some cool, possible advantages:
- More interesting blinking/color patterns
- Pre-built tilt sensors (now that we're using lower voltage DC)
- The possibility of reporting back state changes. Maybe they could keep score? Have a bonus box?
So I got two things working. First, I got my 5.5V Arduino Duo to control a 12V LED strip, using two power supplies. This is important because the cheaper Arduinos that I'll need are not going to be able to handle the 12V needed by the LED strips. Second, I some basic tilt switches working as input to the Arduino.
These particular switches are barrel shaped, and each box would need three of them to detect a tip in any of four directions. They are also a pain to work with--easy to overheat when soldering, difficult to properly align at appropriate angles. My current hopes are pinned on this digital four-way sensor.
Here is my Arduino wiring diagram and sketch. The resistors are 10k and the "NPN" devices are N-Channel MOSFETs. (Somehow, "NPN" seems like the wrong label for 'em, but that's what the diagramming tool (fritzing) rendered.)
// Tilt Sensor LEDs const int ledPin = 13; const int axisPinX = 2; const int axisPinY = 3; const int ledPinRed = 9; const int ledPinGreen = 10; const int ledPinBlue = 11; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(axisPinX, INPUT); pinMode(axisPinY, INPUT); pinMode(ledPinRed, OUTPUT); pinMode(ledPinGreen, OUTPUT); pinMode(ledPinBlue, OUTPUT); } int axisX = 0; int axisY = 0; void loop(){ // read the state of the pushbutton value: axisX = digitalRead(axisPinX); axisY = digitalRead(axisPinY); if (axisX == HIGH) { if (axisY == HIGH) { setColor(255, 0, 0); digitalWrite(ledPin, HIGH); } else { setColor(0, 255, 0); digitalWrite(ledPin, LOW); } } else { if (axisY == HIGH) { setColor(0, 0, 255); digitalWrite(ledPin, LOW); } else { setColor(255, 255, 0); digitalWrite(ledPin, HIGH); } } delay(100); } void setColor(int r, int g, int b) { Serial.print("("); Serial.print(axisX); Serial.print(","); Serial.print(axisY); Serial.print(") "); Serial.print(r); Serial.print(":"); Serial.print(g); Serial.print(":"); Serial.println(b); analogWrite(ledPinRed, r); analogWrite(ledPinGreen, g); analogWrite(ledPinBlue, b); }
Quick update: I just received/tried the four-way sensor. If I'd been paying a bit more attention, I would have noticed that this can't detect "no tilt". To do that I'd need two units mounted at near 90-degree angles (getting expensive).