Receiving data from Arduino

Hello guys,
l've almost done my project of "switcher". My project has 2 possibilities of using.
First is about using 4 buttons connected to aruduino.
Second is VS Apllication

My problem is about that if im going to use arduino through serialport "VS App" while connecting i want to read actuall state of button. If I've set 3rd button i want to send data and make my 3rd button set in application. I've tried much things still it doesn't works....

Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3E, 16, 2);  // Ustawienie adresu ukladu na 0x26 bo PCF8574
 
 


 
 
boolean debug = true;
 
// length of command is 20 chrs
// if you need longer commands then increase the size of numChars
const byte numChars = 20;
char receivedChars[numChars];
 
boolean newData = false;
 

 

 
boolean feedback = true;
 
int circle_swith = 0;
int circle_swith_old = 0;
int loops = 0;
char title[7] ={'S', 'Q', '7', 'B', 'C', 'N', 'o'}; 
void setup() 
{
//piny----------------------------------------------------------------------------
  lcd.begin();                      
  lcd.setBacklight(LCD_BACKLIGHT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT); 
 
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(11, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);

  pinMode(6, OUTPUT);
  pinMode(14, OUTPUT);
 // pinMode(11, INPUT_PULLUP);
  //pinMode(12, INPUT_PULLUP); 

//--------------------------------------piny-------------------------  
   
 
     Serial.begin(9600);
     sendStartMessage();
     lcd.clear();  
    lcd.printstr("Ant Selector");
    lcd.setCursor(0,1);
    
}
 
void loop() 
{
     if (Serial.available() > 0)     {  recvWithStartEndMarkers(); }
     if (newData) { parseData(); }

    








if(digitalRead(9)== LOW)
  circle_swith = 9;
 if(digitalRead(10)== LOW)
  circle_swith = 10;
 if(digitalRead(11)== LOW)
  circle_swith = 11;
 if(digitalRead(12)== LOW)
  circle_swith = 12;

  if(circle_swith != circle_swith_old)
 {
    lcd.clear();  
    lcd.printstr("Ant Selector");
    lcd.setCursor(0,1);
 

     switch (circle_swith) {
      
      
       case 9:
          lcd.clear();  
          lcd.printstr("   Antena 1");
          lcd.setCursor(0,1);
          lcd.printstr("    W3DZZ");
          digitalWrite(2, LOW);
          digitalWrite(3, HIGH);
          digitalWrite(4, HIGH);
          digitalWrite(5, HIGH);
          
        
        break;  
      
      
      case 10:
          lcd.clear();  
          lcd.printstr("   Antena 2");
          lcd.setCursor(0,1);
          lcd.printstr("   HexBeam");
          digitalWrite(2, HIGH);
          digitalWrite(3, LOW);
          digitalWrite(4, HIGH);
          digitalWrite(5, HIGH);
          
        break;
      case 11:
          lcd.clear();  
          lcd.printstr("   Antena 3");
          lcd.setCursor(0,1);
          lcd.printstr("   VertGP-30m");
          digitalWrite(2, HIGH);
          digitalWrite(3, HIGH);
          digitalWrite(4, LOW);
          digitalWrite(5, HIGH); 
        
        break;
      case 12:
          lcd.clear();  
          lcd.printstr("   Antena 4");
          lcd.setCursor(0,1);
          lcd.printstr("    B R A K");
          digitalWrite(2, HIGH);
          digitalWrite(3, HIGH);
          digitalWrite(4, HIGH);
          digitalWrite(5, LOW);
           
        break;
   
      default:
      lcd.clear();
        lcd.print("dupa");
        lcd.printstr("...#...");
     }

  circle_swith_old = circle_swith;
  loops++;
     
 }

 delay(10);


    

     
}
//========================================    






 
void sendStartMessage()
{

    
    
     lcd.printstr("   Ant Switcher");
     lcd.setCursor(0,1);
     lcd.printstr("     SQ7BCN     ");
     delay(1000);
     

     
 
     if (debug) { Serial.println("Debug is on"); }
           else { Serial.println("Debug is off"); }
    Serial.println(" "); 
}
 
 
    
void parseData()
{  
        newData = false;    
        if (debug) { Serial.println( receivedChars ); }    
 
        // HELLO
        // If the Arduino receives "HELLO" it sends "HELLO" back
        // This is used by the VB program to show it is connected
        
        
         if(digitalRead(9)== LOW)
          {
            Serial.write("Antena1"); 
          } 
        
        if (strcmp(receivedChars, "HELLO")  == 0)
        {
            
            Serial.println("HELLO");
            
        }
 
        if (strcmp(receivedChars, "START")  == 0)
        {
            sendStartMessage();
        }
     if (strcmp(receivedChars, "Antena1")  == 0)
        {
          lcd.clear();  
          lcd.printstr("   Antena 1");
          lcd.setCursor(0,1);
          lcd.printstr("    W3DZZ");
          digitalWrite(2, LOW);
          digitalWrite(3, HIGH);
          digitalWrite(4, HIGH);
          digitalWrite(5, HIGH);
          
        }
      if (strcmp(receivedChars, "Antena2")  == 0)
        {
          lcd.clear();  
          lcd.printstr("   Antena 2");
          lcd.setCursor(0,1);
          lcd.printstr("   HexBeam");
          digitalWrite(2, HIGH);
          digitalWrite(3, LOW);
          digitalWrite(4, HIGH);
          digitalWrite(5, HIGH); 
        }

      if (strcmp(receivedChars, "Antena3")  == 0)
        {
          lcd.clear();  
          lcd.printstr("   Antena 3");
          lcd.setCursor(0,1);
          lcd.printstr("   VertGP-30m");
          digitalWrite(2, HIGH);
          digitalWrite(3, HIGH);
          digitalWrite(4, LOW);
          digitalWrite(5, HIGH); 
        }

      if (strcmp(receivedChars, "Antena4")  == 0)
        {
          lcd.clear();  
          lcd.printstr("   Antena 4");
          lcd.setCursor(0,1);
          lcd.printstr("    B R A K");
          digitalWrite(2, HIGH);
          digitalWrite(3, HIGH);
          digitalWrite(4, HIGH);
          digitalWrite(5, LOW); 
        }

ss.jpg

I've tried much things still it doesn't works....

Gee, that's a shame.

If you told us what the program actually does, and how that differs from what you want, you'd get more than fake sympathy.

Your code is very raggedy and very hard to read. Please use the AutoFormat tool to present it consistently.

Also it is not complete. Post a complete program.

I can't see where your code reads switches or tries to send the state of the switches.

When you say " while connecting i want to read actuall state of button" do you mean that you just want this to happen once the first time that the connection with the serial port is made? OR did you mean to write "while connected ..."?

...R