The Spinning Bow Tie

I created this spinning bow tie that will spins when there is someone near you using the servo and a motion sensor. The motion sensor goes at the back, while the bow tie at the front so that if there’s someone who walks up to you from behind, the bow tie will start to spin. The trouble is that the sensor is too sensitive and it picks up motion unless you’re sitting absolutely still.

Used my mug since it was tricky trying to shoot a decent selfie shot.

#include <Servo.h>

int servoPin = 9;
int sensorPin = 12;

Servo servo;
int angle = 0; // servo position in degrees

void setup() {
pinMode(sensorPin, INPUT);

void loop() {
int val = digitalRead(sensorPin);
if(val == HIGH) {
Serial.println(“I AM HIGH!”);
// scan from 0 to 180 degrees
for(angle = 0; angle < 180; angle++) {
// now scan back from 180 to 0 degrees
for(angle = 180; angle > 0; angle–) {
Serial.println(“I AM LOW!”);

Leave a Reply

Your email address will not be published.