Crypto Countdown Case Circuit

The case's circuit consists of:

  • Inputs
    • on/off button
    • five toggle switches
  • Outputs
    • 14-segment alphanumeric LED display
    • piezo buzzer
    • NeoPixel RGB indicator LED
  • Processing
    • Feather M0 microcontroller
  • Power
    • 4400mAh Lithium Ion battery
    • USB port for charging (and programming)

This diagram shows how you'll connect things, using the Terminal Block Breakout FeatherWing for wiring.

Note: This diagram does not show the small transistor switching circuit you'll build on the prototyping area of the Terminal Block FeatherWing -- see below for more info

Switches

These toggle switches are not only really cool looking, but they are kind of fancy, too! They have some circuitry inside to allow their LEDs to light up, and can operate in one of three modes.

 

There are three connections to a switch: "GND", "+", and "=D"(also called "headlamp"). Here's how to use them with a Feather M0 (although this may be applied to other Feathers, Arduinos, or most any microcontroller):

To use a switch like a normal toggle

  • connect a wire from Feather GND pin to switch Headlamp contact
  • connect a wire from Feather Enable pin to  switch + contact
  • toggle the switch to from OFF to ON to close and open the circuit, sending the Enable pin LOW or HIGH to power the Feather off or on

 

To use a switch as a toggle, with the built-in switch LED permanently lit

  • connect Feather GND pin to switch GND contact
  • connect Feather 3v3 pin to switch Headlamp contact
  • connect a Feather input pin, such as pin 11, to switch + contact
  • toggle the switch from OFF to ON to send digital pin reading from HIGH to LOW
You will need to set the Feather pin mode to INPUT_PULLDOWN for this to work properly. This is possible on M0-based boards, for others you'll need to create a pulldown circuit with two resistors.

Here's a simple example sketch to use when testing the switch in permanently lit mode.

//Illuminated toggle switch
//permanently lit mode
//Connections:
// Feather GND to switch GND
// Feather 3v3 to switch Headlamp
// Feather pin 11 to switch +

//When switch is ON, digital pin will read LOW


const int SWITCHPIN = 11;     // the number of the toggle switch pin to read
const int LEDPIN =  13;       // the number of the LED pin (using the onboard LED)
int switchState = 0;          // variable for storing the switch state

void setup() {
  // initialize the LED pin as an output
  pinMode(LEDPIN, OUTPUT);
  // initialize the switch pin as an input_pulldown
  pinMode(SWITCHPIN, INPUT_PULLDOWN);
}

void loop() {
  // read the state of the switch value
  switchState = digitalRead(SWITCHPIN);

  // check if the switch is flipped on
  // if it is, the switchState is LOW
  if (switchState == LOW) {
    // turn LED on
    digitalWrite(LEDPIN, HIGH);
  } else { // switchState is HIGH, which is flipped to off
    // turn LED off
    digitalWrite(LEDPIN, LOW);
  }
}

To use the switch as a toggle, with the built-in switch LED going from unlit to lit as the switch is flipped from OFF to ON

  • connect Feather GND pin to switch GND contact
  • connect Feather 3v3 to switch + contact 
  • connect Feather digital pin, such as pin 11, to switch Headlamp contact
  • toggle the switch to send digital pin reading from LOW to HIGH 

Here's a simple example sketch to use when testing the switch in LED toggle mode.

//Illuminated toggle switch
//toggle LED on/off mode
//Connections:
// Feather GND to switch GND
// Feather 3v3 to switch +
// Feather pin 11 to switch Headlamp

//When switch is ON, digital pin will read HIGH


const int SWITCHPIN = 11;     // the number of the toggle switch pin to read
const int LEDPIN =  13;       // the number of the LED pin (using the onboard LED)
int switchState = 0;          // variable for storing the switch state

void setup() {
  // initialize the LED pin as an output
  pinMode(LEDPIN, OUTPUT);
  // initialize the switch pin as an input_pulldown
  pinMode(SWITCHPIN, INPUT_PULLDOWN);
}

void loop() {
  // read the state of the switch value
  switchState = digitalRead(SWITCHPIN);

  // check if the switch is flipped on
  // if it is, the switchState is HIGH
  if (switchState == HIGH) {
    // turn LED on
    digitalWrite(LEDPIN, HIGH);
  } else { // switchState is LOW, which is flipped to off
    // turn LED off
    digitalWrite(LEDPIN, LOW);
  }
}

Wire the Switches

Using four 3" lengths of black and red wires, solder the five switches together so they can share a single power and ground connection on the Feather. Solder the black wires between the switches' ground terminals and the red wires between their + terminals.

Solder a 6" length of color matched wire to each switches' headlamp terminal.

ON/OFF Circuit

On a typical project you can power the Feather on and off by connecting its En(able) pin to its GND pin through a latching switch. However, the Crypto Countdown Case is no typical project! You don't want players to be able to power it off once the countdown has begun. Transistor to the rescue.

You can use a simple transistor and two resistors switching circuit to enable and disable the power switch in software. You'll connect the transistor's collector pin to the En(able) pin on the Feather, the transistor's emitter pin to GND and the transistor's base pin to two resistors -- a 10K resistor to the switch (which in turn is connected to the Feather's VBAT pin) and a 1K resistor which is connected to an output control pin on the Feather, in this case A5 set to OUTPUT mode in software.

When everything is turned off, pressing the on/off button can open and close the Feather's En pin, thus allowing the button to power the Feather on and off. In the Arduino sketch's setup function you can command the A5 pin to go LOW immediately, which in effect disconnects the on/off button from the circuit, thwarting all cheaters who would try to turn it off! 

Later in the software, once the case has either been decoded or failed, the software sets the A5 pin back to HIGH, re-enabling the on/off button.

Place the transistor (an EBC pinout, PN2222 transistor in this case), the two resistors, and wires into the holes on the TerminalBlock breakout FeatherWing's prototyping area as shown, and solder them together on the back side. You can follow the breadboarded diagram as a guide.

To enable an easy connection between the power button and the switching circuit, solder in a 2-pin JST connector: one wire to the BAT pin solder point and the other wire to the 10K resistor.

You'll solder the other side of the JST cable to the COMMON and N.O. terminals of the latching button. 

This photo shows the switching circuit with a CBE pinout transistor, so the black and orange wires are reversed from that of the diagram

Display

Solder in the stacking headers on the Feather M0 board instead of the normal headers. This way you'll be able to plug the Feather into the Terminal Block breakout FeatherWing and the display FeatherWing can go on top of the Feather. It's a delightful Feather sandwich! (Ptoo.)

Assemble the 14-segment display shield as instructed here, then stack it onto the Feather, and the stack the Feather onto the TerminalBlock breakout FeatherWing.

Power Button Lighting

The latching power button has a built-in LED to give it its green glow. You'll run that LED from the Feather output pin 13. Solder an 8" length of red wire to the button's terminal and black wire to its GND terminal.

NeoPixel Indicator Lamp

The 5mm NeoPixel has four legs, Data In, +, GND, and Data Out. We don't need the data out capability, so you can trim that leg. Then, prepare three female jumper wires to a 3-row wire housing by pushing their crimp connectors into the housing. Trim and strip the wires on the other side, these will be pulled into the screw terminals.

Note the position of the long leg of the NeoPixel -- this is GND. Make a black mark on one wire at both ends and plug the GND leg into this space on the connector to keep track of the wiring order.

BEEEEEP

You can now connect the piezo buzzer to the screw terminals. Strip a bit of insulation from the ends of each wire on the buzzer and then screw the red wire into A0 and the black wire into a GND terminal.

Wiring

Make the remaining wiring connections as seen in the diagram. Since the on/off button will need to be threaded through the case panel later, that one will need to be disconnected and then reconnected, but for now it's good to connect everything for testing before everything is mounted.

Connect the following from component to screw terminals:

Switches

  • Switch bundle's + to 3v3
  • Switch bundle's black wire to GND
  • White switch's white wire (headlamp) to 12
  • Red switch's orange wire to 11
  • Yellow switch's yellow wire to 10
  • Green switch's green wire to 6
  • Blue switch's blue wire to 5

Power Button

  • Power button red wire to pin 13
  • Power button black wire to GND
  • Power button JST to switch transistor circuit JST

NeoPixel

  • NeoPixel GND to GND
  • NeoPixel + to 3v3
  • NeoPixel Data In to A2

This guide was first published on Jan 27, 2017. It was last updated on Mar 08, 2024.

This page (Build the Circuit) was last updated on Mar 08, 2024.

Text editor powered by tinymce.