Skip to content

Instantly share code, notes, and snippets.

@dwblair
Last active January 18, 2020 00:07
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 dwblair/1c833936348cbc23f12f8346cb9a4634 to your computer and use it in GitHub Desktop.
Save dwblair/1c833936348cbc23f12f8346cb9a4634 to your computer and use it in GitHub Desktop.
import serial
PORT='/dev/ttyACM0'
OUTFILE='out.csv'
#f=open(OUTFILE,"w+")
#f=open(OUTFILE,"a+")
s=serial.Serial(PORT,115200,timeout=1)
SIZE = 10
NUM = 1
RES = 12
RATE = 5
# SET UP THE SAMPLING
s.write('ADC.SET_SIZE '+str(SIZE)+'\n\r') # number of samples to grab in one go
s.write('ADC.SET_NUM '+str(NUM)+'\n\r') # number of times to repeat the sample grab
s.write('ADC.SET_RES '+str(RES)+'\n\r') # resolution
s.write('ADC.SET_RATE '+str(RATE)+'\n\r') # resolution
print("SIZE=",SIZE)
print("NUM=",NUM)
print("RES=",RES)
print("RATE=",RATE)
for i in range(0,3):
s.write('ADC.START\n\r')
print(s.readline())
s.write('ADC.STOP\n\r')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment