arduino+vb6
hi!
can me please in right coding arduino , vb6...i find hard in communicating 2 devices arduino , vb6.
here code:
for arduino:
here vb code:
can me please in right coding arduino , vb6...i find hard in communicating 2 devices arduino , vb6.
here code:
for arduino:
code: [select]
void setup()
{
pinmode(9, output);
pinmode(10, output);
pinmode(11, output);
pinmode(12, output);
pinmode(2, input);
pinmode(3, input);
pinmode(4, input);
pinmode(5, input);
pinmode(7, output);
serial.begin (9600);
}
void loop()
{
int = digitalread (2);
int b = digitalread (3);
int c = digitalread (4);
int d = digitalread (5);
//digitalwrite (7,low);
{
if (a == high)
{
digitalwrite (9, high);
serial.println ("red color of led/ pressures value 20psi");
delay (200);
digitalwrite (7, high);
delay (400);
digitalwrite (7, low);
}
else if (a == low)
{
digitalwrite (9, low);
}
if (b == high)
{
digitalwrite (10, high);
serial.println ("green color of led/the pressures value 40psi");
delay (200);
digitalwrite (7, high);
delay (400);
digitalwrite (7, low);
delay (200);
digitalwrite (7, high);
delay (400);
digitalwrite (7, low);
}
else if(b==low)
{
digitalwrite (10, low);
}
if (c == high)
{
digitalwrite (11, high);
serial.println ("blue color of led/the pressures value 60psi");
delay (200);
digitalwrite (7, high);
delay (400);
digitalwrite (7, low);
delay (200);
digitalwrite (7, high);
delay (400);
digitalwrite (7, low);
delay (200);
digitalwrite (7, high);
delay (400);
digitalwrite (7, low);
}
else if (c==low)
{
digitalwrite (11, low);
}
if (d == high)
{
digitalwrite (12, high);
serial.println ("yellow color of led/the pressures value 80psi");
delay (200);
digitalwrite (7, high);
}
else if (d==low)
{
digitalwrite (12, low);
}
}
}
here vb code:
code: [select]
option explicit
private sub form_load()
mscomm1
if .portopen .portopen = false
.commport = 1
.settings = "19200,n,8,1"
.dtrenable = true
.rtsenable = true
.rthreshold = 4
.sthreshold = 3
.portopen = true
end with
shape1
shape1.shape = 3 'circle
shape1.height = 555
shape1.width = 555
shape1.fillcolor = vbwhite
shape1.fillstyle = 0 'solid
end with
end sub
private sub ledon(col long)
end sub
shape1.fillcolor = col
end sub
private sub ledoff()
end sub
shape1.fillcolor = vbwhite
end sub
private sub mscomm1_oncomm()
dim strdata string
static strbuffer string
dim strwords() string
dim intpos integer
dim bocomplete boolean
select case mscomm1.commevent
case comevreceive
strdata = mscomm1.input
strbuffer = strbuffer & strdata
do
intpos = instr(strbuffer, vbcrlf)
if intpos > 0 then
strwords = split(strbuffer, " ")
select case ucase(strwords(1))
case "a"
call ledon(vbred)
case "b"
call ledon(vbgreen)
case "c"
call ledon(vbblue)
case "d"
call ledon(vbyellow)
case else
call ledoff
end select
if intpos + 2 < len(strbuffer) then
strbuffer = mid(strbuffer, intpos + 2)
else
strbuffer = ""
bocomplete = true
end if
else
bocomplete = true
end if
loop until bocomplete = true
end select
end sub
1) first having same communication speed on both sides? (arduino uses 9600, vb uses 19200)
2) getting easier run first?
arduino sends
"red color of led/ pressures value 20psi"
your vb code seems draw colored circles controlled characters found in string
is intend ? (if got wrong, please tell code supposed do, , instead)
3) see while debugging vb code ?
4)
imo ucase() never return lower case character.
2) getting easier run first?
arduino sends
"red color of led/ pressures value 20psi"
your vb code seems draw colored circles controlled characters found in string
is intend ? (if got wrong, please tell code supposed do, , instead)
3) see while debugging vb code ?
4)
quote
code: [select]select case ucase(strwords(1))
case "a"
call ledon(vbred)
imo ucase() never return lower case character.
Arduino Forum > Using Arduino > Interfacing w/ Software on the Computer > arduino+vb6
arduino
Comments
Post a Comment