Skip to content

Instantly share code, notes, and snippets.

@dz1984
Created April 14, 2013 02:53
Show Gist options
  • Save dz1984/5381202 to your computer and use it in GitHub Desktop.
Save dz1984/5381202 to your computer and use it in GitHub Desktop.
把Arduino抓到的數值,透過Serial方式傳到Processing程式,利用Processing的互動特性,將這些數值視覺化,方便觀察數字變化關係。 (Arduino)
//A0 - input pin
int fsrPin = 0;
byte fsrReading;
void setup(){
pinMode(fsrPin,INPUT);
Serial.begin(9600);
}
void loop(){
//Translate 0~1023 to 0~254
fsrReading = map(analogRead(fsrPin),0,1023,0,254);
//Write a byte to PC through Serial port.
Serial.write(fsrReading);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment