Picaxe 08M with visual basic 6

Hi guys,

For the past few weeks I have been playing with Visual Basic 6 and attempting to get it talking to my picaxe 08M chip.  I have found a few tutorials online that are not exactly for this chip but I can follow and understand how they work (at least i think so).  My goal that I am trying to achieve is a simple off and on LED switch via VB6.  I have tried tweaking my code many times and going through various tutorials but I have had no success. Here is how i have been setting up.

I have the standard programing cable plugged in with the serial output of the cable going to pin 4 of my picaxe.

I have an LED hooked up to Pin 1 (this is the LED that I am trying to blink on and off)

After reading the manual I have come to understand that SERIN is the command to use on the picaxe end to listen for serial input.

Here is my picaxe code.



serin 4,N2400,b1

if b1 = 0 then ahigh

if b1 = 1 then alow

goto main

high 1
goto main

low 1
goto main


And this is the Visual Basic 6 code: (I have 2 buttons set up, one to send a "0" for off and the other to send "1" for on)


Option Explicit

Private Sub Command1_Click()
MSComm1.Output = Chr$(0)

End Sub

Private Sub Command2_Click()
MSComm1.Output = Chr$(1)
End Sub

Private Sub Form_Load()

MSComm1.CommPort = 10

' 2400 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "2400,N,8,1"

' Disable DTR
MSComm1.DTREnable = False

' Open the port
MSComm1.PortOpen = True

End Sub


As far as this project goes for me, i have been trying for a few weeks now and I feel I am not getting anywhere. Not looking for a easy way out but more so someone to show me where I am going wrong as there must be something I am missing.


Thanks for the help guys :)


Are you sure that the port

I think you should just leave the serial cable as it is when programming.

Are you sure that the port should be 4 and not 1 ?
You might try: serin 1,N2400,b1

I did actually origianlly

I did actually origianlly leave the serial cable with pins connected as is when programming but still had no luck.

The reason I hooked up the serial input to read from pin 4 is due to picaxe manual 2, page 198 where i read the statement

"The serin command is used to receive serial data into an input pin of the
microcontroller. It cannot be used with the serial download input pin, which
requires use of the serrxd command instead."

Due to this statement in the manual, I hooked the serial cable up to pin 4 instead, However I do have one question for you.

With what you last posted to try “serin 1,N2400,b1” would that refer to input pin 1? or the serial input pin?

Thanks :slight_smile:

resistors and inverted signals

When using the sync cord on “other” serial pins (other than the ones used for syncing) will require the same 22k/10k resistor set-up as the download circut. Be sure this is the case.

Also, picaxe uses inverted serial signals. Try the same commands as stated above but change that “N” to a “T” and see if that gets you anywhere.

Oh, the “regular” serial pins

I have to aggree with Mr. Andersen as well. The regular sync pins (and the regular sync jack) would be the easiest way to do this. However, to access these pins, one should use the sertxd and serrxd commands.



Still a no go

Hi Chris thanks for the input!

I just tried what you suggested. First i changed the N the to T and had no luck. It also appears that the picaxe 08M does not support the serrxd command.  My current setup is just the usb to jack program cable with the standard wiring. Once I have downloaded my program to the picaxe, I change over the serial input wire to go into pin 4. and leave the other wires the same.  I have also tried leaving the wiring the same however i have had no luck.  Starting to kinda pull my hair out on this one now.  I know it is possible with this chip but when you think you have it all right in your head and don’t get anywhere, it feels like its playing games with you…

I am not sure where the problem is (picaxe coding, wiring or the VB6 coding)


Thanks again for the help Chirs!


After looking at manual 1 page 95, I noticed that a) pin 4 is actually leg 3, b) your program doesn’t seem to make mention of either one of those ‘assignments’ and c) in your program I see what seems to be mention of pin 1 which would be leg 6. My knowledge of PICAXE BASIC is minimal at best. I would still think that some manner of definition of pins would be required.

Thanks for the help!

Hi birdmun thanks for taking the time to help out!

I just took a read through manual 1 page 95 as you suggested.  To the best of my knowledge, when you refer to pin 4 in the code, it does actually apply to physical leg 3. I have never needed to assign anything in that manner in previous projects so I am not to sure on that one. I will definately take this into consideration though and look into it some more!

Thanks again!

Completely disregard my comment.

As I said, my knowledge of PICAXE BASIC is not my forte. After looking back through your program I now understand some things a bit more. 

serin 4, … is saying serial input on pin 4/leg 3 and the input is put into variable b1 which you then test and attempt to flash your LED.

Sorry about my misdirection it was unintentional.

Thanks again

No thats fine!  I do respect the fact that you guys are willing to try and help out. Any ideas on what could be the problem can help.

Thanks again :slight_smile:

Just to throw it out there

Have you tried swapping your rx/tx lines? It is a simple thing, I know, but I don’t think I have ever gotten it right the first time.

I looked it up, and sure enough, the 08m does not support serrxd! It does sertxd, so it will talk but not listen. How weird. I’m not saying I didn’t trust you, it has simply not come up before and I couldn’t believe it.

Oh, and have you tried it the other way? Set the picaxe to contantly transmit and try to catch it on the PC? There can always be funny “translations” on each end. For example, you could be sending an “A” but the picaxe tells you that you got a 65. Technically correct, but if you are using if data_in=“A” then… and the picaxe has decided to do some ASCII shenanigans well, the “if” statement will never happen. If you have the picaxe transmit instead of recieve during tests, you can easily see on the screen (your terminal or VB) whatever you are getting. I would do this:


serout pin,T_or_N_and_your_baud,b1

b1=b1+1  'just let this overflow --the number does not matter, just that you are getting numbers and that they are 'changing

pause 1000

goto main

This guy will spit-out a simple count every second. If you can catch the data via your PC, it is probably working the other direction too. This should tell you that you are having an issue with how you are dealing with the data (once you got it) on the picaxe end and/or if your hardware is GTG.

Alright more research …

The following link, http://support.microsoft.com/kb/823179 , is for VB6 serial port communications.

One difference I see in your code versus the Microsoft code is


’ Send the attention command to the modem.

        MSComm1.Output = “ATV1Q0” & Chr(13)

Your code, MSComm1.Output = Chr$(1), their code, MSComm1.Output = Chr(1). I know I paraphrased. I don’t know the function of the dollar sign or no dollar sign.

One other “stupid” question. Do you know for sure you have comm port 10? I have read often times that Windows generates new ports as a USB -> serial convertor is plugged and unplugged.


Hey man,Yeah i have tried

Hey man,

Yeah i have tried swapping over the RX/TX lines. I have learnt from that mistake multiple times in the past also!

I have just started trying to send data the other way using this:

serout 0,N2400,(65)
pause 1000
goto main


In the picaxe terminal window, sure enough I can see A being received on repeat however when i open up my VB6 project, my textbox i have setup to display input does not display what I want. I am pretty sure that this means that its more so the VB side of things that is the problem and not so much the picaxe. Don’t wanna give up on this though.

Thanks for the help again Chris

Just checked out the link

Just checked out the link that you send through, Honestly, I am unsure of that the purpose of the “$” does but multiple examples I have found on the internet refer to it as Chr$(value). Just played around with the code again using what you suggested and still having no luck.  As I was saying to Chris in previous post, I am pretty sure that I am going to need to spend a few more hard hours studdying up on my VB coding as I think this is the problem area.

As for the Comm port, I have made that mistake many times and it has become second nature to check this every time I plug my cable in. lol. That one is an easy mistake to make sometimes.

Thanks again for the help dude!

As it seems to be some

As it seems to be some uncertainty about the VB program an if communication actually reaches the PICAXE, one test might be to turn on a LED right after the serin statement and pause. Then at least there should be a value in b1 (but if it’s 0 or 1 remains to be seen)


Hi guys!

After many days of frustration, I have got my picaxe chip talking with VB6!

It turned out to be a simple problem that I should have picked up (dont you hate when that happens). My serial input pin on my picaxe was left floating.  I wired this to ground and bingo!  Here is my code for anyone who is reading this trying to do the same thing in future!


My Picaxe code:

Hook up an LED to pin 2 and your serial input to pin 4. (DO NOT FORGET TO WIRE YOUR STANDARD SERIAL IN TO GROUND ;)  )



serin 4,N2400,b1

if b1 = “H” then ahigh

if b1 = “L” then alow

goto main

high 2
goto main

low 2
goto main


Visual Basic 6 code,

 Add 2 command buttons, a text box and make sure you have your MSComm settings set the same as your picaxe!



Private Sub Form_Load()
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.PortOpen = True
End Sub

Private Sub Command1_Click()
MSComm1.Output = "H"
Text1.Text = "H"
End Sub

Private Sub Command2_Click()
MSComm1.Output = "L"
Text1.Text = "L"
End Sub


From there hopefully your LED clicks off and on!

Thanks to all you guys who helped out and kept me going!

So you did not have …

the serial connection hooked up as shown in Manual 2 on page 199? 

Chris even mentioned that you would require the 10k and 22k resistors for a serial connection. Maybe you missed that comment. :slight_smile:

Umm my problem that I was

Umm my problem that I was having was that when I unplugged my serial input pin after downloading my program, I would plug it into pin 4. This just left the Serial Input of the picaxe floating. What I did was a ran a wire from that serial to ground and bingo.  Manual 1 page 27 does actually state that it must not be left floating or the program will not run.  I now have 2 leds hooked up and a servo all controlled via VB6.  I am over the moon that I actually got it going (With everyones help ofcourse)

Once again I do thank everyone for their help! :slight_smile:

Not trying to beat a dead horse, but,

I just wanted to make sure we were looking/talking about the same thing.


As you can see by the above schematic, the input pin is in fact tied to ground with the 10k resistor.