AME MATD3039 Lab Session 07/02/22

We began this session as usual by revising our blog posts from last week and the content we covered.

We then setup a circuit that features a 100 Ohm resistor and a piezo disc as a speaker that produces one single stable, monophonic frequency sine tone. The code for this version is featured below.

//A sketch to demonstrate the tone() function
//Specify digital pin on the Arduino that the positive lead of
//piezo buzzer is attached.
const int piezoPin = 8;
void setup() {
}//close setup
void loop() {
/*Tone needs 2 arguments, but can take three
1) Pin#
2) Frequency - this is in hertz (cycles per second) which
determines the pitch of the noise made
3) Duration - how long teh tone plays
*/
tone(piezoPin, 250, 500);
//tone(piezoPin, 1000, 500);
//delay(1000);
}
No description available.

We then created a version of the code that rapidly increases the pitch and then a version that can ascend and then descend when it hits its threshold pitch.

We then utilized a piece of code that recreates the Mario theme tune through limited beeps which was interesting, so far most of the end products have been very unmusical but now we have a musical output which is encouraging. Below is a small snippet of the code which is quite lengthy due to the many pitches, etc required.

Tone tone1;
void setup() {
// put your setup code here, to run once:
tone1.begin(8); // Playback on Pin 11, change to whatever you may
//need
}
void loop() {
// put your main code here, to run repeatedly:
tone1.play(660,100);
delay(75);tone1.play(660,100);
delay(150);tone1.play(660,100);
delay(150);tone1.play(510,100);
delay(50);tone1.play(660,100);
delay(150);tone1.play(770,100);
delay(275);tone1.play(380,100);
delay(287);tone1.play(510,100);
delay(225);tone1.play(380,100);
delay(200);tone1.play(320,100);
delay(250);tone1.play(440,100);
delay(150);tone1.play(480,80);
delay(165);tone1.play(450,100);
delay(75);tone1.play(430,100);
delay(150);tone1.play(380,100);
delay(100);tone1.play(660,80);
delay(100);tone1.play(760,50);
delay(75);tone1.play(860,100);
delay(150);tone1.play(700,80);
delay(75);tone1.play(760,50);
delay(175);tone1.play(660,80);

We then implemented a new circuit with a speaker output jack and a potentiometer which controlled the frequency of the output signal.

No description available.

Leave a Reply

Your email address will not be published. Required fields are marked *