usb communication


hi, i'm newbie in arduino programation en c (done 20 years ago @ school lol). i've made plugins x-plane send data on usb , arduino have pick info , screen on lcd information.
that works need popin serial monitor. indeed if not start it, information not work !!! why ?

for exemple send on usb mac arduino these words :"speedbrake arm" or "speedbrake full".

the result should on lcd 20*2 speedbrake arm or speedbrake full, depend on send usb.

it works have start arduino screen usb monitor.

indeed must start serial monitor screen of arduino, send speedbrake arm; lcd shows arm well.

but show full must close serial monitor , restart when send speedbrake full full print on lcd correctly.

do know why? have clue ?

thanks in advance

ounet

here 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';
}

quote
i've made plugins x-plane send data on usb , arduino have pick info , screen on lcd information.
that works need popin serial monitor.


what x-plane? how communicate serial port?

when open serial monitor, com port arduino listens bound to. no other application can use same com port.

these last 2 lines of code.
code: [select]
indata[count] = '\0';
}

the same value being overwritten many times per second. statement unnecessary.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > usb communication


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums