Hello
I am hoping you can assist me as well when you have the time. I will probably start a new topic on this.
I have a somewhat similar problem. I am sending data from my Arduino to my application, but it looks as though the app is not receiving the data packages correctly, or I have not conditioned it to do so properly. For example I will send 127.9 to the app, and at first it will read the whole number, then when I send a different value to replace that one, it displays the data almost as though it is scrolling across the screen, .9 --> 7.9 ---> 27.9 ---> 127.9 --->.9 and then it just stays as .9 until I send in a different value. What I need is for the value to display fully every time.
NB, this is for a coin acceptor. So when the person enters a coin, the value of the coin is subtracted from CreditDue and then CreditDue is sent to the app to be displayed.
void CreditCounter(float CreditDue)
{
float CreditAmountStorage = 0;
while(CreditInserted < CreditDue)
{
i=i+1;
Serial.println(CreditDue);
if (i >= 30 and impulsCount == 1){CreditInserted = CreditInserted + 0.2; impulsCount = 0; EEPROM.put(0, CreditInserted);}
delayMicroseconds(2);
if (i >= 30 and impulsCount == 2){CreditInserted = CreditInserted + 0.5; impulsCount = 0; EEPROM.put(0, CreditInserted);}
delayMicroseconds(2);
if (i >= 30 and impulsCount == 3){CreditInserted = CreditInserted + 1; impulsCount = 0; EEPROM.put(0, CreditInserted);}
delayMicroseconds(2);
if (i >= 30 and impulsCount == 4){CreditInserted = CreditInserted + 2; impulsCount = 0; EEPROM.put(0, CreditInserted);}
delayMicroseconds(2);
if (i >= 30 and impulsCount == 5){CreditInserted = CreditInserted + 5; impulsCount = 0;}
delayMicroseconds(2);
if(CreditInserted > 0){CreditDue = CreditDue - CreditInserted; CreditInserted = 0; break;}/*Reduces outstanding amount by amount inserted and
zeros the amount inserted variable to prevent the code from deducting the inserted amount with every cycle of the while loop.*/
}
}