Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 948

Python • GPIO and Buzzer activation

$
0
0
I'm working on a python code to make an access control by RFID and it is working very well. Now I have the final implementation with a buzzer to make a short sound when the RFID tag is detected. I have a 3 pins active buzzer (VCC, GND and I/O signal) feeded at 3.3 volts connected in this way:

VCC ==> pin 1 (pin number)
GND ==> pin 9
I/0 ==> pin 11

I wrote this code:

Code:

#!/home/luca/pi-rfid/env pythonimport RPi.GPIO as GPIOfrom time import sleepGPIO.setmode(GPIO.BOARD)GPIO.setup(11, GPIO.OUT)try:while True:print("Beep ON")GPIO.output(11, GPIO.LOW)sleep(0.3)GPIO.output(11, GPIO.HIGH)print("Beep OFF")sleep(5)finally:GPIO.cleanup()
The buzzer is working well but on the opposite: it is making the sound when I set GPIO.LOW and silence when I set GPIO.HIGH....nothing bad...but is not logic and somewhere I have a mistake.

Statistics: Posted by eidii — Wed Mar 27, 2024 9:48 pm — Replies 0 — Views 1



Viewing all articles
Browse latest Browse all 948

Latest Images

Trending Articles





Latest Images