Things used in this project

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
×1
13285 01
PIR Motion Sensor (generic)
×1
5v Stepper Motor Uln2003 Driver Board
×1
Adafruit industries ada1536 image
Buzzer
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×1
09590 01
LED (generic)
×1
08377 02 l
Resistor 330 ohm
×1

Schematics

ojGkh1cgyied4GJure2b.fzz
Stepper control
NzcXggMo28Hy3I0XZVRd.fzz

Code

BlinkPython
from gpiozero import LED
from time import sleep
led = LED(18)
while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)
Alternative BlinkPython
from gpiozero import LED
from signal import pause
red = LED(17)
red.blink()
pause()
ButtonPython
from gpiozero import Button
button = Button(2)
while True: 
    if button.is_pressed: 
        print("Button is pressed") 
    else:
        print("Button is not pressed")
Button commanding a LEDPython
from gpiozero import LED, Button
from signal import pause
led = LED(18)
button = Button(2)
button.when_pressed = led.on
button.when_released = led.off
pause()
AlarmPython
from gpiozero import MotionSensor, Buzzer, LED
import time
pir = MotionSensor(23)
bz = Buzzer(24)
led = LED(18)
print("Waiting for PIR to settle")
pir.wait_for_no_motion()
while True:
    led.off()
    print("Ready")
    pir.wait_for_motion()
    led.on()
    print("Motion detected!")
    bz.beep(0.5, 0.25, 8)
    time.sleep(3)
Stepper Motor ControlPython
import time
import sys
from gpiozero import OutputDevice as stepper
IN1 = stepper(12)
IN2 = stepper(16)
IN3 = stepper(20)
IN4 = stepper(21)
stepPins = [IN1,IN2,IN3,IN4] # Motor GPIO pins</p><p>
stepDir = -1        # Set to 1 for clockwise
                           # Set to -1 for anti-clockwise
mode = 1            # mode = 1: Low Speed ==> Higher Power
                           # mode = 0: High Speed ==> Lower Power
if mode:              # Low Speed ==> High Power
  seq = [[1,0,0,1], # Define step sequence as shown in manufacturers datasheet
             [1,0,0,0], 
             [1,1,0,0],
             [0,1,0,0],
             [0,1,1,0],
             [0,0,1,0],
             [0,0,1,1],
             [0,0,0,1]]
else:                    # High Speed ==> Low Power 
  seq = [[1,0,0,0], # Define step sequence as shown in manufacturers datasheet
             [0,1,0,0],
             [0,0,1,0],
             [0,0,0,1]]
stepCount = len(seq)
if len(sys.argv)>1: # Read wait time from command line
  waitTime = int(sys.argv[1])/float(1000)
else:
  waitTime = 0.004    # 2 miliseconds was the maximun speed got on my tests
stepCounter = 0

while True:                          # Start main loop
  for pin in range(0,4):
    xPin=stepPins[pin]          # Get GPIO
    if seq[stepCounter][pin]!=0:
      xPin.on()
    else:
      xPin.off()
  stepCounter += stepDir
  if (stepCounter >= stepCount):
    stepCounter = 0
  if (stepCounter < 0):
    stepCounter = stepCount+stepDir
  time.sleep(waitTime)     # Wait before moving on</p>

Credits

Mjrobot hiresicon 512 512 j57u7diljd
MJRoBot

Engineer, writer and forever student. Passionate to share knowledge of electronics with focus on IoT and robotics.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

NeoPixel Thermometer!
Easy
  • 90
  • 4

Full instructions

Transforms a NeoPixel ring into a cool thermometer

Electronic Voting Machine Using Arduino
Easy
  • 221
  • 5

It is an EVM using Arduino. There are five switches in all, assigned for various activities.

Smartphone Connected Home Door Lock
Easy
  • 183
  • 3

Full instructions

An internet-connected, servo-driven deadbolt actuator that can be operated remotely using a smartphone.

MyHumidity Controlled by BME280 and Photon
Easy
  • 114
  • 2

Full instructions

Checks if humidity threshold is reached and informs the user by using Blynk/IFTTT-services with softAP integration.

Secure Simple Remote Access for Camera Viewing
Easy
  • 2,603
  • 12

Full instructions

Turn your RPi into a full featured camera with remote access, end2end encryption, and easy user enrollment.

Tweeting Particle Photon
Easy
  • 25
  • 1

Full instructions

Tweet your friends with only the press of a button!

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login