Electronic – Using a piezo disc as an input and output device to ATtiny85

attinyavrmicrocontrollerpiezozener

I am working on an art installation and plan to use a number of these small circuits to make sounds, to sense sound/vibration and also to move the device (using a triangle wave output).

This link gives examples of input and output using the piezo. I have crudely mashed the circuits together into one. Would this work? Or do I need some more components, eg diode protection on the output.

The objective is to create a small circuit with the minimum of parts that can be experimented with as a cell in a kind of physical automaton.

Circuit

Best Answer

  • Add a decoupling cap (100nF) across the AVR's power pins, with leads as short as possible to the ciontroller;
  • For the zener diode use a voltage close, preferably slightly lower to the battery voltage. The trigger threshold of the input is ½ Vcc, so you definitely want the zener voltage higher than that;
  • Did you actually check the sound output volume level with the 10k resistor?
  • You probably want to turn the PWM pin in INPUT mode (high impedance) while sensing the input voltage, to not unnecessarily load the already weak piezo signal;
  • As you need to turn the output pin into input mode for sensing anyway, you can probably use just a single GPIO pin for both functions (saves parasitic capacity and leakage current).