In this week's lab, I performed different experiments to control the tone output amplitude & frequency. I also conducted experiments to control the servomotor.
I used D8 as analog output and A0 analog input pin. I am using changing resistance from force sensing resistor as the input to change the volume of the speaker output.
Tone control using force sensing resistor through Arduino Nano 33 IoT
Tone control using force sensing resistor through Arduino Nano 33 IoT
Output : Tone control using force sensing resistor through Arduino Nano 33 IoT
int speakerPin = 8;
int sensorValue = 0; //Analog input from force sensor
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(speakerPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Read analog input for force sensor
sensorValue = analogRead(A0);
// play the tone for 1 second:
tone(speakerPin, 440,1000);
// do nothing else for the one second you're playing:
delay(1000);
Serial.println(sensorValue);
}
I used D8, D9 as analog output and A0 analog input pin. I am using changing resistance from force sensing resistor as the input to change the volume of the speaker output. Pin D8 has a speaker connected with resistor & D9 has the speaker connected along with the transistor.
Tone control using force sensing resistor through Arduino Nano 33 IoT with/without transistor alongwith speaker
Tone control using force sensing resistor through Arduino Nano 33 IoT with/without transistor alongwith speaker
Tone control using force sensing resistor through Arduino Nano 33 IoT with/without transistor alongwith speaker
int speakerPin_tran = 9;
int speakerPin_notran = 8;
int sensorValue = 0; //Analog input from force sensor
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(speakerPin_tran, OUTPUT);
pinMode(speakerPin_notran, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Read analog input for force sensor
sensorValue = analogRead(A0);
// play the tone for 1 second:
tone(speakerPin_tran, 440,1000);
// do nothing else for the one second you're playing:
delay(1000);
tone(speakerPin_notran, 440,1000);
// do nothing else for the one second you're playing:
delay(1000);
Serial.println(sensorValue);
}