Spooky Alarm - Particle Argon - Lane Tech PCL **GONE WRONG**

by smcorter in Circuits > Microcontrollers

120 Views, 1 Favorites, 0 Comments

Spooky Alarm - Particle Argon - Lane Tech PCL **GONE WRONG**

Screen Shot 2023-01-30 at 11.28.10 PM.png

Do you have trouble waking up in the morning? Do you always set your alarm and then one day it doesn't go off? Well let me introduce you to the SPOOKY ALARM!!👻😱

Instead of waking up to a pitch black room, only to hit to snooze button again, now there is a bright flashing light in your eyes. I appreciate that it doesn't make a sound so my alarm does not wake up my family. OH. And the strobe lights do not stop until you get out of bed :)

Supplies

Screen Shot 2023-01-30 at 7.51.04 PM.png
Servo-Motor-Wires.png
Screen Shot 2023-01-30 at 8.13.36 PM.png

Wires

IMG_0266.jpeg
IMG_0272.jpeg
IMG_0267.jpeg
IMG_0277.jpeg
IMG_0280.jpeg
IMG_0293.jpeg

sensorPin = D2

ledPin = D6

servo = D8

shorter side of LED connects to resistor

VUSB = + rail

3v3 = + rail

GND = - rail

middle wires on motion sensor & servo connect to + rail with VUSB

*I didn't change any settings on the sensor*

Code / Assembly Fails

IMG_0295.jpeg
Screen Shot 2023-02-27 at 9.49.53 PM.png
Screen Shot 2023-02-27 at 9.48.10 PM.png
Screen Shot 2023-02-27 at 9.51.31 PM.png
Screen Shot 2023-02-27 at 9.48.20 PM.png
Screen Shot 2023-02-27 at 9.52.13 PM.png
Screen Shot 2023-02-27 at 9.48.31 PM.png
Screen Shot 2023-02-27 at 9.53.35 PM.png
Screen Shot 2023-02-27 at 9.48.46 PM.png
  • try different angular servo movements that will get the button to turn on, making sure the fin will not fly off
  • hot glue the servo like crazy next to button
  • all those screenshots are me overthinking the sensor code
  • I looked at other projects that used the sensor and it was so much more complicated than it needed to be and consumed so much time
  • I was also having trouble getting the led to work alongside the sensor value
  • I finally asked Mr. Law for help and he fixed it right away, of course.

below is a short clip of testing the servo hitting the ON button :)

Code

Servo myServo;
int sensorPin = 2;
int ledPin = 6;
int motion = 0;

void setup() {
  pinMode(ledPin, OUTPUT);   
  pinMode(sensorPin, INPUT);
  myServo.attach(8);
Time.zone(-6); //Central Standard Time Zone
}

void loop() {
if(Time.hour() == 6 && Time.minute() == 0 && Time.second() == 0) 
{
  if (digitalRead(sensorPin) == HIGH) 
  {
    digitalWrite(ledPin, HIGH); //once motion detected, turn on led and stop servo from moving
    motion++;
    delay(1000);
    digitalWrite(ledPin, LOW); 
  }
  else
  {
    if(motion < 1) 
    {
      digitalWrite(ledPin, LOW);
      myServo.write(110); //turn strobe lights on
      delay(200);
      myServo.write(170); //turn strobe lights on
      delay(13000); //wait for light to turn back off --> different depending on strobe light
    }
  }
}
}

Finished Product

Spooky Alarm

Tips & Future Improvements

  • when testing the motion sensor, use a box so it does not detect unintentional motion (it's very sensitive)
  • unplug argon if servo starts vibrating
  • I would change code so the sensor is always looking for movement and the alarm turns off immediately
  • in the video you can see that the LED doesn't turn on right away when I am waving my hand in front of it, and that's because the sensor only checks for motion at a specific time (when the delay from the strobe light is over)