Created
May 6, 2015 19:15
-
-
Save amokan/d37cd34b91f9eefdc52e to your computer and use it in GitHub Desktop.
firmata test with pressure sensor
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 org.firmata.*; | |
| import cc.arduino.*; | |
| import processing.serial.*; | |
| Arduino arduino; | |
| int val = 0; | |
| int currX = 0; | |
| void setup() { | |
| size(1024, 800); | |
| noSmooth(); | |
| resetView(); | |
| arduino = new Arduino(this, "/dev/tty.usbserial-A601EWGV", 57600); | |
| } | |
| void draw() { | |
| val = arduino.analogRead(0); | |
| line(currX, 1024, currX, 1024 - (val + 1)); | |
| currX ++; | |
| if (currX > 1024) { | |
| currX = 0; | |
| resetView(); | |
| } | |
| delay(500); | |
| } | |
| void resetView() { | |
| background(0); | |
| stroke(255); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment