Computer Architecture and Organization. Electronic Keyboard

Similar documents
Assignment #3: Piezo Cake

Arduino Lesson 3. RGB LEDs

1. Arduino Board and Breadboard set up from Project 2 (8 LED lights) 2. Piezo Speaker

Lesson 4 RGB LED. Overview. Component Required:

EP486 Microcontroller Applications

Laboratory 8. Digital Circuits - Counter and LED Display

Lab 3c Fun with your LED cube. ENGR 40M Chuan-Zheng Lee Stanford University 19 May 2017

ENGR 40M Project 3b: Programming the LED cube

Experiment 0: Hello, micro:bit!

Module 4: Traffic Signal Design Lesson 1: Traffic Signal (Arduino) Control System Laboratory Exercise Grade 6-8

Digital 1 Final Project Sequential Digital System - Slot Machine

Technology Control Technology

Fig. 1 Analog pins of Arduino Mega

8 PIN PIC PROGRAMMABLE BOARD (DEVELOPMENT BOARD & PROJECT BOARD)

Laboratory 11. Required Components: Objectives. Introduction. Digital Displays and Logic (modified from lab text by Alciatore)

Measure the value of water flow using water flow sensor and DC water pump 12 V interfacing with Arduino uno

Triple RTD. On-board Digital Signal Processor. Linearization RTDs 20 Hz averaged outputs 16-bit precision comparator function.

Figure 7.8 Circuit Schematic with Switches, Logic Gate, and Flip-flop

Bill of Materials: 7-Segment LED Die with Arduino PART NO

Lesson Sequence: S4A (Scratch for Arduino)

ENGR 1000, Introduction to Engineering Design

Lecture (04) Arduino Microcontroller Programming and interfacing. By: Dr. Ahmed ElShafee

Catch or Die! Julia A. and Andrew C. ECE 150 Cooper Union Spring 2010

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

The Infinity Portal Craig A. Lindley 03/16/2011

Circuit Playground Hot Potato

This module senses temperature and humidity. Output: Temperature and humidity display on serial monitor.

Self-Playing Xylophone

Part (A) Controlling 7-Segment Displays with Pushbuttons. Part (B) Controlling 7-Segment Displays with the PIC

Instructions and answers for teachers

Laboratory 7. Lab 7. Digital Circuits - Logic and Latching

Theory and Practice of Tangible User Interfaces. Thursday Week 3: Analog Input. week. Sensor 1: Potentiometers. Analog input

SparkFun Inventor's Kit for micro:bit Experiment Guide

The Serial Port is Dead! Long Live the Serial Port! USB Serial Port Breadboard Experiments with the FTDI FT232R

Lab 23 Controller Diagnostics

DRAFT Microprocessors B Lab 3 Spring PIC24 Inter-Integrated Circuit (I 2 C)

Laboratory 10. Required Components: Objectives. Introduction. Digital Circuits - Logic and Latching (modified from lab text by Alciatore)

INTRODUCTION (EE2499_Introduction.doc revised 1/1/18)

Digital Circuits I and II Nov. 17, 1999

DX-10 tm Digital Interface User s Guide

Basic LabVIEW Programming Amit J Nimunkar, Sara Karle, Michele Lorenz, Emily Maslonkowski

HS-509 VIBRATION TRIP MODULE

Due date: Sunday, December 5 (midnight) Reading: HH section (pgs ), mbed tour

TV Synchronism Generation with PIC Microcontroller

Character LCDs. Created by lady ada. Last updated on :47:43 AM UTC

DMC550 Technical Reference

Lab experience 1: Introduction to LabView

Objectives: Learn how LED displays work Be able to output your name on the display

Rfid Based Attendance System

This document is intended to provide information to allow the researcher to build their own device.

ECE Lab 5. MSI Circuits - Four-Bit Adder/Subtractor with Decimal Output

PLTW Engineering Digital Electronics Course Outline

Edge Connector Light Level Detector

Alice EduPad Board. User s Guide Version /11/2017

Digital Electronics Course Outline

Lab P-6: Synthesis of Sinusoidal Signals A Music Illusion. A k cos.! k t C k / (1)

Ginger Bread House

Combo Board.

Modcan Touch Sequencer Manual

Art M Digital codelock module

Data Acquisition Using LabVIEW

Experiment # 4 Counters and Logic Analyzer

Arduino LED Matrix Control. Controlling lots of LEDs

Lab #10: Building Output Ports with the 6811

Vtronix Incorporated. Simon Fraser University Burnaby, BC V5A 1S6 April 19, 1999

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

APPLICATION NOTE 4312 Getting Started with DeepCover Secure Microcontroller (MAXQ1850) EV KIT and the CrossWorks Compiler for the MAXQ30

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT /12/14 BIT 10 TO 65 MSPS DUAL ADC

Fig. 1. The Front Panel (Graphical User Interface)

ECE 372 Microcontroller Design

AD9884A Evaluation Kit Documentation

Session 1 Introduction to Data Acquisition and Real-Time Control

EE 367 Lab Part 1: Sequential Logic

Introduction. The Clock Hardware. A Unique LED Clock Article by Craig A. Lindley

EEM Digital Systems II

Introduction 1. Green status LED, controlled by output signal ST. Sounder, controlled by output signal Q6. Push switch on input D6

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT /12/14 BIT 10 TO 105 MSPS ADC

SRV02-Series. Rotary Pendulum. User Manual

successive approximation register (SAR) Q digital estimate

In total 2 project plans are submitted. Deadline for Plan 1 is on at 23:59. The plan must contain the following information:

ENGR 1000, Introduction to Engineering Design

Building the ChronoDot Calendar Reminder

Informatics Enlightened Station 1 Sunflower

The Micropython Microcontroller

QTI Line Follower AppKit for the Boe-Bot (#28108)

AES Channel Digital/Analog Audio Switcher/DA/Digital to Analog Converter

9/23/2014. Andrew Costin, Tom Syster, Ryan Cramer Advisor: Professor Hack Instructor: Professor Lin May 5 th, 2014

SHOWLINE SL NITRO 510 LED STROBE LUMINAIRE SPECIFICATIONS.

Computer Systems Architecture

Vorne Industries. 87/719 Analog Input Module User's Manual Industrial Drive Itasca, IL (630) Telefax (630)

The New and Improved DJ Hands: A Better Way to Control Sound

Altera s Max+plus II Tutorial

Extreme MINDSTORMS TM : An Advanced Guide to LEGO MINDSTORMS TM

Telephony Training Systems

W0EB/W2CTX DSP Audio Filter Operating Manual V1.12

Interfacing Analog to Digital Data Converters. A/D D/A Converter 1

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

Assignment 3: 68HC11 Beep Lab

LABORATORY # 1 LAB MANUAL. Digital Signals

ECE-320 Lab 5: Modeling and Controlling a Pendulum

Transcription:

Computer Architecture and Organization Electronic Keyboard By: John Solo and Shannon Stastny CPSC - 42, Merced College Professor Kanemoto, December 08, 2017

Abstract Our arduino project consists of an electronic keyboard that has seven piano keys. The piano keys are as follows: B5, A5, G5, F5, E5, D5, and C5. The user is able to freely play a song by utilizing these seven keys. The second part of our project includes a piano player that plays preset songs. We have an LCD screen designed with a user interface that allows the user to navigate to which song that they want to listen to by pressing the eight button and any piano key. We implemented four preset songs: Super Mario Theme, Super Mario Underworld Theme, Star Wars Main Theme, and the Zelda Main Theme. We found the original sheet music for these songs and converted it into compliable code for the arduino to playback to the user with the piezo capsule. 2

Table of Contents Abstract 2 1.0 Introduction 4 2.0 Hardware and Components 4 2.1 Components Listing 5 2.2 Hardware Setup 5 2.3 Completed Hardware 6 3.0 Diagrams 7 3.1 Circuit Diagram 7 3.2 Schematic 8 4.0 Sheet Music 9 5.0 Software 10 5.1 electronic_keyboard.ino 10 Frequencies 11 Void loop() 11 Song1title() 12 5.2 pitches.h 13 5.3 song1.ino: Super Mario Theme 14 Melodies 14 Note Durations 15 For Loop 16 6.0 Code Additions 17 6.1 Song3: Star Wars Main Theme 17 6.2 Song4: Zelda Main Theme 18 7.0 Conclusion 19 References 20 3

1.0 Introduction Our project expands on the Electric Piano Keyboard with Preset Songs by Lindsay Fox on Hackster.io. We also drew inspiration from Arduino Lab 7 Keyboard Instrument to implement the piezo buzzer and additional buttons. The electronic keyboard acts as a piano that has seven piano keys that are programmed to the middle of B/A/G/F/E/D/C. It can also act as a pianola or a player piano that plays premade piano songs. The original code came packaged with five preset songs, but we scrapped three of the songs to add two of our own. 2.0 Hardware and Components (Images taken from Hackster.io) 4

2.1 Components Listing 1x Arduino Uno 1x Adafruit Standard LCD - 16x2 8x Pushbutton 4x 220 ohm resistor 1x 560 ohm resistor 1x 1k ohm resistor 3x 10k ohm resistor 1x 1M ohm resistor 1x Piezo buzzer 1x LED 1x Potentiometer 1x Pack of jumper wires 2x Breadboard Piano Keys 2.2 Hardware Setup There s seven piano keys each connected to a resistor. The resistors used for the switches are 220, 560, 1k, 10k, and 1M ohm. The leftmost switch starts with the smallest resistor and each consecutive switch is connected to a resistor larger than the previous switch. Essentially, we have a resistance ladder that are connected to A0. LCD Screen The LCD screen is connected to the potentiometer and connected to pins 2-5. Piezo Buzzer The piezo buzzer is connected to a resistor and pin 8, and it is in its own separate breadboard. LED (generic) The LED is connected to pin 6 with a push button connected to pin 7. Both are connected to a resistor. 5

2.3 Completed Hardware One of the challenges that we faced when completing the hardware was supplying voltage to the entire breadboard. For some reason, our breadboard was separated into two halves so we had to jump wires from one half of the breadboard to the other. Another challenge was completing the circuit itself. As soon as we connected the wire to ground, the arduino turned off. We broke one of our initial counterfeit arduino r3 because we hooked it to a usb power supply and a 12v power supply. We eventually ended up using the official product. Shannon designed a box to make our hardware more stylish and user friendly. She handled most of the user interface design and made the piano key buttons intuitive by making them longer/higher as the note gets higher. We re both music enthusiasts and we wanted to blend our passion for music with our passion for computer science. Overall, we completed a product that plays preset songs and allows the user to play their own songs. It serves as an entertainment device. Here s our hardware with its circuitry completed: 6

3.0 Diagrams Diagrams were made with fritzing software. The first diagram is from the hackster.io website but the schematic was entirely done by us. 3.1 Circuit Diagram (Taken from Hackster.io) 7

3.2 Schematic 8

4.0 Sheet Music Adding additional preset music wouldn t have been possible without finding the sheet music for the songs. The sheet music provided below are sample sheets that can be found at musicnotes.com and acts as a reference for us when coding preset songs. We transcribed the sheets and converted it into compilable code for the arduino to interpret and playback to the piezo buzzer. Our program utilizes an array that contains the pitches that the song depends on and a for loop that traverses through the array. (Taken from musicnotes.com) Song 3 was coded with the sheet music on the left while song 4 was coded using the sheet music to the right. 9

5.0 Software The main part of the software was written by Lindsay Fox on hackster.io, but the other two individual preset Mario songs (song1 and song2) were coded by Dipto Pratyaksa. There s five program files in total with one of the files being an external library called pitches.h that contains individual constant variables referencing different pitches. We added two new songs to the code: Zelda Main Theme and Star Wars Main Theme; replacing Songs: 3, 4, and 5. Our project files include: electronic_keyboard.ino, pitches.h, song1.ino, song2.ino, song3.ino, song4.ino 5.1 electronic_keyboard.ino Lindsay Fox imported two external libraries: LiquidCrystal.h for the LCD screen and pitches.h for the piezo buzzer. The opening code defines the pins and their matching hardware components and an array of notes for buttons. 10

Frequencies These if-else statements defines the frequencies associated with each pushbutton. It utilizes the array of notes and associates them with different frequencies. The notes are as follows: C,D,E,F,G,A,B. There s a final else if that does not play notes if none of the switches are pressed. Each switch has a different resistance and plays a different note from the array defined in the beginning of the code. Void loop() Here s the void loop code that loops for the LCD screen and the song titles. 11

Song1title() This is the song title loop part code that s part of electronic_keyboard.ino. It references the song1.ino file that contains the mario song and it defines the words that ll appear on the LCD screen. It operates when the menu button is pressed and another key from one the seven piano keys are pressed. 12

5.2 pitches.h This is an important external library that allows us to utilize music notes in our arduino program. This file contains constant variables that are associated with different pitches. The file does not contain any flats but it does have sharp notes. Our array melodies in each file contains these music notes and with the help of note duration arrays, we are able to create a song for our arduino program. 13

5.3 song1.ino: Super Mario Theme The song s arduino code was written by Dipto Pratyaksa, and there s a link to the original article in the code file. This song file serves as a basic structure for us to manipulate and personalize so we can code our own songs. Here is the basic code anatomy for a song file which includes: melodies, note durations, and loops. Melodies We have an int melody array that contains the note values of the song. These notes are referencing the constant variables that are in the pitches.h file. The notes are modeled from the original sheet music for the Super Mario Theme. The 0 represents a stop time and still has a note duration associated with it. 14

Note Durations The note durations has the same amount elements as the melody array because it defines the delay for each note. The note duration are coded as follows: a four is a quarter note, an eighth is an eighth note, a nine is a triplet, and a twelve is a sixteenth note. The note duration can be found by reading the original sheet music. 15

For Loop This for loop is what glues the melody array and note duration together. The size variable grows proportionally to the size of the array and terminates the loop as soon as the index reaches the size. This part of the code loops through both the note duration and melody array and outputs them to pin 8 which is connected to the piezo buzzer. Most of our code additions follows this basic structure. 16

6.0 Code Additions Our code additions follows the code anatomy of song1 and song2. We have a melody array, note duration array, a for loop, and some LCD print statements to indicate what song the user is listening to. Song3 is the Star Wars main theme and Song4 is the Zelda Main Theme. We based our code on the sample music sheets from musicnotes.com and images are located in section 4.0 Sheet Music. Song3 has fifty new lines of code and song 4 has fifty new lines of code. In total, we added one hundred new lines of code. 6.1 Song3: Star Wars Main Theme This entire file contains fresh new code from us, but follows the same structure as song1. Most of the code looks really similar, but the constant values and note durations are entirely different from the other songs since its unique to this song. 17

6.2 Song4: Zelda Main Theme The Zelda Main Theme was the first song we coded. It was longer and more challenging than the Star Wars Main Theme since there were note durations that were counterintuitive to our code. We troubleshooted the audio playback by ear and that was how we debugged the song. The code is separated into paragraphs to help the coder identify where in the sheet music we derived our notes from. Here s the for loop for the melody and note duration code: 18

7.0 Conclusion The Electronic Piano was able to evolve through a series of collaborative efforts that allowed the project to grow into a fully functional product that can entertain its users with hardware produced music. From the hardware to the software, we meticulously researched and implemented ways to transform how music is perceived. Electronic instruments isn t a new phenomenon, but showing the relationship between applied mathematics and music theory illustrates how intertwined the humanities and the sciences are. The two needed each other. Each pitch had a constant numerical value, but without the proper arrangement of the pitches, the sound that played back wouldn t make sense. Music is simply a collection of organized sounds and without the mathematical backing of the pitches, there wouldn t be any sounds to organize. Our project allowed us to venture outside of strictly performing computational analysis for computers, and allowed us the creative freedom to implement music with Computer Science principles. 19

References Fox, Lindsay. Electronic Piano Keyboard with Preset Songs. Hackster, 11 Feb. 2016 Kondo, Koji. The Legend of Zelda Main Theme from 'The Legend of Zelda' Sheet Music (Easy Piano) (Piano Solo) in C Major - Download & Print. Musicnotes.com, www.musicnotes.com/sheetmusic/mtd.asp?ppn=mn0109469. Williams, John. Star Wars (Main Theme)" from 'Star Wars' Sheet Music (Easy Piano) 20