2010年6月22日火曜日

Sensor 06 Acceleromenter ADXL335

This is a tutorial for Acceleromenter ADXL335

This exercise will be easy since this we can use analog input for this sensor.

Requirement

Arduino

Acceleromenter ADXL335

wires

Computter and USB


 All the thing that you  have to do is that connect 3.3V to Vcc and connect ground of Arduino and sensor and connect XYZ to analog 0,1,2. Write a program that got a data from analog pins and send them back to computer.

Program

/*

program for Acceleromenter ADXL335

*/

void setup()

{

 Serial.begin(9600);

}

void loop()

{

Serial.print("X");

Serial.print(analogRead(0));

Serial.print("Y");

Serial.print(analogRead(1));

Serial.print("Z");

Serial.println(analogRead(2));

delay(100);

}









0 件のコメント:

コメントを投稿