code.py
 1  # SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """
 6  'audio.py'.
 7  
 8  =================================================
 9  alarm circuit with a FSR and a speaker
10  requires:
11  - CircuitPython_CharLCD Module
12  """
13  import audioio
14  import analogio
15  import board
16  
17  f = open("siren.wav", "rb")
18  a = audioio.AudioOut(board.A0, f)
19  
20  fsr = analogio.AnalogIn(board.A2)
21  threshold = 200
22  while True:
23      if fsr.value < threshold:
24          a.play(loop=True)
25      else:
26          a.pause()