I’ve started my blog before on Wordpress. Here’s the link:
https://giav2030.wordpress.com/?_gl=1*e5rba2*_gcl_aw*R0NMLjE3NTgxNTQ1MTkuQ2owS0NRand1S25HQmhENUFSSXNBRDE5UnNhVW9nTVJ3TGNPbEdaVDZmNzlSYlBNOVQxYmhHZWdhNEZ3UHB5YTJvT2plakI3VGJqZTZTa2FBcVVXRUFMd193Y0I.*_gcl_au*MTkzNDk0MzE3My4xNzU3MjkwMTk3LjI0ODk0MDg4MS4xNzU3MjkwNzY0LjE3NTcyOTA5MTg.
However, I decided to go with Notion now that some people has taught me about it!
The following circuit is for producing tones from a speaker, changing that output by using an FSR.

This is the code for checking the sensitivity of the FSR.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //initialize serial comms
}
void loop() {
// put your main code here, to run repeatedly:
int analogueValue = analogRead(A0); //read analog input
Serial.println(analogueValue); // print it
delay(100);
}
This was the result on that measure, it goes from 0 to 1000. Meaning that I should use a smaller range of those values to get better results.
_16.38.55.png)
Next, I’ll check if the speaker works by changing the code a little bit. The code used was the following.
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
//play tone for 1 second
tone(8, 440, 1000);
// pause for 1 second
delay(1000);
}
Effectively, I am hearing a tone continually. Meaning that the speaker is connected properly as the lab states. However, because of the play tone for 1 second and pause for 1 second, I did not understand correctly why it sounds continuously.
Next I’ll try to play tones through the speaker. I’ll be mapping the output from 200 to 900 Hz to test if the speaker plays them correctly. For this exercise I used the following code:
void setup() {
// put your setup code here, to run once:
}
void loop() {
//get sensor reading
int sensorReading = analogRead(A0);
//map the results from the sensor reading's range to desired pitch range
float frequency = map(sensorReading,0, 1000, 100,1000);
Serial.println(frequency);
//change the pitch, play for 10 ms
tone(8,frequency,10);
delay(30);
}
After that, it was really interesting to build the circuit with a transistor, allowing the speaker to play sound a little louder. I used the following code to achieve this.
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
tone(8,400,1000);
delay(1000);
}
This is how the circuit looks like
