I'm new for both software.
I want to input a number and click a button in VB, so that it gives data to Arduino.
Can someone give me any hint? or a simple example? ![]()
Most Arduinos communicate with a PC over a serial connection through a USB port. Most languages have hooks for Serial interface (Python, PERL, Java, C, etc), so I'm sure VB will be able to talk to an Arduino this way. As a matter of fact, Googling "visual basic arduino serial communication" gives a whole lot of hits, including tutorial videos.
Have a look at Serial Input Basics. If you can designe your system like example 3 it will be most reliable.
...R
Hey, Lufan76, you can use something like this:
char val; // variable to receive data from the serial port
int ledpin = 13; // LED connected to pin 13 (on-board LED)
void setup()
{
pinMode(ledpin, OUTPUT); // pin 13 (on-board LED) as OUTPUT
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
}
if( val == 'H' ) // if 'H' was received
{
digitalWrite(ledpin, HIGH); // turn ON the LED
}
if( val == 'L' ) // if 'H' was received
{
digitalWrite(ledpin, LOW); // turn OFF the LED
}
delay(100); // wait 100ms for next reading
}
If u open Serial Monitor and type H pin 13 state will be high, type L will make it low. After that you can send characters from VB and controll it. It will be better if you use numbers.