-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_emgcode.py
executable file
·55 lines (41 loc) · 1.3 KB
/
run_emgcode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 9 23:42:33 2015
@author: cloudlife
"""
#import serial
#ser = serial.Serial('/dev/cu.usbmodem1411', 9600)
#while True:
#print ser.readline()
#print ser.readline() # Read the newest output from the Arduino
from __future__ import print_function
from time import sleep
import sys
import serial
ser = serial.Serial('/dev/cu.usbmodem1411', 9600) # Establish the connection on a specific port
##### Digital Read Version #####
while True:
reading = ser.readline()
print("Current reading: " + str(reading))
sleep(.1)
##### Analog Read Version #####
# values = [0,0,0,0,0,0]
# while True:
# reading = ser.readline()
# reading = reading[0:-2]
# #reading = int(reading)
# print("Current reading: [" + str(reading) + "]")
# if reading == '10001':
# values[0] = ser.readline()[0:-2]
# if reading == '10002':
# values[1] = ser.readline()[0:-2]
# if reading == '10003':
# values[2] = ser.readline()[0:-2]
# if reading == '10004':
# values[3] = ser.readline()[0:-2]
# if reading == '10005':
# values[4] = ser.readline()[0:-2]
# if reading == '10006':
# values[5] = ser.readline()[0:-2]
# sleep(.1) # Delay for one tenth of a second
# print("Stored values: " + str(values))