I’ve got a electrical question. I think I’ve got it sorted out but I just wanted to be sure before I blow anything up. So it would be great if somebody could confirm that I’m heading in the right direction (or not )
I’m running out of I/O on my BB2 so I want to combine the beeper output (P9) with a digital input. And still be able to use the beeper. Basically like the tree leds and buttons on the BB2.
Can I connect a push button to the P9 pin and let it pull to the GND when pushed. A 10k resistor will pull the input to Vcc when the button is not pushed. I know this happens but I’m a bit unsure what happens if the button is pushed and the output is set to make some beeps. Am I making a short trough the uC that way? If I look at it, it will make short circuit when the uC makes the output high and the button is pushed. But if I look at the schematic from the BB2 I notice that the buttons and leds are working on exactly the same way.
Although electrically correct, your schematic is upside down. Usually when drawing schematics power nets are on top and ground nets are on bottom. What you have now is a pull-up ressitor configuration which brings P9 to a hight state when the button is open, low when the button is pressed. The 10k ressitor is not considered a short since it’s a load, and current is restricted. If you remove the 10k resistor, then you have your self a nice short to ground when the button is pressed.
I would recommend inserting a small resistor, say maybe 470 ohms to 1000 ohms, between pin 9 and the junction between the switch and the 10K resistor. If you happen to have pin 9 configured as an output and are assering a high state when you press the button it will be a hard short to ground and you risk damaging the pin 9 output driver.
Sorry for the mix-up in the diagram. Initially I drew a pull-down resistor to make P9 low. This way the base on transistor Q1 would be low when the button isn’t pushed. I only swapped GND and Vc because that was easier
I think I’ll go with the small transistor in the P9 line to make sure the output stays alive when using the speaker.
The LED and button circuitry works great, but there are only two valid states for the I/O pin! It’s either in input or a low.
Making it an input to check the status of the I/O pin.
Make it a low in order to light up the LED.
In use your program would keep the I/O pin an input. If you need to light up the LED, you make the I/O pin a low. To keep the LED lit and read the status of the I/O pin you need to make the I/O pin an input just prior to checking the status of the pin, then it must be switched back to a low immediately after checking the status of the I/O pin.
So there really is no chance to short the I/O pin if programmed properly.
The Speaker circuitry must be driven high by a sound command to get output. If you just attach a switch to the I/O pin 9 there is a potential for a short if the sound command is playing when the button is pressed. However I doubt it would destroy the I/O pin as it’s “on” for a very short time. If you put a 220 ohm resister in series with the switch then it should prevent any I/O pin discomfort.
Just wanted you guys know I added a 1k resistor in series with the switch to prevent it from shortage. It works great! I can read the input and send sounds to the speaker without a problem!
I’m adding a scroll function on the DIY-RC which allows me to show more data on the screen. The RC is pretty stuffed so it’s hard to find space and free pins. But his worked out perfect. More information comming once i’ve got it up and running.