IMG_0056ed

IMG_0056ed

Advertisements

9

9

Arduino code

#include <SoftwareSerial.h>

 

//#include <NewSoftSerial.h>

SoftwareSerial mySerial (2, 3);
int minVal = 265;
int maxVal = 402;

int ledPin = 13; // LED connected to digital pin 13
const int xPin = 0;
const int yPin = 1;
const int zPin = 2;
const int tilt = 3;

 

void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(tilt, INPUT);
Serial.begin(9600); //9600bps is default for OpenLog
//Serial.begin(57600); //Much faster serial, used for testing buffer overruns on OpenLog
//Serial.begin(115200); //Much faster serial, used for testing buffer overruns on OpenLog

delay(1000); //Wait a second for OpenLog to init

Serial.println();
Serial.println(“Run OpenLog Test”);
mySerial.begin(9600);
}

void loop() {
String xRead = String(analogRead(xPin), DEC);
String yRead = String(analogRead(yPin), DEC);
String zRead = String(analogRead(zPin), DEC);
String tiltread = String(digitalRead(tilt), DEC);
String stringOne = String(xRead + “, “+yRead+ “, “+zRead+ “, “+tiltread); //+ “, “+zRead

Serial.println(stringOne);
//Serial.println(“sent”);
delay(25);

}

//////////////////////////////////////////////////////////////////
//©2011 bildr
//Released under the MIT License – Please reuse change and share
//Simple code for the ADXL335, prints calculated orientation via serial
//////////////////////////////////////////////////////////////////

//Analog read pins

//The minimum and maximum values that came from
//the accelerometer while standing still
//You very well may need to change these