How to make a skull shoot lasers out of its eye sockets
Check out the video tutorial here!
Today we’re going to use the particle argon to make a quick and easy halloween decoration. We will use the particle ide and create a simple circuit that takes an input(a button) and produces an output(flashes two lights).
Since it’s Halloween we are going to mount this circuit to a foam skull. I will be using laser diodes for the lights, though you can use the code on standard LEDs if you don’t have any lasers available.
Technical Skills Covered in this tutorial:
- How to code/wire Push button input
- How to blink an LED or laser
Materials:
Technical Components:
- Particle Argon
- Wifi antenna
- Breadboard
- Male to male wires x 9
- Male to female wires x 4
- Laser Diodes that accept 3v3 x 2
- Push Button
- Battery pack
Non Technical Components
- Foam skull
- Fake blood
Steps:
Get your Argon ready to for set up
- Connect your device to power. You can use either USB power or connect it to a battery pack.
- Connect the wifi antenna so your device can connect to the internet
Wire up your light sources
- In the lower section of your breadboard, away from your Argon, insert your Laser diode.
- Use a different wire to connect the black/blue wire to the ground wire.
- Put a resistor next to the red wire.
- Connect a wire to the resistor and put the other end of the wire next to the D6 pin of your Argon.
- Repeat this process with your second laser and the D5 pin.
Program the lights to turn on when the code is flashed
- Download Particle Workbench
- Create a new app
- Above the setup function create two const ints that are equal to the pins where you wired your lights.
1. const int leftLaser = D6;
2. const int rightLaser = D5;
- Inside the setup function declare your lasers as outputs
1. pinMode(leftLaser, OUTPUT);
2. pinMode(rightLaser, OUTPUT);
- In the loop function write your lasers to high then have a delay for two seconds then write to low then delay again for two seconds
digitalWrite(leftLaser, HIGH);
digitalWrite(rightLaser, HIGH);
delay(2000);
digitalWrite(leftLaser, LOW);
digitalWrite(rightLaser, LOW);
delay(2000);
Wire up your push button
- Attach the button below the Argon, in the center of your breadboard so two pins are on one side of the breadboard and two pins are on the other side.
- Run a wire from one of your pins to the A5 pin of your argon.
- Run a wire from the positive section of your breadboard to another pin on your button.
- Lastly, run a resistor from one pin of your button to the negative port in your breadboard.
Program the push button to turn the lights on and off when pressed
- At the top of the file name your Button and say what pin it’s at.
const int redButton = A5;
-
Create an int called buttonState that will store the value of the button’s state (whether it’s being pressed or not)
int buttonState;
-
Next go to the setup function and declare the button to be an input.
pinMode (redButton, INPUT);
-
In the loop section, set buttonState equal to the status of redButton so it knows if that button is pressed.
` buttonState = digitalRead(redButton);`
- Then write an if statement that dictates different behavior for a pressed and unpressed button.
1. If the input is high that means the button has been pressed and we want our lights to blink.
if(buttonState == HIGH){
digitalWrite(leftLaser, HIGH);
digitalWrite(rightLaser, HIGH);
delay(2000);
digitalWrite(leftLaser, LOW);
digitalWrite(rightLaser, LOW);
}
- If the input is low that means the button is not being pressed and we want the lights to stay off.
else{
digitalWrite(leftLaser, LOW);
digitalWrite(rightLaser, LOW);
}
- Compile the code and flash it to your Argon.