Go Down

Topic: vb6 ? (Read 4271 times) previous topic - next topic

Kuchi

hi
i want to on/off led on pin 13
how i do this ?
i don't find nothing on google or on the forum
pleas help
and i need it to visual basic 6 not net ...

thanks !

PaulS

Does VB6 provide any way to communicate with the serial port?

Kuchi

#2
Jan 01, 2010, 09:37 pm Last Edit: Jan 01, 2010, 09:44 pm by Kuchi Reason: 1
yes
Code: [Select]
Private Sub Command1_Click()
'TRANSMIT
MSComm1.Output = "0"
End Sub

Private Sub Form_Load()
'SETUP
With MSComm1 'sets up COM settings
.Handshaking = 0
.RThreshold = 0
.RTSEnable = False
.CommPort = 5
.Settings = "115200,n,8,1"
.SThreshold = 0
.PortOpen = True
End With
End Sub


but i want to do pin 13 to on/off leds and not work ...

PaulS

What code do you have running on the Arduino?

Kuchi


PaulS

Well, then, there's your problem. You've got to have some code running on the Arduino to pay attention to the serial data you are sending it. That doesn't happen automatically.

Kuchi

what i need to put on the ardiuno ?
and thanks !
you have a guide that what i need to put on the ardiuno and in VB6 ?

TRON007

You need to write a program to put in your arduino that listens to the serial port for commands and have the commands interpreted. The place you should start is actually by making the LED on pin 13 blink by itself, a "Hello World!" program of sorts for the arduino platform. Once you get the gasp of that then move onto more complicated things. The playground is the best place to start. All the basics are there.

Kuchi

thanks i do this and it's work !

in vb
Code: [Select]
Private Sub Command1_Click()
'TRANSMIT
MSComm1.Output = "1"
End Sub

Private Sub Command2_Click()
MSComm1.Output = "2"
End Sub

Private Sub Form_Load()
'SETUP
With MSComm1 'sets up COM settings
.Handshaking = 0
.RThreshold = 0
.RTSEnable = False
.CommPort = 5
.Settings = "9600,n,8,1"
.SThreshold = 0
.PortOpen = True
End With
End Sub


and to ardiuno
Code: [Select]
int ledPin =  13;
int incomingByte;
 
void setup() {
   Serial.begin(9600);
   pinMode(ledPin, OUTPUT);
}
void loop() {
        incomingByte = Serial.read();
        if (incomingByte == '1') {
             digitalWrite(ledPin, HIGH);
        }
                 if (incomingByte == '2') {
             digitalWrite(ledPin, LOW);
        }
}

PaulS

Excellent.

Now, get a servo and hook it up. Add a slider type control to the form, and nave the servo move as you drag the slider.

Or, change the LED to a PWM pin, and have it fade on and off in response to a slider movement.

Or, get a RGB LED and have the three colors change independently. Then, make all three change at once.

Add some kind of sensor, like a potentiometer, and read it's value from VB.

The possibilities are endless.

Kuchi

thanks :D

the Arduino Duemilanove 2009 AVR ATmega168-20PU
can connect to internet ? or what ? ...
if i want to on/off from a web what i need to do ?

PaulS

You could get an Ethernet shield, which allows the Arduino to directly connect to the internet. Or the VB app can (I think) act as go-between between the web application and the Arduino.

Kuchi

i do that the arduino check the internet file that i upload ....
and i control from my web ...

Go Up