Compare commits
2 commits
Accelerome
...
main
Author | SHA1 | Date | |
---|---|---|---|
boutrie.eytan | 4ffe8e146d | ||
boutrie.eytan | 3fb983fe37 |
|
@ -35,7 +35,11 @@ S20A is 3.3V voltage regulator MIC5205-3.3BM5
|
||||||
#include "MPU9250.h"
|
#include "MPU9250.h"
|
||||||
|
|
||||||
float biai = 1.25;
|
float biai = 1.25;
|
||||||
|
unsigned long previousTime;
|
||||||
|
int interval = 300;
|
||||||
|
int stepPin = 14;
|
||||||
|
int dirPin = 12;
|
||||||
|
bool pinState = LOW;
|
||||||
// an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68
|
// an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68
|
||||||
MPU9250 IMU(Wire,0x68);
|
MPU9250 IMU(Wire,0x68);
|
||||||
int status;
|
int status;
|
||||||
|
@ -54,20 +58,20 @@ void setup() {
|
||||||
Serial.println(status);
|
Serial.println(status);
|
||||||
while(1) {}
|
while(1) {}
|
||||||
}
|
}
|
||||||
|
pinMode(stepPin,OUTPUT);
|
||||||
|
pinMode(dirPin,OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// read the sensor
|
// read the sensor
|
||||||
|
digitalWrite(dirPin,HIGH);
|
||||||
IMU.readSensor();
|
IMU.readSensor();
|
||||||
// display the data
|
// display the data
|
||||||
Serial.print("AccelX: ");
|
|
||||||
Serial.print(IMU.getAccelX_mss(),2);
|
|
||||||
Serial.print(" ");
|
|
||||||
Serial.print("AccelY: ");
|
|
||||||
Serial.print(IMU.getAccelY_mss(),2);
|
|
||||||
Serial.print(" ");
|
|
||||||
Serial.print("AccelZ: ");
|
|
||||||
Serial.println(IMU.getAccelZ_mss() + biai,2);
|
|
||||||
|
|
||||||
delay(200);
|
if((micros() - previousTime) >= interval){
|
||||||
|
previousTime = micros();
|
||||||
|
pinState = !pinState;
|
||||||
|
digitalWrite(stepPin,pinState);
|
||||||
|
Serial.println(IMU.getAccelX_mss() + IMU.getAccelY_mss() + IMU.getAccelZ_mss() + biai +11);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue