Tarea 1111
Tarea 1111
h>
void setup ()
{
Serial.begin (115200);
Wire.begin();
Wire.setClock(4000000);
Wire.beginTransmission(0x68);
Wire.write(0x6b);
Wire.write(0x0);
Wire.endTransmission(true);
}
int throttle = 0;
void loop()
{
Wire.beginTransmission(0x68);
Wire.write(0x45);
Wire.endTransmission(false);
Wire.requestFrom(0x68,2, true);
int16_t GyYH = Wire.read();
int16_t GyYL = Wire.read();
int16_t GyY = GyYH <<8 |GyYL;
if(Serial.avaible()>0)
{
while(Serial.avaible()>0)
{
char userInput = Serial.read();
if(userInput >='0' && userInput <='9')
{
throttle = (userInput-'0')*25;
Serial.println(userInput);
}
}
}
analogWrite(6, iSpeedA);
analogWrite(10, iSpeedB);
analogWrite(9, iSpeedC);
analogWrite(5, iSpeedD);
void setup ()
{
Serial.begin (115200);
Wire.begin();
Wire.setClock(4000000);
Wire.beginTransmission(0x68);
Wire.write(0x6b);
Wire.write(0x0);
Wire.endTransmission(true);
}
int throttle = 0;
void loop()
{
Wire.beginTransmission(0x68);
Wire.write(0x45);
Wire.endTransmission(false);
Wire.requestFrom(0x68,2, true);
int16_t GyYH = Wire.read();
int16_t GyYL = Wire.read();
int16_t GyY = GyYH <<8 |GyYL;
double Kd =1.0;
BalY += Kd*-GyYR;
if(throttle ==0) BalY =0.0;
if(Serial1.avaible()>0)
{
while(Serial1.avaible()>0)
{
char userInput = Serial1.read();
if(userInput >='0' && userInput <='9')
{
throttle = (userInput-'0')*25;
}
}
}
analogWrite(6, iSpeedA);
analogWrite(10, iSpeedB);
analogWrite(9, iSpeedC);
analogWrite(5, iSpeedD);