Perry OgletreeShawn Hill
Published

Halloween "Noisy" Skull

With Halloween just a few weeks away we thought we'd do a "talking" skull decoration. (NOTE: This project is still in progress!)

Work in progress971
Halloween "Noisy" Skull

Things used in this project

Hardware components

DigiSpark
DigiSpark
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×2
9-volt Battery Holder
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
2.25" 16 ohm Speaker
×1
Texas Instruments LM386N-4
×1

Software apps and online services

Arduino IDE
Arduino IDE
You will need to follow the instructions at http://digistump.com/wiki/digispark/tutorials/connecting to add the Digispark to the IDE..
Digispark Drivers

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Noisy Skull Fritzing Layout

Fritzing wiring layout for project.

Noisy Skull schematic for project

Schematic diagram for project.
NOTE: component values for resistors and capacitors can vary up to 20%.. The speaker decoupling cap can be anything between 200 and 1000 mfd. High voltage rated components will work fine.

Code

"Noisy Skull" ATTiny85 code... (10 OCT 2017)

Arduino
This is "a work in progress" code example. The code does not work properly at this time but will serve as a starting point for further code. As I progress on the code, I will update it here.
  // Global constants of frienly names
  const int inPIR = 3; //PIR people detector
  const int rLED = 4; //Red LED
  const int gLED = 5; //Green LED
  const int bLED = 2; //Blue LED
  const int pBright = 1; //PWM for LED brightness control
  const int pAudio = 0; //PWM for audio Fx generation

  // Global variables
  int colorLED = 0;

// the setup routine runs once when you press reset:
void setup() {                
  
  // initialize the digital pins as an input.
  pinMode(inPIR, INPUT); //PIR signal input
  randomSeed(analogRead(inPIR)); 
  
  // initialize the digital pins as an output and set state.
  pinMode(pAudio, OUTPUT); //PWM audio to low pass filter 
  pinMode(pBright, OUTPUT); //PWM "eye" brightness
  pinMode(bLED, OUTPUT); //Blue LED  
  pinMode(gLED, OUTPUT); //Green LED   
  pinMode(rLED, OUTPUT); //Red LED
  digitalWrite(pAudio,LOW); //Turn off audio

  // initialize circuits to show "it's alive!"
  digitalWrite(pBright,HIGH);
  digitalWrite(bLED,HIGH); //Turn on Blue LED
  delay(1000);
  digitalWrite(bLED,LOW); //Turn off Blue LED
  digitalWrite(rLED,HIGH); //Turn on Red LED
  delay(1000);
  digitalWrite(rLED,HIGH); //Turn off Red LED
  digitalWrite(gLED,HIGH); //Turn on Green LED
  delay(1000);
  digitalWrite(gLED, LOW);  //Turn off green LED
  digitalWrite(pBright,LOW);
}

// the loop routine runs over and over again forever:
void loop() {
  do
  {
    delay(50);
 } while (analogRead(inPIR)<600);
  makeNoise;
}

void ledRamp() {
  digitalWrite(pBright,LOW);
  for (int j = 0; j = 255; j++) {
    analogWrite(pBright, j);
    delay(20);
  }
  for (int j = 255; j = 0; j--) {
    analogWrite(pBright, j);
    delay(20);
  }
  digitalWrite(pBright,LOW);
}

void makeNoise() {
  //Blink eyes
  doEyes;
  doSound;
  delay(1000);
}

void doEyes() {
  colorLED = random(0, 6);
  digitalWrite(pBright,HIGH);
  if (colorLED = 0)
  {
    digitalWrite(rLED,HIGH); //Turn on Red LED
    digitalWrite(bLED,LOW); 
    digitalWrite(gLED,LOW);      
  }
  else if (colorLED = 1)
  {
    digitalWrite(gLED,HIGH); //Turn on Green LED 
    digitalWrite(rLED,LOW);   
    digitalWrite(bLED,LOW);  
  }
  else if (colorLED = 2)
  {
    digitalWrite(bLED,HIGH); //Turn on Blue LED
    digitalWrite(gLED,LOW); 
    digitalWrite(rLED,LOW);          
  }
  else if (colorLED = 3)
  {
    digitalWrite(rLED,HIGH);   
    digitalWrite(bLED,HIGH);  
    digitalWrite(gLED,LOW); 
  }
  else if (colorLED = 4)
  {
    digitalWrite(bLED,HIGH); 
    digitalWrite(gLED,HIGH);      
    digitalWrite(rLED,LOW);          
  }
  else if (colorLED = 5)
  {
    digitalWrite(gLED,HIGH); 
    digitalWrite(rLED,HIGH);          
    digitalWrite(bLED,LOW);  
  }
  digitalWrite(pBright,LOW);
}

void doSound() {
  for (int j = 80; j>2000; j = j+10) {
    analogWrite(pAudio, j);
    delay(10);
  }
  for (int j = 2000; j<80; j = j-10) {
    analogWrite(pAudio, j);
  }
  digitalWrite(pAudio, LOW);
}

Credits

Perry Ogletree

Perry Ogletree

0 projects • 6 followers
Retired Chief of IT
Shawn Hill

Shawn Hill

-1 projects • 1 follower
Automotive Manufacturing full time. Engineer/ PLC Controls or anything to reduce Non Value Added Work using new tech or a better way.

Comments