Toggle Switch

Toggle switches were also components I had never worked with before. To start, I watched a few videos to understand how DPDT toggle switches work. I found Wiring a 3 Position On/Off/On DPDT Switch by The Joy of Electronics and How Switches Work - SPST - SPDT - DPST - DPDT - Simply Put by Simply Put on Youtube to be very informative.

After watching the videos, I realized that a toggle switch wasn’t necessary for my purposes. Initially, I wanted to switch between two modes, but I learned that I didn’t have seperate circuits and a simple pushbutton could have fulfilled the same function. Regardless, the switch interface provided stronger context for the intended function of the interaction instead of the pushbutton.

After some feedback from a fellow peer in my Computational Media class, I learned that I can’t just snap the NeoPixel stick in half to get two sets of 4. So, due to time constraints with shipping, I decided to continue with a single stick and split the color display into 2 sets of 4.

Following Toggle Switch by GeneralSpud, I wired the toggle switch to control a single LED.

IMG_8138.HEIC

IMG_8137.MOV

Toggle Switch + NeoPixel Stick

Fortunately, I was able to apply what I learned about NeoPixels from working with the NeoPixel Ring to the NeoPixel Stick.

IMG_8142.HEIC

IMG_8141.MOV

#include <Adafruit_NeoPixel.h>

const int toggleSwitch1_PIN = 7;

const int NeoStick_PIN = 6;
const int NeoStick_COUNT = 8;
Adafruit_NeoPixel stick(NeoStick_COUNT, NeoStick_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
pinMode(toggleSwitch1_PIN, INPUT);

stick.begin();
stick.setBrightness(64);
}
void loop() {
  int toggleSwitch1_STATE = digitalRead(toggleSwitch1_PIN);
  if(toggleSwitch1_STATE == HIGH) {
    stick.fill(stick.ColorHSV(0, 0, 4);
    stick.fill(stick.ColorHSV(0, 4, 4);
  }
  if (toggleSwitch1_STATE == LOW) {
    stick.fill(stick.ColorHSV((65536 * 1/2), 4, 4);
    stick.fill(stick.ColorHSV(0, 0, 4);
  }
  stick.show();
}

I started by just hard coding colors that displayed according to the toggle switch.

IMG_8143.MOV

I also tested hard coded saturation and brightness values.

void loop() {
  int toggleSwitch1_STATE = digitalRead(toggleSwitch1_PIN);
  if(toggleSwitch1_STATE == HIGH) {
    stick.fill(stick.ColorHSV(0, 20, 80), 0, 4);
    stick.fill(stick.ColorHSV(0, 4, 4);
  }
  if (toggleSwitch1_STATE == LOW) {
    stick.fill(stick.ColorHSV((65536 * 1/2), 80, 20), 4, 4);
    stick.fill(stick.ColorHSV(0, 0, 4);
  }
  stick.show();
}