Created
November 14, 2014 02:28
-
-
Save neoneo40/91b461d9b9a13cbe1053 to your computer and use it in GitHub Desktop.
matplotlib으로 EMF 찍어보기, http://www.instructables.com/id/Arduino-EMF-Detector/
This file contains hidden or 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 numpy as np | |
import matplotlib.pyplot as plt | |
import serial | |
sr = serial.Serial('/dev/tty.usbmodem1421',9600) | |
plt.axis([0, 1000, 0, 256]) | |
plt.ion() | |
plt.show() | |
x,y = range(1, 1001),[] | |
start = time.time() | |
while True: | |
try: | |
value = int(sr.readline()) | |
if len(y) >= 1000: | |
y.pop(0) # to remove the first item | |
y.append(value) | |
plt.scatter(x[0:len(y)], y) | |
plt.draw() | |
time.sleep(0.05) | |
end = time.time() | |
if end-start > 10: | |
break | |
except: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment