Luminous Marble Pushbutton

by brabudu in Circuits > Arduino

624 Views, 3 Favorites, 0 Comments

Luminous Marble Pushbutton

video.gif

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

1.JPG
1b.JPG
  1. 16mm Glass Transparent Solid Marble
  2. Tactile Push Button Switch 6x6x3.1 mm SMD
  3. RGB LED WS2812B 5050
  4. Perforated board (single side)
  5. Right Angle Single Row Pin Header Male (5 pins)
  6. Printed parts (see attachment)

PCB Cutting and Preparation

2.JPG
3.JPG
5.JPG
  1. Cut the PCB to a square with 9x9 holes.
  2. Solder the tin in the two holes as shown in the left picture
  3. Solder the components using only those two holes, paying attention to the direction of the LED (the notch is at the top left).
  4. Once you're sure the components are centered, solder the remaining pins.
  5. Slide the connector pins so that they look like the picture on the right

Create Connections

4.JPG
bitmap.jpg
  1. Referring to the figure, insert the connector and solder it
  2. Using thin wires, create connections as shown in the figure on the right

Assembly

a1.JPG
A2.JPG
A3.JPG
A4.JPG
a6.JPG
  1. Put the marble in the box
  2. Cover it with the perforated piece (pay attention to the concavity)
  3. Put the pcb in the box
  4. Close with the bottom piece

Testing

ok.JPG
Arduino.png
  1. Connect the wires according to the diagram
  2. Add the PoluluLedStrip library to your Arduino IDE (GitHub - pololu/pololu-led-strip-arduino: Arduino library for addressable RGB LED strips from Pololu ยท GitHub)
  3. Upload the attached code
  4. 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);
}

Downloads