Created
September 30, 2014 15:25
-
-
Save Craigson/782d6bd26be01ef38b94 to your computer and use it in GitHub Desktop.
Serial Communication with Processing (ADXL335 Accelerometer)
This file contains 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
const int buttonPin = 2; | |
void setup(){ | |
Serial.begin(9600); | |
pinMode(buttonPin, INPUT); | |
establishContact(); | |
} | |
void loop(){ | |
if (Serial.available() > 0) { | |
int inByte = Serial.read(); | |
//take reading for x-axis | |
int sensorValue = analogRead(A0); | |
Serial.print(sensorValue); | |
Serial.print(","); | |
//take reading for x-axis | |
sensorValue = analogRead(A1); | |
Serial.print(sensorValue); | |
Serial.print(","); | |
//take reading for x-axis | |
sensorValue = digitalRead(buttonPin); | |
Serial.println(sensorValue); | |
} | |
} | |
void establishContact(){ | |
while (Serial.available() <= 0){ | |
Serial.println("hello"); //send a starting message | |
delay(300); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment