Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
wiehe_maria
Published

Blinking Smile Mask

With the flip of a switch this face mask lights up and blinks to show a smile.

BeginnerProtip181
Blinking Smile Mask

Things used in this project

Hardware components

ProtoSnap - LilyPad Development Board
SparkFun ProtoSnap - LilyPad Development Board
×1
Sewable Conductive Thread
Sewable Conductive Thread
×1
LED (generic)
LED (generic)
×1
Alligator Clips
Alligator Clips
×1

Hand tools and fabrication machines

Fabric or Mask

Story

Read more

Schematics

Blinking Mask Schematic

Code

Blinking LED Mask

Arduino
int switchPin = A9;

int switchLED = A8;

void setup()
{
  // Initialize the button and switch pins as inputs with pullups.
  // Pullups keep the inputs from "floating" when a switch or button is open / unpressed.

  pinMode(switchPin, INPUT_PULLUP);

  // Initialize the LED pins as outputs:

  pinMode(switchLED, OUTPUT);
}

void loop()
{
  // This code will read the positions of the button and switch,
  // then use the "if" command to make LEDs follow these states.

  // Create variables to store the button and switch input values:

  int switchState;

  // Read and save the states of the button and switch:

  switchState = digitalRead(switchPin);

  // The if-else statement lets you do different things based on different inputs:

  // The button will read as LOW when it's pressed


  if (switchState == LOW) // Check to see if switchState is LOW (switch is on)
  {
    digitalWrite(switchLED,HIGH); // If switchState is LOW (on), turn on the LED
     delay(1000);            // Pause for 1000 milliseconds (one second), the LED stays on
  digitalWrite(switchLED,LOW);  // Give pin A5 a LOW voltage level (off), which turns off the LED
  delay(1000);      
  }
  else
  {
    digitalWrite(switchLED,LOW); // If switchState is HIGH (off), turn off the LED
  }
}

Credits

wiehe_maria

wiehe_maria

1 project • 1 follower

Comments