Alex Wulff
Published © GPL3+

Light-Up Poker Chip

This whole circuit is the same size as a regular poker chip, but with an added surprise: lights!

IntermediateFull instructions provided2 hours5,985

Things used in this project

Hardware components

Custom fabricated PCB
OSH Park Custom fabricated PCB
Link: https://oshpark.com/projects/RmkVGeN9/
×1
Resistor 330 ohm
Resistor 330 ohm
1/8w or 1/6W should be sufficient
×5
Microchip ATtiny85 SOIC
×1
0805 SMD LED
×5
Coin Cell Battery CR2032
Coin Cell Battery CR2032
×1
CR2032 Holder
×1
SPDT Slide Switch
×1
Arduino UNO
Arduino UNO
Only needed for programming the ATtiny
×1
Capacitor 10 µF
Capacitor 10 µF
Only needed for programming the ATtiny
×1
Alligator Clips
Alligator Clips
Only needed for programming the ATtiny
×6

Software apps and online services

Autodesk circuits.io - 123D Circuits

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
tweezer
Multimeter
Must have diode mode

Story

Read more

Schematics

Circuit Schematic

Code

Demo.ino

Arduino
//Code produced by Alex Wulff: www.AlexWulff.com

//Pin definitions for Rev. 1
#define led1  0
#define led2  1
#define led3  4
#define led4  2
#define led5  3

bool enableOne = true;
bool enableTwo = false;
bool enableThree = false;
bool enableFour = false;
bool enableFive = false;
bool programmingLightMode = false;
bool lightMode = false;

bool dotMode = false;

void setup() {
  pinMode(led1, INPUT_PULLUP);
  pinMode(led2, INPUT_PULLUP);
  pinMode(led3, INPUT_PULLUP);
  pinMode(led4, INPUT_PULLUP);
  pinMode(led5, INPUT_PULLUP);
}

void loop() {

  //This means the user wants to enter programming mode
  if (digitalRead(led1) == 0 && !programmingLightMode) {
    programmingLightMode = true;
    pinMode(led1, OUTPUT);
    for (int i = 0; i < 4; i++) {
      digitalWrite(led1, HIGH);
      delay(300);
      digitalWrite(led1, LOW);
      delay(300);
    }
    pinMode(led1, INPUT_PULLUP);
  }

  //This means the user wants to enter the demo mode
  if (digitalRead(led2) == 0 && !programmingLightMode) {
    dotMode = true;
  }

  //This will check to see if any of the lighs have been selected
  if (programmingLightMode) {
    if (digitalRead(led1) == 0) {
      lightMode = true;
    }
  
    else if (digitalRead(led2) == 0) {
      enableTwo = true;
    }
  
    else if (digitalRead(led3) == 0) {
      enableThree = true;
    }
  
    else if (digitalRead(led4) == 0) {
      enableFour = true;
    }
  
    else if (digitalRead(led5) == 0) {
      enableFive = true;
    }
  }
  
  //This is displayed at the end of the programming mode
  if (lightMode) {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    pinMode(led5, OUTPUT);
    digitalWrite(led1, enableOne);
    digitalWrite(led2, enableTwo);
    digitalWrite(led3, enableThree);
    digitalWrite(led4, enableFour);
    digitalWrite(led5, enableFive);
    while(true); //Should sleep here
  }

  //If dot mode is selected or the chip has been sitting, enter demo mode
  if (dotMode || (millis() >= 10000 && !programmingLightMode)) {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    pinMode(led5, OUTPUT);

    //Do the demo forever
  	while (true) {doDotMode();}
  }
}

void doDotMode() {
	for (int i = 0; i < 5; i++) {
    switch (i) {
      case 0:
        setLow();
        digitalWrite(led1, HIGH);
        break;
      case 1:
        setLow();
        digitalWrite(led2, HIGH);
        break;
      case 2:
        setLow();
        digitalWrite(led3, HIGH);
        break;
      case 3:
        setLow();
        digitalWrite(led4, HIGH);
        break;
      case 4:
        setLow();
        digitalWrite(led5, HIGH);
        break;
    }
    delay(50);
  }

  for (int i = 4; i >= 0; i--) {
    switch (i) {
      case 0:
        setLow();
        digitalWrite(led1, HIGH);
        break;
      case 1:
        setLow();
        digitalWrite(led2, HIGH);
        break;
      case 2:
        setLow();
        digitalWrite(led3, HIGH);
        break;
      case 3:
        setLow();
        digitalWrite(led4, HIGH);
        break;
      case 4:
        setLow();
        digitalWrite(led5, HIGH);
        break;
    }
    delay(50);
  }
}

void setLow() {
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
}

Credits

Alex Wulff

Alex Wulff

12 projects • 235 followers
I'm a maker and student at Harvard. I love Arduino, embedded systems, radio, 3D printing, and iOS development. www.AlexWulff.com

Comments