5.2 Code example
Once you have completed the installation and booted the system, open
the terminal console and run the following command:
In the window that opens, please enter the following code completely.
Alternatively you can download the code example here download it
here .
nano ISD1820.py
from time import sleep
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
pe=13
rec=11
GPIO.setup(pe,GPIO.OUT)
GPIO.setup(rec,GPIO.OUT)
GPIO.output(pe,0)
GPIO.output(rec,0)
def recording():
sleep(3)
print("Recording starts")
GPIO.output(pe, 1)
sleep(10)
GPIO.output(pe, 0)
sleep(5)
print("Recording finished")
def play():
print("Playback starts")
GPIO.output(rec, 1)
sleep(1)
GPIO.output(rec, 0)
sleep(10)
print("Playback finished")
while True:
recording()
play()
Raspberry Pi Soundmodule
5V VCC
GND GND
GPIO 14 (Pin 8) P-E
GPIO 15 (Pin 10) REC
You can save your input with the key combination CTRL+O and leave the
editor with CTRL+X.
You can then start the example with
and end it with CTRL+C.
python3 ISD1820.py