Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5565

String Subset from Serial error

$
0
0

Hi Everyone

I have  a simple program. I have used arduino to tranfer some string to labview.

And In Labview I want to Subset string. But, It is working only first string and the later strings not be subset.

Can you help me find my error?

Thank for reading

Here is my code and my error

serial.png

 

Here is my Video: https://www.youtube.com/watch?v=Gm5nOrZ3iyo

Here is my arduino code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int i=0;
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
{
  lcd.init();    // initialize the lcd
  Serial.begin(9600);
 // attachInterrupt(0,irt1,CHANGE);
  attachInterrupt(1,irt2,FALLING);
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
  Serial.print("Hello, world\n");
  delay(1000);
  lcd.clear();
}

void loop()
{

  while(Serial.available())
  {
  char r = (char) Serial.read();
  if(r=='t')
  {
    lcd.setCursor(0,0);
  lcd.print("you are robot");  
 // Serial.print("you are robot\n");
  }
  else if (r='a')
  {
    lcd.setCursor(0,0);
    lcd.print("you are human");  
   // Serial.print("you are human\n");
  }
  }
}

void irt2()
{
  delay(1500);
  i++;
  if(i%2)
 { Serial.print("ngaysinh010071992\n");}
  else
  {Serial.print("ngaysinh123455\n");}
}


Viewing all articles
Browse latest Browse all 5565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>