computer engineering activities introduction to interfacing traffic light project si 2003 graham...
TRANSCRIPT
Computer Engineering Computer Engineering ActivitiesActivities
Introduction to InterfacingIntroduction to Interfacing
Traffic Light ProjectTraffic Light Project
SI 2003SI 2003Graham Smyth Graham Smyth Yungsiow YangYungsiow Yang
Kevin SheaKevin SheaJerry DolataJerry DolataIlana SmythIlana Smyth
Computer Engineering UnitsComputer Engineering Units
Grade 10/11/12
1. Hardware1. Hardware
2. Networking2. Networking
3. Integrated Circuits3. Integrated Circuits
4. Programming4. Programming
5. 5. InterfacesInterfaces
Interfacing ActivitiesInterfacing Activities
Grade 10• One bit• Three LEDs• LED simulators• ASCII• Binary counting• Light patterns• Intersections• AC ???
Grade 11• One bit• One byte• DC motor• Bi-directional • LED traffic light• LED intersection• Demultiplexer• GUIs• Mouse control• AC ??
Interfacing ActivitiesInterfacing Activities
Interfacing ActivitiesInterfacing Activities
Introduction to Traffic Lights Introduction to Traffic Lights
Breadboard ConnectionsBreadboard Connections
Connected
Connected
HighFives
DividerLowFives
ParallelportParallelport
View from View from backback of Computer of Computer
13 12 11 10 9 8 7 6 5 4 3 2 1
25 24 23 22 21 20 19 18 17 16 15 14
OutputD0 – D7
InputI0 – I3
Input I4 Grounds18 - 25
Computer Computer Interface Peripheral Interface Peripheral
Interfacing SystemInterfacing System
Unit 5
• Parallelport • Resistors • LED's
Wires Wires
Joystick SoftwareJoystick Software
Turing
• parallelput(number) - reads 8 pins• put parallelget - reads 5 pins• mousewhere(x,y,click)• play(“CDEFG”)• drawline(x1,y1,x2,y2,red)• FREE!!!
parallelput(number)parallelput(number)
NumberNumber D7D7 D6D6 D5D5 D4D4 D3D3 D2D2 D1D1 D0D0
11 11 11 11 11 11 11 11
00 00 00 00 00 11 00 00parallelput(4)parallelput(4)
parallelput(5)parallelput(5) 00 00 00 00 00 11 00 11
parallelput(25parallelput(255)5)
Traffic Light HardwareTraffic Light Hardware
• Four male pins • One D sub connector • Cable • Three 220 ohm resistors (red/red/brown)• Three LEDs• One Breadboard
220 ohm Resistor220 ohm Resistor
Red Red Brown Gold
2 2 X 101
Direction Resistor inserted IS NOT important
Resistor ChartResistor Chart
BAND 1 BAND 2 BAND 3 BLACK 0 0 1 BROWN 1 1 10
RED 2 2 100 ORANGE 3 3 1 000 YELLOW 4 4 10 000 GREEN 5 5 100 000 BLUE 6 6 1 000 000
VIOLET 7 7 10 000 000 GRAY 8 8 100 000 000 WHITE 9 9 1 000 000 000
LEDLED
+ = Long Lead - = Short Lead
+ = Edge - = No Edge
Direction LED inserted IS important
D sub to BreadboardD sub to Breadboard
Male Pin Insulated Wire
Large Crimp Tab Stripped Wire
Small Crimp Tab
Traffic Light Hardware Traffic Light Hardware (Eight wire colour scheme)
change
White/Orange
White/Blue
Orange
White/Brown
Blue
BrownGreenWhite/Green
The D Sub ConnectorThe D Sub Connector(with extraction wire)(with extraction wire)
The D Sub ConnectorThe D Sub Connector
Pin 2
Pin 18
D sub Connector
Stop Light WiringStop Light Wiring
Green (Pin18)
White/Green (Pin2)
White/Orange (Pin4) White/Brown (Pin3)
Traffic Light Traffic Light (hardware)(hardware)
Pin 18 Pin 3 Pin 2 Pin 4
GND Wire
+
-
Traffic Light Traffic Light (hardware)(hardware)
Resistor to GND
Align
The hardware is complete.The hardware is complete.
Now to the software Now to the software
Stop Light Question 1Stop Light Question 1
Write a program that will output a Write a program that will output a traditional stop light pattern.traditional stop light pattern.
Stop Light Activation Answer 1 Stop Light Activation Answer 1
Version 1Version 1
parallelput (4) parallelput (4) % Red light% Red light
delay (500)delay (500)
parallelput (2) parallelput (2) % Yellow light% Yellow light
delay (500)delay (500)
parallelput (1) parallelput (1) % Green light% Green light
delay (500)delay (500)
Stop Light Activation Answer 1Stop Light Activation Answer 1
Version 2Version 2
for counter : 0 .. 2for counter : 0 .. 2 % three lights% three lights
parallelput (2 ** counter)parallelput (2 ** counter) % clever expon. % clever expon.
delay (500)delay (500)
end forend for % three lights % three lights
Adding Graphics ScreenAdding Graphics Screen
(0,0)
(640,400)
Virtual Traffic LightsVirtual Traffic Lights
% Outline of traffic box% Outline of traffic boxdrawfillbox (100, 60, 250, 370, gray)drawfillbox (100, 60, 250, 370, gray)% Red light% Red lightdrawfilloval (175, 315, 35, 35, red)drawfilloval (175, 315, 35, 35, red)% Yellow light% Yellow lightdrawfilloval (175, 225, 35, 35, 92)drawfilloval (175, 225, 35, 35, 92)% Green light% Green lightdrawfilloval (175, 135, 35, 35, green)drawfilloval (175, 135, 35, 35, green)
delay (2000)loop % Red light parallelput (4) drawfilloval (175, 315, 35, 35, brightred) drawfilloval (175, 225, 35, 35, 92) drawfilloval (175, 135, 35, 35, green) delay (2000)
Real and Virtual Traffic LightsReal and Virtual Traffic LightsREDRED
Real and Virtual Traffic LightsReal and Virtual Traffic LightsYELLOWYELLOW
% 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 LightsReal and Virtual Traffic LightsGREENGREEN
% Green lightparallelput (1)
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 2Stop Light Question 2
Write a program that will output Write a program that will output a traditional stop light pattern a traditional stop light pattern including an advanced green. including an advanced green.
Stop Light Software Answer 2 Stop Light Software Answer 2 Advanced GreenAdvanced Green
Insert at appropriate placeInsert at appropriate place
for counter : 1 .. 5for counter : 1 .. 5
parallelput (1)parallelput (1) % % Green light Green light onon
delay (300)delay (300)
parallelput (0)parallelput (0) % % Green lightGreen light offoff
delay (300)delay (300)
end forend for
Stop Light Question 3Stop Light Question 3
Write a program that will add a Write a program that will add a second traffic light to simulate an second traffic light to simulate an intersection. intersection.
Stop Light Question 4Stop Light Question 4
Write a program that will output a Write a program that will output a traditional stop light pattern to real traditional stop light pattern to real world traffic lights.world traffic lights.
Stop Light Software Answer 4 Stop Light Software Answer 4
The software for DC LED traffic lightsThe software for DC LED traffic lights
and the real world AC traffic lights is and the real world AC traffic lights is
the the samesame. .
The interface and the peripheral The interface and the peripheral changes.changes.
AC SchematicAC Schematic
1 2 Solid State Relay 3 4
Pin 18 Pin 2
Check Specs
To GFI
Red Traffic Light
Real World Traffic InterfaceReal World Traffic InterfaceTo AC Light
To AC Light
To Pin 18 To Pin 2
More Hands-On ActivitiesMore Hands-On Activities
• Keyboard• Intersection• Robot• World’s Largest Joystick