Arduino Vb.net Button Problem

Hello friends, Im developing a project with arduino and vb.net , at the begining project was looking quite easy to complete but now i have problem with buttons, In summary , when i push to psychical button , it increases (1,2,3)the value in textbox which located in windows form. i can get the data from arduino with this way for 1 button and textbox but my biggest problem is Arduino will have 3 different pychical buttons and each buttons will send datas to 3 different textboxes, how can i ensure to get datas to different textboxes in windows form ? Could you please help ? Thank you

but my biggest problem is Arduino will have 3 different pySical buttons and each buttons will send datas to 3 different textboxes

If I understand you, Arduino button #1 has 3 text boxes, 1, 2, 3. This is repeated for button #2 and #3. Therefore you have 3 physical buttons and 9 text boxes.

A way to fo this is to assign phases to each button: Phase 1 and Phase 2. Phase 1 involves a long-press and Phase 2 involves a short-press.

Example: Button #2 is long-pressed (> 500mS). A LED lights to indicate Phase 1 has been activated. Now, a short press on any of the 3 buttons will select the associated PC box. The LED is extinguished to show completion and the logic returns waiting for a long-press ... in this state, a short-press on Any button is ignored.

You can extend this short, long-press scenario to 3 or 4 phases before it gets very difficult. Example:

0 mS - 499 mS ignore 500 mS - 999 mS Phase 1 1000 mS - 1499 mS Phase 2 1500 mS - 1999 mS Phase 3

LEDs for each Phase helps the human to avoid confusion. Phsse 1 ----> Phsse 2 -----> Phase 3 -----> clear -----> Phase 1 ...

You could add a CLEAR button if desired instead of the extended presses sbove.

Good luck. Review how software button debounce is implemented!!!

Ray

What does your sketch send to the VB program, right now?

In general you'll have to send different messages to the VB program, for every button, and decode there which button was pressed, and what to do consequently.

mrburnette:
If I understand you, Arduino button #1 has 3 text boxes, 1, 2, 3. This is repeated for button #2 and #3. Therefore you have 3 physical buttons and 9 text boxes.

Hello !

No, button and textbox numbers are equal, 3 button and 3 textboxes,

DrDiettrich:
What does your sketch send to the VB program, right now?

In general you’ll have to send different messages to the VB program, for every button, and decode there which button was pressed, and what to do consequently.

Exactly what i should do but how ? At vb.net code how can i read data from different buttonpins ? Because im only using

comport1.ReadLine() code.

My sketch code below;

const int buttonPin = 2;

int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

void setup() {

pinMode(buttonPin, INPUT);

Serial.begin(9600);

}

void loop() {

buttonState = digitalRead(buttonPin);

if (buttonState != lastButtonState) {

if (buttonState == HIGH) {

buttonPushCounter++;

Serial.println(buttonPushCounter);
} else {

}

delay(50);
}

lastButtonState = buttonState;

if (buttonPushCounter % 4 == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}

}

Thank you for support.

Use ascii and use a simple code, something like 1,1,2,3. You can then split the received data in VB.

The 1st property is the button pressed, the 2nd property is the value to go in to the first text box, the 3rd property is the value to go in to the second text box, and finally, the 4th property is the value to go in to the third text box.

It would also help to use start and end markers. Have a look at https://forum.arduino.cc/index.php?topic=288234.0, especially the start and end marker function. The first example in the second post.

The example arduino-and-visual-basic-part-2-receiving-data-from-the-arduino-part-2 uses a version of the start and end marker function in VB and you should be able to modify it to suit your needs.

MartynC:
Use ascii and use a simple code, something like 1,1,2,3. You can then split the received data in VB.

The 1st property is the button pressed,
the 2nd property is the value to go in to the first text box,
the 3rd property is the value to go in to the second text box, and finally,
the 4th property is the value to go in to the third text box.

It would also help to use start and end markers. Have a look at https://forum.arduino.cc/index.php?topic=288234.0, especially the start and end marker function. The first example in the second post.

The example arduino-and-visual-basic-part-2-receiving-data-from-the-arduino-part-2 uses a version of the start and end marker function in VB and you should be able to modify it to suit your needs.

Yes but im using 3 different button ! i think i should learn how to get data from different buttons to vb.net ?

(deleted)

Please edit your posting and enclose the code in code tags </>.

Until now you transmit the button press count. Add or replace it by the button number, so that your VB program can know which button is pressed. If you also want to send when a button is released, add another character to indicate pressed or released.