hi, I'm a newbie in arduino programation en C too (done it 20 years ago at school lol). I've made a plugins for X-plane to send data over usb and the arduino have to pick up this info and screen on lcd information.
That works but for that I need to popin the serial monitor. indeed if I do not start it, the information not work !!! why ?
For exemple I send over usb from mac to arduino these words :"Speedbrake Arm" or "Speedbrake Full".
the result should on my lcd 20*2 Speedbrake Arm or Speedbrake Full, depend on what are send to usb.
It works but I have to start the arduino screen usb monitor.
Indeed I must start he serial monitor screen of the arduino, then send Speedbrake Arm; the lcd shows Arm well.
But then to show Full I must close the serial monitor and restart it then when I send Speedbrake Full then full is print on my lcd correctly.
do you know why? do you have a clue ?
thanks in advance
ounet
Here we are my code
#include <stdio.h>
#include <string.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int ledPin = 13;
char indata[30];
int count = 0;
void setup ()
{
pinMode(ledPin,OUTPUT);
Serial.begin(115200);
lcd.begin(20, 2);
lcd.setCursor(0, 0);
lcd.print("Speed Brake Value");
}
void loop()
{20
digitalWrite(ledPin,LOW);
while (Serial.available() > 0)
{
char incomingByte = Serial.read ();
if(count < 29)
{
indata[count] = incomingByte;
count ++;
indata[count] = '\0';
}
}
if ( strcmp (indata,"Speedbrake Full") == 0)
{
//Serial.println("full");
lcd.setCursor(0, 1);
lcd.print("Speedbrake Full");
digitalWrite(ledPin,HIGH);
delay(2000);
digitalWrite(ledPin,LOW);
count =0;
indata[count] = '\0';
}
if ( strcmp (indata,"Speedbrake Arm") == 0)
{
//Serial.println("arm");
lcd.setCursor(0, 1);
lcd.print("Speedbrake Arm");
digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
delay(1000);
digitalWrite(ledPin,HIGH);
count =0;
indata[count] = '\0';
}
indata[count] = '\0';
}