You are on page 1of 46

Computer Engineering

Interfacing Activity
The Traffic Light Project

ACSE
Nov 13 2004
Graham Smyth
Jerry Dolata
Computer Engineering Units

Grade 10/11/12
1. Hardware
2. Networking
3. Integrated Circuits
4. Programming
5. Interfaces
Interfacing System
Unit 5

Computer Interface Peripheral


• Parallelport • Resistors
• LED's
• Relays
• or Sealed Beams
• Power Supply
• or Real World
• Breadboard
• etc

Wires Wires
Introduction to Traffic Lights
Interfacing Activities
Interfacing Activities
Breadboard Connections

Connected

High
Fives

Low Divider
Fives

Connected
Parallelport

Input Output
I0 – I3 13 12 11 10 9 8 7 6 5 4 3 2 1
D0 – D7

25 24 23 22 21 20 19 18 17 16 15 14

Grounds Input I4
18 - 25
View from back of Computer
Traffic Light Software

Turing
• parallelput(number) - reads 8 pins
• put parallelget - reads 5 pins
• mousewhere(x,y,click)
• play(“CDEFG”)
• drawline(x1,y1,x2,y2,red)
• Provincially Licenced
parallelput(number)

Number D7 D6 D5 D4 D3 D2 D1 D0
parallelput(4) 0 0 0 0 0 1 0 0
parallelput(5) 0 0 0 0 0 1 0 1
parallelput(255) 1 1 1 1 1 1 1 1
Traffic Light Hardware

• Four male pins • 1 2”x4”x9” (base)


• One D sub connector • 1 1”x2”x9” (backing)
• Cable • 1 5/8”x12” dowel
• Breadboard • Screws
• 3 sealed beams • 2 clamps for dowel
• 3 pig tails • 12VDC Power Supply
• 3 mounting Brackets • extra wire
• 3 PN2222A transistors
Stop Light Brackets
1”x4” Mounting
Board
Align Brackets
Evenly Space
Two Screws
Rat Tail

Snap Rat Tail into Light


Rat Tail and Lights
Insert Rat Tail into Hole

Shorter End of Board

Then Rotate Light ¼ turn Clockwise to Tighten


Repeat for All 3 Lights
Stop Light Wiring
Wrap Red Wire
to Red Light

Wrap Yellow
Wire to Yellow
Light
Add White Wire
to EACH of the
THREE White Wrap Green Wire
Wires to Green Light
Wrap ALL Connections with Electrical Tape
Cable Construction
Male Pin Connections

Insulated Wire Male Pin

Small Crimp Tab


Stripped Wire
Large Crimp Tab
Cable With Male Pins
(3 pair colour scheme)

White/Green
Green/White

Orange/White

White/Orange

Blue/White
change
White/Blue
D sub and Cable Colour Codes

Pin Light Wire Colour


2 Red Orange/White
3 Yellow Blue/White
4 Green Green/White
18 Ground White/Orange
The D Sub Connector
(with extraction wire)
The D Sub Connector

Pin 2
D sub
Connector

Pin 18
D Sub Connector Wiring

White/Orange (Pin18)
Green/White (Pin4)

Blue/White (Pin3)
Orange/White (Pin2)
PN2222A Transistor

Flat Side Front

Emitter Collector
(Ground) (Remote)
Base
(Trigger)
Breadboard with Transistors
Black/White (+)

Transistors (3)
Flat Front

Black (-)
Transistors with Grounds
(left pin)
Jumper

3 Transistors Grounded
Breadboard to Lights
To Red Light To Green Light

To Yellow Light
Jumper
Cable to Transistors (middle pin)

To Pin 2 To Pin 18
To Pin 4
To Pin 3
Lights to Transistors
(right pin – ground)
Ground to Ground to Ground to
Red Light Yellow Light Green Light
The hardware is complete.

Now to the software


Stop Light Question 1

Write a program that will output a traditional


stop light pattern.
Stop Light Activation Answer 1
Version 1

parallelput (1) % Red light


delay (500)
parallelput (2) % Yellow light
delay (500)
parallelput (4) % Green light
delay (500)
Stop Light Activation Answer 1
Version 2

for counter : 0 .. 2 % three lights


parallelput (2 ** counter) % clever expon.
delay (500)
end for % three lights
Stop Light Question 2

Write a program that will output a


traditional stop light pattern including
an advanced green.
Stop Light Software Answer 2
Advanced Green

Insert at appropriate place

for counter : 1 .. 5
parallelput (4) % Green light on
delay (300)
parallelput (0) % Green light off
delay (300)
end for
Stop Light Question 3

Write a program that will add a virtual


stop light that will activate with the real
world light.
Adding Graphics Screen
(640,400)

(0,0)
Virtual Traffic Lights
% Outline of traffic box
drawfillbox (100, 60, 250, 370, gray)
% Red light
drawfilloval (175, 315, 35, 35, red)
% Yellow light
drawfilloval (175, 225, 35, 35, 92)
% Green light
drawfilloval (175, 135, 35, 35, green)
Real and Virtual Traffic Lights
RED

delay (2000)
loop
% Red light
parallelput (1)
drawfilloval (175, 315, 35, 35, brightred)
drawfilloval (175, 225, 35, 35, 92)
drawfilloval (175, 135, 35, 35, green)
delay (2000)
Real and Virtual Traffic Lights
YELLOW

% Yellow light
parallelput (2)
drawfilloval (175, 315, 35, 35, red)
drawfilloval (175, 225, 35, 35, yellow)
drawfilloval (175, 135, 35, 35, green)
delay (2000)
Real and Virtual Traffic Lights
GREEN

% Green light
parallelput (4)
drawfilloval (175, 315, 35, 35, red)
drawfilloval (175, 225, 35, 35, 92)
drawfilloval (175, 135, 35, 35, brightgreen)
delay (2000)
end loop
Stop Light Question 4

Write a program that will continuously


flash all lights to indicate a power outage.
Stop Light Question 5

Write a program that will add a second


traffic light to simulate an intersection.
Stop Light Question 6

Write a program that will output a


traditional stop light pattern to real world
traffic lights.
Stop Light Software Answer 6

The software for DC LED traffic lights


and the real world AC traffic lights is
the same.

The interface and the peripheral changes.


AC Schematic

Red Traffic Light

To GFI

Check Specs 1 2
Solid State Relay
3 4
Pin 18 Pin 2
Real World Traffic Interface
To AC
To AC Light
Light

To Pin 2 To Pin 18
Addresses

smythel@mnsi.net

www.classictechnology.ca

www.holtsoft.com

You might also like