Created
May 23, 2022 03:50
-
-
Save jasta/4311d8ded25b20bdd5a565e93b814406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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