Hi,
Im trying to use a LGT8 in a ebike controller as a DAC and other functions communicating through I2C.
I cant seem to find reference to processing words or characters etc.
as int SPEED=255;analogWrite(SPEED, Val); through I2C.
This is the code ive got working on the master but was wanting advice on other ways to do it.
void receiveEvent(int howMany)
{
while (1 < Wire.available())
{
PIN = Wire.read();
//Serial.print(PIN);
}
VALUE = Wire.read();
if (PIN ==83){Serial.print("Speed"); analogWrite(3,VALUE);Serial.print("=");Serial.println(VALUE);Serial.println();}
if (PIN==66 && VALUE==76){Serial.print("BRAKE"); digitalWrite(BRAKE,HIGH);Serial.print("=");Serial.println("HIGH");Serial.println();}
if (PIN==66 && VALUE==72){Serial.print("BRAKE"); digitalWrite(BRAKE,LOW);Serial.print("=");Serial.println("LOW");Serial.println();}
if (PIN==68 && VALUE==76){Serial.print("FORWARDs"); digitalWrite(DIRECTION,HIGH);Serial.print("=");Serial.println("HIGH");Serial.println();}
if (PIN==68 && VALUE==72){Serial.print("REVERSE"); digitalWrite(DIRECTION,LOW);Serial.print("=");Serial.println("LOW");Serial.println();}
}