520 likes | 704 Views
Computer Engineering Activities Interfacing Music Box Project ACSE 2004. Graham Smyth. Computer Engineering Units. Grade 10/11/12 1. Hardware 2. Networking 3. Integrated Circuits 4. Programming 5. Interfaces. Interfacing Activities. Grade 10 One bit Three LEDs
E N D
Computer Engineering ActivitiesInterfacingMusic Box ProjectACSE 2004 Graham Smyth
Computer Engineering Units Grade 10/11/12 1. Hardware 2. Networking 3. Integrated Circuits 4. Programming 5. Interfaces
Interfacing 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 Activities • Grade 12 • One byte • LED intersection • Stop Lights AC? • Vehicles • Security systems • Drag strips • Music Box • Latches • Marquees • GUIs/Mouse Control
Music Box Note indicator Light Note push button
Breadboard Connections Connected High Fives Divider Low Fives Connected
Music 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!!!
Interfacing System Unit 5 Computer Interface Peripheral • Parallelport • Wires • ICs • Resistors • Capacitors • Transistors • LED's • Motors • Lights • Robots • Music Box • Joysticks Wires Wires
Music 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 - Resistor(Four Required) 1 0 X 103 BrownBlackOrangeGold Tolerance +-5%
Music Box Hardware Cable: D sub to Breadboard Male Pin Insulated Wire Small Crimp Tab Stripped Wire Large Crimp Tab
3 Pair Cable White/Green Green/ White Orange/ White White/Orange Blue/ White White/ Blue
Music Box Hardware:Normally Open Switch Schematic Physical 1 1 2 2
Music Box Hardware : Parallelport Input I0 – I3 Output D0 – D7 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 Grounds 18 - 25 Input I4 View from back of Computer
D Sub Connector Pin 10 Pin 2 D sub Connector Pin 18
D Sub Connector Pin 2 Check Bottom, 2 Down
D Sub Connector Check Pin 2, Bottom, 2 Down Pin 18, Top, 5 Down Pin 10, Bottom, 10 Down Pin 11 Pin 12 Pin 13 Total of six wires from D sub connector
Breadboard Switches Span Divider
Breadboard with Resistors Resistors to Top Rail Brown/Black/Orange Align
D Sub to Breadboard Cable To Pin 2 White/Green Four Wires To Pin18 White/Blue Switch to Ground
D Sub to Breadboard Cable Pin 10 Green/ White Pin 11 Orange/ White Pin 12 White/Orange Pin 13 Blue/ White Pin 2 White/Green Pin18 White/Blue
Music Box Software Assignment 1 Write a program that will continuously scan for input values from the MUSIC BOX.
Music Box SoftwareAssignment 1 parallelput(1) loop % Start of infinite loop. put parallelget % Returns input pin values. end loop % End of loop.
Music Box Note Matrix Remember these Numbers
Music Box Software Assignment 2 Write a program that will play the notes “CDEG” each as quarter notes.
Music Box Software Assignment 2 parallelput(1) var value : int loop value := parallelget if value = ______ then play (“C”) elsif value = _____ then play (“D”) Etc Save as MusicBox2
Music Box Software Assignment 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 Screen (640,400) (0,0)
Music Box Software Assignment 3: A GUI part 1 locatexy (300, 300) put "MUSIC BOX PLAYER" locatexy (200, 140) put "C D E G" % drawing 4 circles with perimeter black drawoval (200, 200, 40, 40, black) drawoval (300, 200, 40, 40, black) drawoval (400, 200, 40, 40, black) drawoval (500, 200, 40, 40, black)
Music Box Software Assignment 3: A GUI part 2 % filling 4 circles with white drawfilloval (200, 200, 40, 40, white, black) drawfilloval (300, 200, 40, 40, white, black) drawfilloval (400, 200, 40, 40, white, black) drawfilloval (500, 200, 40, 40, white, black)
Music Box Software Assignment 3: A GUIpart 3 parallelput(1) var value : int loop value := parallelget if value = ______ then % fills “C” GUI with red drawfilloval (200, 200, 40, 40, red, black) % plays C for a quarter note play “C” % sets “C” GUI back to white drawfilloval (200, 200, 40, 40, white, black)
Music Box Software Assignment 3: A GUIpart 4 elsif value = _____ then % fills “D” GUI with red drawfilloval (300, 200, 40, 40, red, black) play “D” % sets “D” GUI back to white drawfilloval (300, 200, 40, 40, white, black) Similarly for notes E and G Save as MusicBox3
Music Box Tune Mary Had a Little Mary had a little lamb E D C D E E E rest Little lamb D D D rest Little lamb E G G rest Mary had a little lamb E D C D E E E rest Whose fleece was white as snow E D D E D C Save as MusicBox4
Music Theory • play (“8CDEFGAB>C”) – plays one octave of 8th notes from middle C • play(“<BAGFEDC”) – plays scale in reverse in 8th notes if it follows previous line • play (“>4CDEFGAB”) – plays one octave of quarter notes one octave up from middle C • play (">6CpC+pC-") – plays one octave up from middle C, a C 16th note, a rest, C sharp, a rest, and a C flat • play(“1C2C4C6C”) – plays whole, half, quarter, and 16th C note
Music Box Software Assignment 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 MusicBox5
Music Box Software Assignment 5 Write a program that will automatically play “Mary Had a Little Lamb”. Save as MusicBox6
Additional Music Box 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