Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
boutrie.eytan | 4ffe8e146d | ||
boutrie.eytan | 3fb983fe37 |
|
@ -1,41 +1,77 @@
|
||||||
/*
|
/*
|
||||||
Blink
|
* Library: https://github.com/bolderflight/MPU9250
|
||||||
|
Basic_I2C.ino
|
||||||
|
Brian R Taylor
|
||||||
|
brian.taylor@bolderflight.com
|
||||||
|
|
||||||
Turns an LED on for one second, then off for one second, repeatedly.
|
Copyright (c) 2017 Bolder Flight Systems
|
||||||
|
|
||||||
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||||
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
|
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
the correct LED pin independent of which board is used.
|
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||||
If you want to know what pin the on-board LED is connected to on your Arduino
|
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||||
model, check the Technical Specs of your board at:
|
furnished to do so, subject to the following conditions:
|
||||||
https://www.arduino.cc/en/Main/Products
|
|
||||||
|
|
||||||
modified 8 May 2014
|
The above copyright notice and this permission notice shall be included in all copies or
|
||||||
by Scott Fitzgerald
|
substantial portions of the Software.
|
||||||
modified 2 Sep 2016
|
|
||||||
by Arturo Guadalupi
|
|
||||||
modified 8 Sep 2016
|
|
||||||
by Colby Newman
|
|
||||||
|
|
||||||
This example code is in the public domain.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||||
|
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Updated by Ahmad Shamshiri on July 09, 2018 for Robojax.com
|
||||||
|
* in Ajax, Ontario, Canada
|
||||||
|
* watch instrucion video for this code:
|
||||||
|
For this sketch you need to connect:
|
||||||
|
VCC to 5V and GND to GND of Arduino
|
||||||
|
SDA to A4 and SCL to A5
|
||||||
|
|
||||||
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
|
S20A is 3.3V voltage regulator MIC5205-3.3BM5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// the setup function runs once when you press reset or power the board
|
#include "MPU9250.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;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// initialize digital pin LED_BUILTIN as an output.
|
// serial to display data
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
Serial.begin(115200);
|
||||||
|
while(!Serial) {}
|
||||||
|
|
||||||
|
// start communication with IMU
|
||||||
|
status = IMU.begin();
|
||||||
|
if (status < 0) {
|
||||||
|
Serial.println("IMU initialization unsuccessful");
|
||||||
|
Serial.println("Check IMU wiring or try cycling power");
|
||||||
|
Serial.print("Status: ");
|
||||||
|
Serial.println(status);
|
||||||
|
while(1) {}
|
||||||
|
}
|
||||||
|
pinMode(stepPin,OUTPUT);
|
||||||
|
pinMode(dirPin,OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the loop function runs over and over again forever
|
|
||||||
void loop() {
|
void loop() {
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
// read the sensor
|
||||||
// turn the LED on (HIGH is the voltage level)
|
digitalWrite(dirPin,HIGH);
|
||||||
delay(1000);
|
IMU.readSensor();
|
||||||
// wait for a second
|
// display the data
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
|
||||||
// turn the LED off by making the voltage LOW
|
if((micros() - previousTime) >= interval){
|
||||||
delay(1000);
|
previousTime = micros();
|
||||||
// wait for a second
|
pinState = !pinState;
|
||||||
|
digitalWrite(stepPin,pinState);
|
||||||
|
Serial.println(IMU.getAccelX_mss() + IMU.getAccelY_mss() + IMU.getAccelZ_mss() + biai +11);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue