Go Down

Topic: Visual Basic 2005: Reset (Read 393 times) previous topic - next topic

Speedway

Hello guys,

I managed to get a connection between my Arduino Diecimila and Visual Basic 2005. I use 3 push buttons to send data to Visual Basic, that was no problem. Now I need something how to reset my board, I made this Arduino code:

Code: [Select]
int inPin5 = 3;
int inPin6 = 5;
int inPin7 = 7;

int val5    = 0;
int val6    = 0;
int val7    = 0;

int delay5  = 0;
int delay6  = 0;
int delay7  = 0;

void setup() {
 pinMode(inPin5, INPUT);
 pinMode(inPin6, INPUT);
 pinMode(inPin7, INPUT);
 
 Serial.begin(9600);
}

void loop() {
 val5 = digitalRead(inPin5);
 val6 = digitalRead(inPin6);
 val7 = digitalRead(inPin7);
 
 if (val5 == HIGH) {
    if (delay5 == 0) {
      Serial.println("Gat5");
      delay5++;
    }
 }
 if (val6 == HIGH) {
    if (delay6 == 0) {
      Serial.println("Gat6");
      delay6++;
    }
 }
 if (val7 == HIGH) {
    if (delay7 == 0) {
      Serial.println("Gat7");
      delay7++;
    }
 }
}

void reset() {
 delay5  = 0;
 delay6  = 0;
 delay7  = 0;  
}


I can send data to my Arduino, but how can I execute the function: reset(); ? What do I have to send to my Arduino ?

Thanks,
Jesper

MikMo

If i understand your post correctly, you want to send something from your VB program that will make your Arduino program's reset() function run ?

You can't directly control Arduini code from the VB program. But you can send for instance a single char. like "R"
and then in the main loop in your Arduino program use the serialavailable() function to check if data is present in the input buffer. If data is ready read it and check if it is "R"and then call your Reset() function.

Hope this makes sense

trialex

Yep check out the "physical pixel" example code - it's built right into the Arduino IDE!

Of course you wont use the processing code to send data to your arduino, but rather write your own VB code. the example arduino code should be what you are looking for though.

Go Up