Does the buzzer only work when powered in one direction? Is it damaged if reverse powered?
You could get rid of the 3.3V line and the transistors, and hook up the LED and buzzer in opposite polarity. If both GPIO pins are the same level, nothing happens. If one is high and the other is low, the LED lights. In the opposite case the buzzer lights.
Or you could use a 3-to-8 line decoder logic chip, with one input tied. This will make a 2-to-4 line decoder: 00 off; 01 LED; 10 Buzzer; 11 Bonus!
But it's probably better if you show your schematic for more suggestions.
You could get rid of the 3.3V line and the transistors, and hook up the LED and buzzer in opposite polarity. If both GPIO pins are the same level, nothing happens. If one is high and the other is low, the LED lights. In the opposite case the buzzer lights.
Or you could use a 3-to-8 line decoder logic chip, with one input tied. This will make a 2-to-4 line decoder: 00 off; 01 LED; 10 Buzzer; 11 Bonus!
But it's probably better if you show your schematic for more suggestions.
Statistics: Posted by ame — Sun Jan 14, 2024 6:40 am