VB and picaxe?

sciguy77

Member
Hi,

I'm trying to make an LED connected to a picaxe turn on when a button is clicked in Visual Basic. I have the LED hooked up, but now I have no Idea how to get the VB button to talk to the picaxe. Any pointers?

Thanks
 

sciguy77

Member
this is the exact instructable I was looking at before. I'm looking for some more bare bones simplified code like when button1 pressed high 1 low 2 or whatever. Can you give me a simpler example?

Sorry, I'm a beginner. :)
 

moxhamj

New Member
Break it down into components. In vb.net, add a button and a label. Change the label text when you click the button.

If that works, then add some code to send a byte out the serial port when you click the button.

On the picaxe side, write some code to flash a led.

Then change the serial line so it goes to a different pin (via the same 10k/22k network)

Then write some code to listen to that pin until your byte arrives. Then flash the led when this happens.

Do you have vb6 or vb.net?
 

sciguy77

Member
Uh, yeah, its the whole sending/receiving bytes that I don't get. Some simpler sample code would really be helpful if its not too much trouble.
 

moxhamj

New Member
so this also works the other way around? displaying variables from a picaxe?

Yes, it does. You can send data to a picaxe from vb.net and get data back. But it is a little complicated to set up.

Uh, yeah, its the whole sending/receiving bytes that I don't get

Ok, lets go back one step further.

Code:
b0=65
for b1=1 to 10
  debug
  pause 1000
next b1
Try running that. The picaxe debug will show the variables.

I don't know which picaxe chip you have, but assuming it is an O8M, put a led on physical pin 7 (output 0) and a 1k resistor to ground. Run that program again and the led should flash once a second. This led will be useful to see if data is going from the picaxe to the PC.

Next try
Code:
main:
  serout 0,N2400,("A")
  pause 1000
goto main
Your led should still be flashing again. Now, shut down the picaxe programmer software and start up a program like Hyperterminal. Set it up to read the serial port at 2400 baud and you should see AAAAA appearing on the screen.

If that works, then you can try receiving bytes in vb.net.

When that works, we can look at sending the data the other way from the PC to the picaxe (which is a little more complicated).

Sing out if you get stuck along the way.
 

Denzel

Senior Member
...

You want to find an activeX control that will allow to use access your serial port via VB. MsComm worked well for vb4 but for 2003 onwards go here:

http://home.comcast.net/~hardandsoftware/DesktopSerialIO.htm

Download desktopserialIO its a pre-made vb app which will allow you to set the baud rate and serial port and then send data (and receive if there's anything to receive). Then just tinker the code to get exactly what you want, change appearance etc. or you can just download the dll desktopserial IO and write you program from scratch.
Then you simply need to set up a serial port that goes into a serin pin on your picaxe (look in picaxe manual...3? i think) and use serin to receive data. I haven't used this method for ages but I HAVE used it and it works. If this is too complicated then I suggest a bit more reading about VB and picaxe serial communication.

Good luck.
 

elios

Senior Member
wow thanks for the tutorial Dr A. i just did it now! its wicked!

so i have now got two LEDs flashing off the buttons
 

moxhamj

New Member
benryves is right - use that suggestion (which is the one used in the instructable). It keeps things simple.

Great to hear elios has it working. Hopefully sciguy77 won't be far behind...
 
Top