How do I use a piezo disc as for atleast turning digital value to 1 or by using a transistor. I did that same but it returned zero. Could it turn on a transistor or should I convert some voltage to current or any other problem. I do not want my chips to burn.
Post the circuit of what you tried and details of the piezo disk
Thunderer:
How do I use a piezo disc as for atleast turning digital value to 1 or by using a transistor. I did that same but it returned zero. Could it turn on a transistor or should I convert some voltage to current or any other problem. I do not want my chips to burn.
Piezo when pressed makes one lead + with respect to the other, that force can make current flow one way.
But when you release pressure, the flow goes the other way.
I made this work for a button that senses press on one pin and release on another.
First connect diodes from ground to each lead, pointing from ground to the lead. Those handle the negative voltage that would destroy the pins/chip.
Then connect a diode from each lead to the base of a cheap BJT (bipolar transistor). What I did then was to connect 5V through 2.2K resistors to the collectors of the BJTs and then wires from the emitters directly to the two digital pins.
Even a light touch got sensed with that setup. Piezo makes lot of volt with small current. The diode soaks .7V as does the BJT which also turns the spike into a bit of current flow. The wire from the BJT emitter loads up with current, enough to make the pin HIGH.
The code constantly reads the pin which removes about 1 uA from the wire per read. With over 40K reads per second, the current in the wire from a light touch takes 10's of reads to go LOW while a hard smack with a srewdriver handle would read 2000-3000 times. That's a rough ADC, good enough for user IO.
What would probably work easier is to connect the piezo to an opto-isolator input and the output to the sense pin. The opto led serves as diode and the opto detector serves as transistor. Hook one up to each lead, give it a try.
I got the idea to try that after watching Youtube videos of piezos driving leds, that's what's in those kids sneakers with the lights in the soles.
Hey it worked. When I used the same chip of atmega 328p it did not work but when I used a new one it worked.
Thunderer:
Hey it worked. When I used the same chip of atmega 328p it did not work but when I used a new one it worked.
You might want to find out why, did a pin burn up on the first 328?