How to wire and program rn-42 BT to picaxe

I have a PICAXE 20x2 and a rn-42 BT module and i don't have a clue how to wire them, program the picaxe or program the computer to control 2 dc motors from my computer.

any help would be appreciated

TIA

Serial

This unit will appear to the computer as if it is a serial port once it is paired-up (pair just like any other BT device). Do a little research on the datasheet to find the default baud rate --this may need to be changed and can be by using a terminal program. From there, you will need to decide what software you want to use on the computer end. A lot of people use Processing which is very similar to the arduino language. VB, python, or really anything can be used including any terminal program (hyperterm etc). From there, you are simply sending serial data back and forth. In picaxe language, you will be using the serin and serout commands or hserout/hserin commands. I would suggest using the hser commands and the hser pins --they are much more useful allowing you to recieve serial data in the background, buffer it and skip to an interrupt routine when something is sent.

In terms of motors, it doesn’t matter. You are simply sending a series of bytes and those bytes can be or do anything you want. Example: Lets say you want to control 2 motors. You could simply send 2 bytes with the first being the desired speed of the left wheel and the second byte being the speed of the right wheel. Maybe you send 4 bytes --The first 2 control the speed of each motor and the next 2 bytes indicate the direction. Anything can be anything here, you just need to figure out a little “coded system” of numbers you are going to use. Hell, you can send letters instead of numbers if you want. It is all just bytes.

Oh yeah, wiring. First off, the unit you have seems to be working at 3.3v NOT 5v. You need to regulate your power down to this level before you plug it into power. The RX and TX lines are at 3.3v as well. Don’t quote me on this, but most 3.3v stuff will talk nice with 5v stuff if you add a 1k resistor in series with each of the TX and RX lines. From there, it is just RX to Tx and Tx to Rx in terms of picaxe to BT.

 

could you please give me a

could you please give me a sample of the code i would write for Processing to communicate. i have no idea what to write.

I would start with a simple terminal

I would start with hyperterm --you already have it if you use a Windows machine. Start–> All Programs–> Accessories–> Communications–> Hyperterm. Set up the picaxe to basically camp on a serin command and debug. Something like:

hsersetup stuff at the beginning of the program

main:

hserin pin,baud,whatever,b1

debug b1

goto main

From there, you just send a byte (number, letter, whatever) from the terminal program and see, via the debug window, if B1 turns into the character you sent. Be sure baud rates are the same for everything, BT, picaxe and terminal. Use “T” (true) serial signals on the picaxe hser commands (probably). Badda-boom. That should be it. Basically, the above code should be pretty fool proof, and a terminal program is pretty straight-forward, thus any problems you have will probably be the set-up of the BT device. Start with just getting anything through for now. I assure you, the set-up is going to be the worst part. From there, gravy… Well, actually, after that you are going to want to learn processing.