Dexter Industries
Published © MIT

Raspberry Pi Servo Flag Waver

This tutorial demonstrates a fun project for waving flags to get started with PivotPi.

BeginnerFull instructions provided1 hour781
Raspberry Pi Servo Flag Waver

Things used in this project

Hardware components

Dexter Industries PivotPi
×1
Raspberry Pi
×1
4xAA Batteries
×1
Servo Motors(2 nos)
×1
Your National Flag
×1

Software apps and online services

Python
Scratch

Story

Read more

Code

Flag waver- Pyhton

Python
Flag.py
# To make the code compatible with python3
from __future__ import print_function
from __future__ import division
from builtins import input
import time
import pivotpi
try:
    pivotpi = pivotpi.PivotPi(0x40, 60) #PivotPi I2C address and PWM frequency
except:
    print("PivotPi not found - quitting")
    exit(-1)
print('Moving servos on channel 1-2, press Ctrl-C to quit...')
while True:
    for i in range (0,180,10):  # increasing the Pulse width in steps of 10 Microseconds
        for j in range(2):  # Channels 1 and 2
            pivotpi.angle(j, i)  # Setting the Servo position between 0 and 180 degrees.       
            time.sleep(0.05)

Flag waver- Scratch

Credits

Dexter Industries

Dexter Industries

32 projects • 83 followers
We think everyone should be able to build, learn, and experiment with robotics.

Comments