Computer Engineering Remote Controlled Car Project ACSE 2006
Computer Engineering Activities Interfacing Music Box Project ACSE 2004
description
Transcript of Computer Engineering Activities Interfacing Music Box Project ACSE 2004
Computer Engineering Computer Engineering ActivitiesActivities
InterfacingInterfacing
Music Box ProjectMusic Box Project
ACSE 2004ACSE 2004Graham Smyth Graham 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 ActivitiesGrade 12• One byte• LED intersection• Stop Lights AC?• Vehicles• Security systems• Drag strips• Music Box• Latches• Marquees• GUIs/Mouse Control
Introduction to Traffic Lights Introduction to Traffic Lights
Traffic Lights Traffic Lights
Traffic Lights Traffic Lights
Introduction to MotorsIntroduction to Motors
MotorsMotors
Introduction to Music Introduction to Music
Music BoxMusic Box
Note indicator Light Note push button
Music: Pipe OrganMusic: Pipe Organ
Breadboard ConnectionsBreadboard Connections
Connected
Connected
HighFives
DividerLowFives
Music Box SoftwareMusic Box 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!!!
Computer Computer Interface Peripheral Interface Peripheral
Interfacing SystemInterfacing System
Unit 5
• Parallelport • Wires• ICs• Resistors• Capacitors• Transistors
• LED's• Motors• Lights• Robots• Music Box •Joysticks
Wires Wires
Music Box HardwareMusic Box Hardware
• Five male pins • One D sub connector • Cable 1 – D sub to Breadboard• Four N.O. pushbuttons
• Four Resistors (Brown/Black/Orange)• One Breadboard• Extra wire• Enhancement hardware ????
Music Box Hardware - ResistorMusic Box Hardware - Resistor(Four Required)
Brown Black Orange Gold
1 0 X 103
Tolerance+-5%
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
Music Box Hardware Music Box Hardware Cable: D sub to BreadboardCable: D sub to Breadboard
Male Pin Insulated Wire
Large Crimp Tab Stripped Wire
Small Crimp Tab
3 Pair Cable3 Pair Cable
White/Green
Green/ White
Orange/ White
White/Orange Blue/ WhiteWhite/ Blue
Cable with Male PinsCable with Male Pins
Music Box Hardware:Music Box Hardware:Normally Open SwitchNormally Open Switch
1
2
1 2
Physical Schematic
Inputting DataInputting Data
Music Box Hardware : Music Box Hardware : 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
D Sub Connector /HarnessD Sub Connector /Harness
D Sub Connector Colour Code D Sub Connector Colour Code
Pin Pin ##
ColourColour
22 White/ GreenWhite/ Green
1010 Green/ WhiteGreen/ White
1111 Orange/ WhiteOrange/ White
1212 White/ OrangeWhite/ Orange
1313 Blue/ WhiteBlue/ White
1818 White/ BlueWhite/ Blue
D Sub ConnectorD Sub Connector
Pin 2
Pin 18
D sub Connector
Pin 10
D Sub ConnectorD Sub Connector
Check
Pin 2
Bottom, 2 Down
D Sub ConnectorD Sub Connector
Total of six wires from D sub connector
Pin 2, Bottom, 2 Down
Pin 18, Top, 5 Down
Pin 10, Bottom, 10 Down
Pin 11
Pin 12
Pin 13
Check
BreadboardBreadboard
Switches Span Divider
Breadboard with ResistorsBreadboard with Resistors
Resistors to Top Rail
Brown/Black/Orange
Align
D Sub to Breadboard Cable D Sub to Breadboard Cable To Pin 2
White/Green
To Pin18 White/Blue
Four Wires
Switch to Ground
D Sub to Breadboard Cable D Sub to Breadboard Cable
Pin18 White/Blue
Pin 2White/Green
Pin 10Green/ White
Pin 11Orange/ White
Pin 12White/Orange
Pin 13Blue/ White
The hardware is complete.The hardware is complete.
Now to the software Now to the software
Music Box Software Music Box Software Assignment 1Assignment 1
Write a program that will continuously scan for input values from the MUSIC BOX.
Music Box SoftwareMusic Box SoftwareAssignment 1Assignment 1
parallelput(1)loop % Start of infinite loop. put parallelget % Returns input pin values.end loop % End of loop.
Music Box Note MatrixMusic Box Note Matrix
Switch Note Parallelget Value
1 C
2 D
3 E
4 G
Remember these Numbers
Music Box Software Music Box Software Assignment 2Assignment 2
Write a program that will play the notes “CDEG” each as quarter notes.
Music Box Software Music Box Software Assignment 2Assignment 2
parallelput(1)var value : intloop
value := parallelgetif value = ______ then
play (“C”)elsif value = _____ then
play (“D”)
EtcSave as MusicBox2
Music Box Software Music Box Software Assignment 3Assignment 3
Write a program that will play the notes “CDEG” each as quarter notes and at the same time display a GUI representing the played notes.
Adding Graphics ScreenAdding Graphics Screen
(0,0)
(640,400)
Music Box Software Music Box Software Assignment 3: A GUI Assignment 3: A GUI part 1part 1
locatexy (300, 300)locatexy (300, 300)put "MUSIC BOX PLAYER"put "MUSIC BOX PLAYER"locatexy (200, 140)locatexy (200, 140)put "C D E G"put "C D E G"% drawing 4 circles with perimeter black% drawing 4 circles with perimeter blackdrawoval (200, 200, 40, 40, black)drawoval (200, 200, 40, 40, black)drawoval (300, 200, 40, 40, black)drawoval (300, 200, 40, 40, black)drawoval (400, 200, 40, 40, black)drawoval (400, 200, 40, 40, black)drawoval (500, 200, 40, 40, black)drawoval (500, 200, 40, 40, black)
Music Box Software Music Box Software Assignment 3: A GUI Assignment 3: A GUI part 2part 2
% filling 4 circles with white% filling 4 circles with white
drawfilloval (200, 200, 40, 40, white, black)drawfilloval (200, 200, 40, 40, white, black)
drawfilloval (300, 200, 40, 40, white, black)drawfilloval (300, 200, 40, 40, white, black)
drawfilloval (400, 200, 40, 40, white, black)drawfilloval (400, 200, 40, 40, white, black)
drawfilloval (500, 200, 40, 40, white, black)drawfilloval (500, 200, 40, 40, white, black)
Music Box Software Music Box Software Assignment 3: A GUIAssignment 3: A GUI part 3part 3
parallelput(1)var value : intloop
value := parallelgetif value = ______ then
% fills “C” GUI with red drawfilloval (200, 200, 40, 40, red, black)drawfilloval (200, 200, 40, 40, red, black)
% plays C for a quarter noteplay “C”% sets “C” GUI back to whitedrawfilloval (200, 200, 40, 40, white, black)drawfilloval (200, 200, 40, 40, white, black)
Music Box Software Music Box Software Assignment 3: A GUIAssignment 3: A GUI part 4part 4
elsif value = _____ then
% fills “D” GUI with red
drawfilloval (300, 200, 40, 40, red, black)drawfilloval (300, 200, 40, 40, red, black)
play “D”
% sets “D” GUI back to white
drawfilloval (300, 200, 40, 40, white, black)drawfilloval (300, 200, 40, 40, white, black)
Similarly for notes E and GSave as MusicBox3Save as MusicBox3
Music Box TuneMusic Box TuneMary Had a Little
Save as MusicBox4Save as MusicBox4
Mary had a little lambE D C D E E E restLittle lambD D D restLittle lambE G G restMary had a little lambE D C D E E E restWhose fleece was white as snowE D D E D C
Music TheoryMusic Theory play (“8CDEFGAB>C”) – plays one octave play (“8CDEFGAB>C”) – plays one octave
of 8of 8thth notes from middle C notes from middle C play(“<BAGFEDC”) – plays scale in reverse play(“<BAGFEDC”) – plays scale in reverse
in 8in 8thth notes if it follows previous line notes if it follows previous line play (“>4CDEFGAB”) – plays one octave of play (“>4CDEFGAB”) – plays one octave of
quarter notes one octave up from middle Cquarter notes one octave up from middle C play (">6CpC+pC-") – plays one octave up play (">6CpC+pC-") – plays one octave up
from middle C, a C 16from middle C, a C 16thth note, a rest, C note, a rest, C sharp, a rest, and a C flatsharp, a rest, and a C flat
play(“1C2C4C6C”) – plays whole, half, play(“1C2C4C6C”) – plays whole, half, quarter, and 16quarter, and 16thth C note C note
Music Box Software Music Box Software Assignment 4Assignment 4
Write a program that will:• play a tune • display a GUI of the notes being played• change the colour of the note name.
Save as MusicBox5Save as MusicBox5
Music Box Software Music Box Software Assignment 5Assignment 5
Write a program that will automatically play “Mary Had a Little Lamb”.
Save as MusicBox6Save as MusicBox6
Additional Music Box Additional Music Box Software Software
Additions• Add an LED above each key on the keyboard• Add additional keys to the keyboard• Store a tune• Test a users ability to replay the tune
More Hands-On ActivitiesMore Hands-On Activities
• Keyboard• Intersection• Robot• World’s Largest Joystick