Hi,
for a slot car track i measure the speed witch 2 arduino nano.
they are connected via rx/tx
they do the calculations indipendently and the tx sends the datas to the rx who is connected to a lcd.
the datas from tx are right (as per ser mon on tx arduino) but shit is shown on the lcd.
the image shows the top speed per track in the upper line and the actual speed in the lower line...
what is wrong???
HolgeR
tx code:
void setup()
{
Serial.begin(9600);
attachInterrupt(0, Starten,FALLING);
attachInterrupt(1,Stoppen,FALLING);
}
void loop()
{
if ((counter2==counter1))T=Zeit2-Zeit1;
V=3600.0*l/T;
if (V>10000)V=0;
Serial.println(V,2);
delay(1000); //Abbruch der Messung
counter2=counter1;
}
void Starten(){
Zeit1=micros();
counter1++;
}
void Stoppen(){
Zeit2=micros();
counter2++;
}
rx code:
void loop()
{
if ((counter2==counter1))T=Zeit2-Zeit1;
VL=3600.0*l/T;
if (VL>10000)VL=0;
VL1=max(VL,VL1);
lcd.setCursor(0,0);
if(VL1<100) lcd.print(" ");
if(VL1<10) lcd.print(" ");
lcd.print(VL1,2);
lcd.setCursor(0,1);
if(VL<100) lcd.print(" ");
if(VL<10) lcd.print(" ");
lcd.print(VL,2);
//hier der Empfängerteil
if (Serial.available()> 0)
{
delay(100);
while (Serial.available() > 0) {
VR = (Serial.read());
Serial.println(VR,2); // just to read back the received datas via ser mon on rx arduino
//A= Serial.read()-48;
//B= Serial.read()-48;
//C= Serial.read()-48;
//D= Serial.read()-48;
//VR=100A+10B+1*C;
if (VR >10000)VR=0;
VR1=max(VR,VR1);
lcd.setCursor(9,0);
if(VR1<100) lcd.print(" ");
if(VR1<10) lcd.print(" ");
lcd.print(VR1,2);
lcd.setCursor(9,1);
if(VR<100) lcd.print(" ");
if(VR<10) lcd.print(" ");
lcd.print(VR);
}}