EasyManua.ls Logo

DFRobot Gravity Series - Sample Code; Expected Result

Default Icon
7 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Sample Code
# Analog sound sensor is used to measure the sound.
# Hardware : analog sound sensor, pyboard v1.1
# connect:
# sensor pyboard
# VCC 3V3
# GND GND
# data X5
from pyb import ADC,Pin
import time
adc=ADC(Pin('X5')) # Connect sensor to 'X5'
while True:
val=adc.read() # Reed the analog value
print(val)
time.sleep(0.1)
Expected Result
Copy the sample code in the uPyCraft IDE, save it, then click the DownloadAndRun button, you
will see the value of the sound.
As shown in the picture below, when there is sound, the value will increase significantly.