Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
boutrie.eytan | 4ffe8e146d | ||
boutrie.eytan | 3fb983fe37 |
|
@ -33,20 +33,20 @@ S20A is 3.3V voltage regulator MIC5205-3.3BM5
|
|||
*/
|
||||
|
||||
#include "MPU9250.h"
|
||||
#include "AccelStepper.h"
|
||||
|
||||
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
|
||||
MPU9250 IMU(Wire,0x68);
|
||||
int status;
|
||||
AccelStepper stepper;
|
||||
|
||||
void setup() {
|
||||
// serial to display data
|
||||
Serial.begin(115200);
|
||||
stepper.setMaxSpeed(1700);
|
||||
stepper.setSpeed(1700);
|
||||
while(!Serial) {}
|
||||
|
||||
// start communication with IMU
|
||||
|
@ -58,21 +58,20 @@ void setup() {
|
|||
Serial.println(status);
|
||||
while(1) {}
|
||||
}
|
||||
pinMode(stepPin,OUTPUT);
|
||||
pinMode(dirPin,OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read the sensor
|
||||
digitalWrite(dirPin,HIGH);
|
||||
IMU.readSensor();
|
||||
stepper.runSpeed();
|
||||
// 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