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);
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
void loop() {
// put your main code here, to run repeatedly:,100);

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.

Week 17 – Lab Session Blog

We began the session by revising what we learned last week and looking over our previous Arduino code, line by line.

Screenshot of last weeks code

Next, we recreated a circuit from the worksheet which features a 10K Ohm resistor, a pushbutton, an LED, a breadboard and some jumper wires with our Arduino boards. When the button is pressed the LED lights up

Photograph of the circuit.

We then altered the code to create a version where the button controls the LED in a different capacity. It is interesting that we can leave the circuit the same but we can change the function of the hardware by changing only the code.

Updated Code

We then updated the code further to remove a small bug so that the light stays on when turned on and turns off when pressed again. There is a noise generated by the push of the button which we can counteract within the code to make it much more reliable in its function.

We then created a new more basic circuit and code that allows our LED to fade on and off intermittently.

A short video of the LED fading on and off with the circuit in the background.

This session has been an important coding revision and it is very important to understand what your code is doing, line by line. Otherwise you cannot diagnose errors and you won’t have any deeper understanding of what your code is achieving.

Lab Session Notes 17/01/2022

In this session, we began by sharing previous work from a previous years module that was applicable to the current module. Emily’s instrument comprised of a multiple oscillator synth, with multiple monophonic synths assigned to multiple control knobs that alter the pitch.

My own instrument comprises of a light dependent resistor (LDR) to control a monophonic synthesizer within an enclosure. The lighter the environment, the higher the pitch. It was interesting to compare as we never ended up getting to show each other our work last year during the module.

We then plugged in the Arduino and had a go at writing our first code which makes the Arduino LED blink in one second intervals, which is essentially the coding equivalent of “Print (“Hello World!)”.

Figure 1 – Screenshot of the code within the Arduino IDE software

As you can see from figure one, it is incredibly simple to understand the function of the code and it is incredibly concise.

We then adapted our own code by writing our own function to call an if/else statement that would print the value status of either high or low to the serial monitor. I have learned more about the Arduino coding language to which I am very unfamiliar, and is both similar and dissimilar to any coding I have done before.