Question

In: Electrical Engineering

need a code for mpu 6050 gyro module for arduino it needs to read the angle...

need a code for mpu 6050 gyro module for arduino
it needs to read the angle of the pendulum and feed information back into stepper motor to try to attain balance

Solutions

Expert Solution

Actually this my code..and you need to modify some parts from this code

#include<wire.h> //wire library

#include<i2Cdev.h>//i2C Library

#include<MPU6050.h> //mpu6050 library

MPU6050 mpu;

int16_t aa,ab,ac;

int16_t ba,bb,bc;

#define in1 5
#define in2 6

void setup(){
Serial.begin(9600);
Serial.println("Initialize MPU");
mpu.initialize();
//Serial.println(mpu.testConnection() ? "Connected" : "Connection failed"); pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);

}

void loop(){
mpu.getMotion6(&aa, &ab, &ac, &ba, &bb, &bc);

aa = map(aa, -17000, 17000, -1500, 1500);

//Serial.println(aa);
if(aa > 0){
if(aa<255){
Serial.println(aa);
analogWrite(in2,aa);
}
else{
Serial.println("+255");
analogWrite(pin2,255);
}

}
if(aa<0){
if(aa>-255){
Serial.println(aa);
analogWrite(in1, aa-aa-aa);
}

.........................................................................................................
else{
Serial.println("-255");
analogWrite(in1, 255);
}
}
delay(1000);
}


Related Solutions

We need to code an LCD with a temperature and humidity sensor for the arduino UNO...
We need to code an LCD with a temperature and humidity sensor for the arduino UNO board. The LCD should simply display the temperature and humidity reading from the DHT11 sensor. We must do this without the use of arduino or lcd libraries, and only use raw c code. For example we need to use PORTD |= (1<<5); to set the pin to 5. The LCD is connected to pins A0 and A1, and it is using I2C. The temperature...
Hi there, I need mpx2100ap arduino code do I need an amplifier to make this work...
Hi there, I need mpx2100ap arduino code do I need an amplifier to make this work ?
I need an Arduino uno code to measure high low levels with hcsr04 of a tank...
I need an Arduino uno code to measure high low levels with hcsr04 of a tank and display it on i2c 20x4 lcd.
Using Arduino to blink an LED in morse code. Morse code is used as one of...
Using Arduino to blink an LED in morse code. Morse code is used as one of the methods for communications. It consists of a series of “dit” and “dah” symbols. (i) Develop an Arduino program to produce a Morse code to express the phrase “We are students” using Pin #13 (connect an LED that is in series with a 220-Ω resistor to Pins #13 to view the information sent via the Morse code). Express one “dit” with LED on for...
This problem needs to be solved with source code. I need a C++ program that will...
This problem needs to be solved with source code. I need a C++ program that will help me solve this question. I need it in C++, please. Writing with comments so it maybe cleared. 1.2. We received the following ciphertext which was encoded with a shift cipher: xultpaajcxitltlxaarpjhtiwtgxktghidhipxciwtvgtpilpit ghlxiwiwtxgqadds. 1. Perform an attack against the cipher based on a letter frequency count: How many letters do you have to identify through a frequency count to recover the key? What is...
arduino c code only write a code that counts down a timer on serial monitor and...
arduino c code only write a code that counts down a timer on serial monitor and if A1 is typed into serial monitor prints the timer counting down and writes at 1 second hello and at 5 secs goodbye and repeats every 5 secs A2 is typed as above at 2 seconds writes hello and 3 seconds writes goodbye A3 same as above but at 3 seconds says hello and 2 seconds goodbye This continues until c is pressed to...
Create a code showing Arduino IMU data being plotted by your Python code.  
Create a code showing Arduino IMU data being plotted by your Python code.  
Write a Class called Module with the following attributes: module code, module name, list of lecturers...
Write a Class called Module with the following attributes: module code, module name, list of lecturers for the module (some modules may have more than one lecturer – we only want to store their names), number of lecture hours, and module description. Create a parameterised (with parameters for all of the class attributes) and a non-parameterised constructor, and have the accessor and mutator methods for each attribute including a toString method. Write a class Student with the following attributes: student...
I need an original matlab code and gui for a simple double pendulum. This needs to...
I need an original matlab code and gui for a simple double pendulum. This needs to be original and not too complicated. Please provide basic instructions. Thank you!
Need to code this is assembly language. Using the windows32 framework, write a procedure to read...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT