Luminous Marble Pushbutton
I've been thinking for a while about making a light-up board for playing Othello, Ataxx, or similar.
This is the first step.
A modular light-up button.
Supplies
- 16mm Glass Transparent Solid Marble
- Tactile Push Button Switch 6x6x3.1 mm SMD
- RGB LED WS2812B 5050
- Perforated board (single side)
- Right Angle Single Row Pin Header Male (5 pins)
- Printed parts (see attachment)
Downloads
PCB Cutting and Preparation
- Cut the PCB to a square with 9x9 holes.
- Solder the tin in the two holes as shown in the left picture
- Solder the components using only those two holes, paying attention to the direction of the LED (the notch is at the top left).
- Once you're sure the components are centered, solder the remaining pins.
- Slide the connector pins so that they look like the picture on the right
Create Connections
- Referring to the figure, insert the connector and solder it
- Using thin wires, create connections as shown in the figure on the right
Assembly
- Put the marble in the box
- Cover it with the perforated piece (pay attention to the concavity)
- Put the pcb in the box
- Close with the bottom piece
Testing
- Connect the wires according to the diagram
- Add the PoluluLedStrip library to your Arduino IDE (GitHub - pololu/pololu-led-strip-arduino: Arduino library for addressable RGB LED strips from Pololu ยท GitHub)
- Upload the attached code
- Press (and hold, if you want) the marble to change the color!
//Include the library for WS2812B
#include <PololuLedStrip.h>
// Create an led object and specify the pin it will use.
PololuLedStrip<12> led;
// Specify the pin used by the pushbutton.
#define BUTTON 11
// Initializes the buffer to hold the colors of the rainbow (3 bytes per color) .
rgb_color color[12] = {
{ 100, 0, 0 }, { 100, 50, 0 }, { 100, 100, 0 }, { 50, 100, 0 },
{ 0, 100, 0 }, { 0, 100, 50 }, { 0, 100, 100 }, { 0, 50, 100 },
{ 0, 0, 100 }, { 50, 0, 100 }, { 100, 0, 100 }, { 100, 0, 50 }
};
int n = 0;
void setup() {
// The pin used by the pushbutton will be an input and asks for the pullup resistor.
pinMode(BUTTON, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUTTON) == LOW) {
led.write(&color[n], 1);
n = (n + 1) % 12;
}
delay(100);
}