Hello,
I'm trying to create a program in Visual Basic (2010) that would let me control leds connected to my Arduino board.
I use 3 different digital outputs for 3 different leds. However the issue I currently have is that for example when I turn on led1 all 3 of the leds would turn on, so basicly it writes the same command to all 3 of the outputs instead of doing so separately.
I suspect my error to be in the Arduino code rather than my Visual basic code, because I've only been using Arduino for a week.
This is the code I used:
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600)
;pinMode(12,OUTPUT);
Serial.begin(9600)
;pinMode(11,OUTPUT);
Serial.begin(9600)
;}
void loop() {
int val;
if (Serial.available()){
delay(100);
while (Serial.available() > 0) {
val=Serial.read();
if(val=='1') {digitalWrite(13,HIGH); }
else if (val=='0') {digitalWrite(13,LOW); }
if(val=='1') {digitalWrite(12,HIGH); }
else if (val=='0') {digitalWrite(12,LOW); }
if(val=='1') {digitalWrite(11,HIGH); }
else if (val=='0') {digitalWrite(11,LOW); }
}
}
}
Hopefully someone can help me out on this, thanks