Skip to content

Instantly share code, notes, and snippets.

@amokan
Created May 6, 2015 19:15
Show Gist options
  • Select an option

  • Save amokan/d37cd34b91f9eefdc52e to your computer and use it in GitHub Desktop.

Select an option

Save amokan/d37cd34b91f9eefdc52e to your computer and use it in GitHub Desktop.
firmata test with pressure sensor
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