Schematic
If using a solderless breadboard, first solder pin headers on your Trinket board (they come included). For GEMMA you can use alligator jumpers. The parts you need are at right. You will need a resistor, nominally 1K to 10K ohms but this can vary a bit if you do not have that value, just do not make it too low or high.
Pins used:
- GPIO #0 (Digital 0) is connected to the signal pin (+) on the piezo speaker.
- GPIO #2 (Analog 1) is connected to the junction of the photocell and the resistor.
You can power the circuit from the USB connection or from an external supply connected to BAT (or Vout on GEMMA) as shown below (4 to 6 volts DC).