Lecture
In the lecture we spoke about the different ways that you can use an Arduino board to expand simple projects into more complex ones. We looked at different sensors and in particular I looked at a force sensitive resistor.

The link for this image of a FSR – Force-Sensing-Resistor.jpg (1847×1114) (elprocus.com)
Lab
We began the lab by using code for the Arduino that allowed for a sine tone to be created using a small speaker. The circuit that was used is included below and this is followed by the code that allowed us to create a sine tone with breaks in between.
//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 the tone plays
*/
tone(piezoPin, 450);
delay(500);
noTone(piezoPin);
delay(500);
}

We went through many other commands that you can add to the code in order to create more advanced melodies. We made our own code that ascend up to a specific note and then decrease to another. The code included below is just that.
//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 the tone plays
*/
for (int i=31; i<10000; i++) {
tone(piezoPin, i, 1000);
delay(10);
}
for (int i=10000; i>700; i--) {
tone(piezoPin, i, 10000);
delay(10);
}
}
Digital Oscillator

Code for digital oscillator
//CODE DigitalOSC
const int ledPin = 13; //variable to represent LED Pin
const int periodKnob = A0; //variable for knob pin (A0 = analog in pin 0)
int delayTime; //variable for the delay time
void setup() {
pinMode(ledPin, OUTPUT); //configure pin 13 as a digital output
}
void loop() {
//set delay time equal to the current value read on analog pin 0
delayTime = analogRead(periodKnob);
//map the analog read range from 0-1023 to 10000-1
//delayTime = map(delayTime, 0, 1023, 10000, 1);
digitalWrite(ledPin, HIGH); //set pin 13 to 5 volts
delayMicroseconds(delayTime); //pause program
digitalWrite(ledPin, LOW); //set pin 13 to 0 volts
delayMicroseconds(delayTime); //pause program
}
//