Character and String

Hi everyone,
I made a program in VB that controls the LED lamps connected in arduino . I used an usb A-B cable for serial communication between the pc and the arduino.

however, something's wrong whenever I use the Char data type when declaring the variable which will be sent to the Arduino as serial data (DEC) . the LED switching is not operational whenever I use the Char.

Then I changed it to STRING data type and suddenly worked .
But whenever I change the (Dim y As Char) the led is not blinking.

Please kindly explain why ''''char''''' doesn't seem to work.

string and char.zip (147 KB)

Is this an Arduino or a VB question ?
Let's see some real code that does not work so that we know what you are talking about.

What do you see if you print what you receive on the Arduino ?

By the way, Serial.flush() does not empty the Arduino serial receive buffer so you might just as well not use it in your program.

    if (f == 55) { //55 (DEC) = 7 (ASCII character)

You could ditch the useless comments:

if(f == '7')
{
        SerialPort1.Open()
        SerialPort1.Write(s)
        SerialPort1.Close()

Opening the serial port resets the Arduino. Closing it may reset the Arduino, too. You need to open the port ONCE, not every time you want to send data.