Home Introduction Contact Search Sitemap Raspberry Pi

Pi Traffic Lights
Pi Traffic Lights
Pi I2C Traffic Lights
Pi Simple Radio
Raspberry Pi bootcamp
Pi Motor Relay


Comments ?




bulletRaspberry PI Traffic Lights

  Below are the instructions to make this motor relay using the Raspberry PI. I have used a Ciseco "Slice of PI" prototyping board but any prototyping board can be used.


bulletRaspberry PI based
bulletUses low relay board from Ciseco
bulletControlled by a Python application



horizontal rule

Ciseco 5 volt relay

Relay current consumption at 5v is 73ma and can switch up to 250 volts at 10 amps.

bulletParts  List
Part Description Supplier
Raspberry PI Raspberry PI credit card computer Farnell or RS
4 Gigabyte SD card For the operating system Any computer or photographic store
Relay card 5 volt relay kit Ciseco
Ciseco prototype board "Ciseco "Slice of PI" Ciseco
DC motor Any small DC motor  
Triple A battery Holder and battery Farnell or RS
Single strand wire Various colours Any electronics shop


GPIO header Ciseco pin-out Relay board
2 5.0v 5.0v  supply
6 Gnd Ground 0 Volts
12 GP18 Relay board in signal


bulletMotor Relay Python Code - test_relay.py
# Open close relay
# Usage: test_relay.py open|close
# GPIO 18 Pin 12 - Relay
# GPIO 23 Pin 16 - Switch 1
# GPIO 24 Pin 18 - Switch 2
import shutil;
import sys;
import RPi.GPIO as GPIO
import time
import atexit

GPIO.setup(18, GPIO.OUT) # Motor relay

# Register exit routine
def finish():
    GPIO.output(18, False)


# Close the relay for two seconds
while True:
    switch1 = GPIO.input(22)
    switch2 = GPIO.input(4)
    print('Close relay')
    GPIO.output(18, True)
    print('Open relay')
    GPIO.output(18, False)

bulletRunning the Motor Relay program
  $ sudo ./test_relay.py
  To stop press Control-C




Copyright 2004 Bob Rathbone. All rights reserved