FSR with LED and Piezo Buzzer

hi i have difficulties combining LED and and buzzer in the same program.

i want the LED and buzzer to trigger at the same time when force is applied.

i'm a newbie so i would appreciate simple and straightforward codes.

thank you!!

currently i have:

int fsrAnalogPin = 0;
int LEDpin = 11;
int buzzer = 8;
int fsrReading;
int LEDbrightness;

void setup(void) {
Serial.begin(9600);
pinMode(LEDpin, OUTPUT);
pinMode(buzzer, OUTPUT);
}

void loop(void) {
fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);

LEDbrightness = map(fsrReading, 0, 1023, 0, 255);

analogWrite(LEDpin, LEDbrightness);
tone (buzzer, 200, 250);
delay(100);
}

(Sensor is reading the value of force. LED lights up according to the amount of force. Buzzer does not sound at all)

Please read the forum guidelines in the sticky post, then edit and fix your post above.

Also you should explain what your circuit is doing now, and how this is wrong.

You should be able to see the force reading on the serial monitor and it should change depending on the force applied to the FSR. At what value do you want the led and buzzer to activate?

Use an active buzzer like this. Then just hook them up in parallel from the same output pin. That's what I did when I made a geiger counter. Put a switch on the buzzer line so you have a bit of quiet.

ChrisTenone:
Use an active buzzer like this. Then just hook them up in parallel from the same output pin. That's what I did when I made a geiger counter. Put a switch on the buzzer line so you have a bit of quiet.

Hey, i am using the buzzer you mentioned :slight_smile:

i changed my codes entirely

naaadirah:
Hey, i am using the buzzer you mentioned :slight_smile:

i changed my codes entirely

Right, cause you don't need to use tone() with that kind of buzzer, just give it 3.3 to 5 volts, and it screams!

If you share your updated code, please enclose it within [code]code tags[/code].

First check that which type of buzzer you are using
(Required voltage ,current etc)

Can arduino board drive it directly or not
Try it individually by setting any pin as output and test it.

If not try using transistor.