Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Evan Rust
Published © GPL3+

Frosty the SPyman

Frosty the SPyman's a snowman on a shelf that livestreams video and moves on his own! Santa can now be 100% sure that people are being nice.

IntermediateFull instructions provided2 hours694
Frosty the SPyman

Things used in this project

Hardware components

DFRobot Raspberry Pi 3
×1
DFRobot Raspberry Pi Camera Module
×1
Servos (Tower Pro MG996R)
×1
Adafruit PCA 9685
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Thonny IDE
MJPG Streamer

Hand tools and fabrication machines

Screwdriver

Story

Read more

Schematics

Schematic

Code

Python Code

Python
from __future__ import division
import time
import subprocess
import shlex

import Adafruit_PCA9685

pwm = Adafruit_PCA9685.PCA9685()

servo_min = 150
servo_max = 550

p=subprocess.Popen(shlex.split('./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"'))

def set_servo(channel, pulse):
    pulse_length = 1000000
    pulse_length //= 60
    pulse_length //= 4096
    pulse *= 1000
    pulse //= pulse_length
    pwm.set_pwm(channel, 0, pulse)
    
pwm.set_pwm_freq(60)

try:
    while True:
        pwm.set_pwm(0,0,servo_min)
        time.sleep(30)
	      pwm.set_pwm(0,0,350)
	      time.sleep(30)
        pwm.set_pwm(0,0,servo_max)
        time.sleep(30)
except KeyboardInterrupt:
    p.terminate()

Credits

Evan Rust
122 projects • 1094 followers
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.

Comments