Serial Writting

Hi all, i am using a simple vb script to write to an arduino board, ie live commands
SerialPort1.Open()
SerialPort1.Write("1")
SerialPort1.Close()
what im trying to do is have the written commands from the vb program turn on a digital pin
this is my attempt in the arduino sketch book

Opening the serial port resets the Arduino.
Closing the serial port resets the Arduino.

If you are executing those commands in a script, with no delay between, don't expect the Arduino to actually do anything.

this is my attempt in the arduino sketch book

You need more code than that. You need at least a setup() and loop() functions.

sry forum cut me off didnt know it posted

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(13, OUTPUT);
}

void loop() {
int incomingByte;
incomingByte = Serial.read();
if (incomingByte=="1"{
digitalWrite(13,HIGH);
delay(1000);
}

Come on back when you have a sketch that will compile.

You need to check the difference between a character (single quotes) and a string (double quotes)

 int incomingByte; incomingByte = Serial.read();

I've never really understood this style of programming

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(13, OUTPUT);
}

void loop() {
int incomingByte;
incomingByte = Serial.read();
if (incomingByte==1){
digitalWrite(13,HIGH);
delay(1000);
}

}

Still not right. Read AWOL's comment again.

thank you guys, been a while since ive programmed in java forgot that difference, its working :slight_smile:

thank you guys, been a while since ive programmed in java forgot that difference, its working

Unless you are doing that somewhere else, the timer hasn't reset. The Arduino is programmed in C++.