Serial to VBA Best solution
hey everyone,
i have started using arduino , 1 of first things wanted link knowledge of vba arduino.
i spent hours , hours researching serial communications vba.
the more researched harder task seemed.
firstly, googled vba serial comm , found pricey "shareware" solutions.. lol next
secondly, tried seemingly common method of mscomm32.ocx
it hard find install process found it,
http://www.youtube.com/watch?v=fhh5pofrt48
the next issue mscomm how use it.
i not use in normal module , beleive had make form correct activex form buttons (which not find).
ie not work.
i went around in cirlces , thought there has better way.
thirdly, found huge opensource vb code supposedly used api??
i dont understand happening there , did not want update/ try , understand huge code.
the last thing did find solution
.
binary access files!!!
arduino code:
this creates sin curve when recevied , "stop"
vba code:
my coding little adhoc , im open suggestions (still newb)
i havnt played delay or baud rate
enjoy
i have started using arduino , 1 of first things wanted link knowledge of vba arduino.
i spent hours , hours researching serial communications vba.
the more researched harder task seemed.
firstly, googled vba serial comm , found pricey "shareware" solutions.. lol next
secondly, tried seemingly common method of mscomm32.ocx
it hard find install process found it,
http://www.youtube.com/watch?v=fhh5pofrt48
the next issue mscomm how use it.
i not use in normal module , beleive had make form correct activex form buttons (which not find).
ie not work.
i went around in cirlces , thought there has better way.
thirdly, found huge opensource vb code supposedly used api??
i dont understand happening there , did not want update/ try , understand huge code.
the last thing did find solution
![tongue :p](https://forum.arduino.cc/smileys/arduino/tongue.gif)
binary access files!!!
arduino code:
this creates sin curve when recevied , "stop"
code: [select]
int x = 0;
int row = 0;
string sreceived = "";
string stop = "stop";
void setup() {
serial.begin(9600);
}
void loop() {
if((serial.available()))
{
serial.print("x,sin(x),");
while(!sreceived.equals(stop))
{
serial.print(x);
serial.print(",");
serial.print(sin(x*pi/180));
serial.print(",");
row++;
x++;
delay(100);
if(serial.available() > 0) sreceived = serial.readstring();
}
row = 0;
x = 0;
sreceived = "";
}
}
vba code:
code: [select]
sub fetcharduino()
dim sgetchar string
dim sgetstring string
dim x integer
dim y integer
dim xnum integer
dim ynum integer
sendval = "1" 'a string send
open "com3" binary access read write #1 ' magic
put #1, , sendval 'put sends data
cgetchar = input(1, #1)
x = 0
y = 0
xnum = 2
ynum = 150
while (x <> ynum)
y = 0
x = x + 1
while (y <> xnum)
while (cgetchar <> ",")
cgetstring = cgetstring + cgetchar
cgetchar = input(1, #1) 'get next character
wend
y = y + 1
cells(x, y) = cgetstring 'put response in cell
cgetstring = ""
cgetchar = ""
wend
wend
put #1, , "stop"
close #1
my coding little adhoc , im open suggestions (still newb)
i havnt played delay or baud rate
enjoy
you find home @ windows powershell script.
http://newsofthewolf.wordpress.com/2009/09/25/powershell-and-arduino/
http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.aspx
quote
$port= new-object system.io.ports.serialport com3,9600,none,8,one #opens serial port - adjust parameters accordingly
$port.open() #opens serial connection
$port.write("hello world") #writes content serial connection
$port.close() #closes serial connection
http://newsofthewolf.wordpress.com/2009/09/25/powershell-and-arduino/
http://blogs.msdn.com/b/powershell/archive/2006/08/31/writing-and-reading-info-from-serial-ports.aspx
Arduino Forum > Using Arduino > Interfacing w/ Software on the Computer > Serial to VBA Best solution
arduino
Comments
Post a Comment