I am trying to make a performance monitor, I wrote a program in C# that reads the usage of my RAM, then it is sent by Serial port to my arduino uno. The arduino programs displays is it on a LCD screen.
So I recieve the data from the serial port and save it to a char variable, which then is displayed on the LCD, hower it does not do it correctly.
It always displays only the last number of the usage, lets say the usage is 87%. It gets sent to the board and only displays the 7 from 87. If the usage changes lets say to 85, it only displays the 5.
I have spent alot of time trying to fix this, but nothing I did fixed this issue.
So I wanted to ask if any of you guys could help me!
The code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
int menuButton = 12;
void setup ()
{
Serial.begin(9600);
lcd.begin (16, 2);
pinMode(menuButton, INPUT_PULLUP);
MainScreen();
}
void loop ()
{
if (!digitalRead(menuButton))
{
tone(9, 330, 75);
UpdateScreen();
_delay_ms(1000);
PerformanceMenu();
while(!digitalRead(menuButton));
}
}
void MainScreen()
{
lcd.setCursor(5, 0);
lcd.print("READER");
lcd.setCursor(6, 1);
lcd.print("1.2.");
}
void PerformanceMenu ()
{
lcd.clear();
lcd.print("RAM:");
if (Serial.available())
{
delay(100);
}
while (Serial.available()>0)
{
char i = Serial.read();
lcd.setCursor(4,0);
lcd.print(i);
}
}
void UpdateScreen ()
{
lcd.clear();
lcd.setCursor(3,0);
lcd.print("PERFORMANCE");
lcd.setCursor(6,1);
lcd.print("MENU");
}