Well , i am working on a project with a flame sensor and a passive buzzer . I have the KY WIN ROBOT flame sensor with 4 pins ( VCC , GND , D0, A0 ) . The main idea is that when fire is detected , buzzer is hit in order to alarm . I am trying to power the rails of the breadboard with VCC and GND in order to power on these two modules (flame sensor , buzzer) .
In the positive rail of the breadboard i've put the cable of the pin 5V of arduino and in the negative rail of the breadboard i've put the cable of GND pin of arduino.
BUT i have this problem : When i connect all the modules and then the arduino usb cable to laptop it seem's that arduino is not powered . But when i disconnect the VCC cable OR the GND cable of the buzzer from the breadboard , arduino is powered on .
So after a research , i’ve found that the middle pin of this module (KY-006 Passive Buzzer) is NOT connected. I connected Pin (S) to digital PIN 8 and GND of buzzer module to GND of arduino. Finally it worked.
But i think, i have run into a new “problem” respecting the source code . So as i said the simple main idea behind this project is that when the module detects flame , the buzzer goes on and a LED also .
When i run the code and i light a lighter the module correctly detects the flame but the buzzer does not make any sound .
Ok , i changed the buzzer Pin to PWM pin (9) on arduino. Regarding your reply i need to switch ON and OFF repeatedly in order to produce sound , but in my source code i have put the commands to turn ON buzzer and turn OFF buzzer digitalWrite[pin,HIGH] and digitalWrite[pin,LOW] respectively .
Should i use tone() function or something else ? **Not too much experience with arduino