Gyroscope

来自Microduino Wikipedia
Pkj讨论 | 贡献2014年5月22日 (四) 12:49的版本 (Created page with "{{Language | 陀螺仪}} {| style="width: 800px;" |- | ==Objective== This tutorial will use the Microduino-10DOF module's gyroscope and accelerometer sensor to measure data, a...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索
Language English

Objective

This tutorial will use the Microduino-10DOF module's gyroscope and accelerometer sensor to measure data, and then display the data in Processing.

Equipment

Microduino-10DOF

  • Other equipment
    • USB cable one

Schematic

Use the Microduino-10DOF module's gyroscope and accelerometer sensor directly.

Program

Refers to MPU6050Microduino

processingGyro

Debug

Step 1:Set up hardware system, as follows:

AtmosphericDataCollectionConnectionDiagram.jpg

Step 2: Explain the code:

This example needs two parts code, one is Processing and the other is Microduino.

Microduino:

//Get the gyroscope and accelerometer sensor's data and output to serial to dispaly.

 void loop() {
     accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
     sprintf(str, "%d,%d,%d,%d,%d,%d,%d", ax, ay, az, gx, gy, gz); 
     Serial.print(str);
     Serial.write(byte(10));
     delay(20);
 }

Processing:

//Get the first serial port data.

 myPort = new Serial(this, Serial.list()[0], 9600); // first COM port

//Display Microduino received data in screen.

Function description:

readSensors() //Read the sensor data

normalize3DVec(float [] vector) //Process the 3d vector

buildBoxShape() //Setup the shap of box

drawCube() //Draw the box

getInclination() //Get the angle


Step 3: Compile the code and download it.

Step 4: After running, rotate the Microduino module and observe Microduino's display.

Result

A box will be displayed in screen, it can simulate the Microduino's posture, as follows:

ProcessingGyroResult.jpg

Video