Created
May 13, 2022 05:38
-
-
Save emwdx/fbea45d647426ae403941e3a1c10c8e7 to your computer and use it in GitHub Desktop.
Circuitpython Morse Code Receiver
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
import time | |
import board | |
from adafruit_circuitplayground import cp | |
import digitalio | |
from analogio import AnalogIn | |
inputPin = cp.light | |
THRESHOLD = 2000 | |
DELAY_SECONDS = 0.005 | |
TOTAL_RECORD_TIME = 10.0 | |
elapsedTime = 0.0 | |
oldTime = time.monotonic() | |
data = [] | |
def thresholdValue(value): | |
if(value > THRESHOLD): | |
return 1 | |
else: | |
return 0 | |
while (elapsedTime < TOTAL_RECORD_TIME): | |
currentTime = time.monotonic() | |
pinValue = cp.light | |
recordValue = pinValue#thresholdValue(pinValue) | |
#print("{0},{1}".format(elapsedTime, recordValue)) | |
data.append([elapsedTime,recordValue]) | |
time.sleep(DELAY_SECONDS) | |
elapsedTime += currentTime - oldTime | |
oldTime = currentTime | |
for row in data: | |
print("{0},{1}".format(row[0], row[1])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment