-1

Having in my visual basic app something like:

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        *whatever* value = serialPort1.Read*whatever*();
    }

Suppose my Arduino sends in every loop, the value read by a photoresistor. Suppose my Arduino also sends a 0 if certain led is LOW or a 1 if certain led is HIGH. Finally suppose my Arduino also sends a value that is equal to the number of times the loop has been executed.

In the 25th execution, lets suppose my Arduino sends something like:

Serial.write(LED_state) // 0 or 1 for LOW or HIGH
Serial.write(photoresistor_value) //lets suppose 25
Serial.write(loop_number) //25 

Question: if all the values are sent using Serial.write or Serial.print, and all values are ints, how can I distinguish in my app if the value 25 received belongs to the photoresistor or to the loop? Is there any way to send something like (key, value) from Arduino so I can distinguish between the ints received so I can assign them correctly to my app variables?

closed as off-topic by per1234, sempaiscuba, gre_gor, Greenonline, MatsK Jan 8 at 13:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – per1234, sempaiscuba, gre_gor, Greenonline, MatsK
If this question can be reworded to fit the rules in the help center, please edit the question.

2

Is there any way to send something like (key, value)

Sure:

Serial.print("LED state: ");
Serial.println(LED_state);

You will have to modify your VB code to parse that.

Not the answer you're looking for? Browse other questions tagged or ask your own question.