Skip to content

Instantly share code, notes, and snippets.

@jasta
Created May 23, 2022 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasta/4311d8ded25b20bdd5a565e93b814406 to your computer and use it in GitHub Desktop.
Save jasta/4311d8ded25b20bdd5a565e93b814406 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import time
import grovepi
divider = 2
setting = 10
grovepi.pinMode(divider, "INPUT")
print('Sampling...')
while True:
sum = 0
for i in range(100):
reading = grovepi.analogRead(divider)
sum += reading
time.sleep(0.002)
avg = sum / 100
adj = setting * avg * (4980 / 1023.00)
print("reading.avg={}, adj={}".format(avg, adj))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment