I hope not being scolded but can’t find reference to my problem…
I want to let a motor turn right left or stop it depending on heading.
It seems the functions RotateMotorRight, RotateMotorLeft and MotorStop) are not being called, but why ?
Any constructive comments are welcomed !
here the partial code:
float angle = heading * 180/M_PI;
Winkel= (int)angle;
//=============================================================================================================
if (Winkel << HeadingToMobil) // WHY void MotorRotateRight or Left or Stop are not called ???
MotorRotateRight; //
// WWWWWW
if (Winkel >> HeadingToMobil) // WW WWW
MotorRotateLeft; // WWW
// WWW
if (Winkel == HeadingToMobil) // WWW
MotorStop; // WWW WW
// WWWWWW
//
// WWW
// WWW
//==============================================================================================================
Serial.print(" Heading: ");
Serial.println(angle);
}
else
{
Serial.println("=Compass Failed=");
}
delay(500); // Run again in .5 s (500 ms)
}
int ReadByte(uint8_t addr, uint8_t reg, uint8_t *data) // Read a byte on the i2c interface
{
Wire.beginTransmission(addr); // Do an i2c write to set the register that we want to read from
Wire.write(reg);
Wire.endTransmission();
Wire.requestFrom(addr, (uint8_t)1); // Read a byte from the device
if (Wire.available())
{
*data = Wire.read();
}
else
{
return -1; // Read nothing back
}
return 0;
}
void WriteByte(uint8_t addr, uint8_t reg, byte data) // Write a byte on the i2c interface
{
Wire.beginTransmission(addr); // Begin the write sequence
Wire.write(reg); // First byte is to set the register pointer
Wire.write(data); // Write the data byte
Wire.endTransmission(); // End the write sequence; bytes are actually transmitted now
}
void MotorRotateLeft()
{
digitalWrite(MotorPinRight,LOW);
delay(10);
digitalWrite(MotorPinLeft,HIGH);
}
void MotorRotateRight()
{
digitalWrite(MotorPinLeft,LOW);
delay(10);
digitalWrite(MotorPinRight,HIGH);
}
void MotorStop()
{
digitalWrite(MotorPinRight,LOW);
digitalWrite(MotorPinLeft,LOW);
}