SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By amrsaad
#194789
Hi everyone!

I'm extremely new to Arduino, and have a university assignment due very soon. My project is Arduino based, and I'm trying to get a Piezo buzzer to make a sound when a force sensor is pressed. Thanks to some Youtube tutorials I've got the wiring down as well as the coding, but the board does nothing once I upload the code. I'll paste the code here. Any help would be extremely appreciated!!!


int force;

void setup() {
pinMode(15, OUTPUT);

Serial.begin(9600);
}

void loop() {
force = analogRead(A0); //defining force as FSR data


if (force < 100) { //if not pressed and not in front

noTone(15); //dont play music

}

else if ((force > 100)) { //if pressed

tone(15, 261); //call a certain note depending on distance

}

}
By Valen
#194798
You give no information about the force sensor. Or how the sensor is connected. Does the force sensor ever give enough of a signal so the analog to digital converter can measure a value above 100? Print the value of force back to the serial port so you can see what it actually is. (Since you defined the baudrate, why not actually use it. ;) ) What voltage would that be equivalent to? On what arduino board are you testing this?