Sarah Foster
Published

Halloween Decoration

Interactive spider that's eyes light up and web that plays tunes.

BeginnerFull instructions provided6 hours1,244
Halloween Decoration

Things used in this project

Hardware components

Arduino LilyPad USB
Arduino LilyPad USB
×1
LilyPad Buzzer
SparkFun LilyPad Buzzer
×1
LilyPad Button Board
SparkFun LilyPad Button Board
×1
LilyPad LED Red (5pcs)
SparkFun LilyPad LED Red (5pcs)
×1
Sewable Conductive Thread
Sewable Conductive Thread
×1
Li-Ion Battery 100mAh
Li-Ion Battery 100mAh
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor

Hand tools and fabrication machines

Needles
Scissors, Free Fall
Scissors, Free Fall

Story

Read more

Code

Halloween Decoration Code

Arduino
//LED Light
int buttonPin = A4;
int buttonLED = A5;
int touchPin = A5;
int buzzer = 11;

//Tune
int NOTE_C5 = 523;
int NOTE_CS5 = 554;
int NOTE_D5 = 587;
int NOTE_DS5 = 622;
int NOTE_E5 = 659;
int NOTE_F5 = 698;
int NOTE_FS5 = 740;
int NOTE_G5 = 784;
int NOTE_GS5 = 831;
int NOTE_A5 = 880;
int NOTE_AS5 = 932;
int NOTE_B5 = 988;
int NOTE_C6 = 1047;

int tempo = 500;

void setup()
{
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(touchPin, INPUT_PULLUP);
  pinMode(buttonLED, OUTPUT);
  pinMode(buzzer, OUTPUT);
}

void loop()
{
  int buttonState;
  int touchState;

  buttonState = digitalRead(buttonPin);
  touchState = digitalRead(touchPin);


  if (buttonState == LOW) // Check to see if buttonState is LOW (pressed) 
  {
    digitalWrite(buttonLED,HIGH); // If buttonState is LOW (pressed), turn on the LED
  }
  else
  {
    digitalWrite(buttonLED, LOW); // If buttonState is HIGH (unpressed), turn off the LED
  }

  if (touchState == LOW) // Check to see if buttonState is LOW (pressed) 
  {
    playTone();
  }
  else
  {
    noTone(buzzer);
  }
}

void playTone(){

  tone(buzzer,NOTE_C5);
  delay(tempo);

  tone(buzzer,NOTE_D5);
  delay(tempo);

  tone(buzzer,NOTE_E5);
  delay(tempo);

  tone(buzzer,NOTE_F5);
  delay(tempo);

  tone(buzzer,NOTE_G5);
  delay(tempo);

  tone(buzzer,NOTE_A5);
  delay(tempo);

  tone(buzzer,NOTE_B5);
  delay(tempo);

  tone(buzzer,NOTE_C6);
  delay(tempo);


  noTone(buzzer);
  delay(tempo * 4);
}

Credits

Sarah Foster

Sarah Foster

2 projects • 0 followers

Comments