Joystick to control BASIC Stamp
CorbettROV
Posts: 17
Hi, I have a BS2 with a Homework board hooked up to a computer via USB. To the BASIC Stamp, a Pololu TReX Jr. serial motor controller is hooked up. Here is a diagram of my setup:
My question is: How can I program the BASIC Stamp to receive readings from a USB joystick and use those readings to send certain serial commands to the TReX Jr? As of now, I am controlling the motor by manipulating variables in the program with the keyboard through the Debug terminal. Instead of a keyboard, I want to use a USB joystick.
Thanks in advance
-Jacy
My question is: How can I program the BASIC Stamp to receive readings from a USB joystick and use those readings to send certain serial commands to the TReX Jr? As of now, I am controlling the motor by manipulating variables in the program with the keyboard through the Debug terminal. Instead of a keyboard, I want to use a USB joystick.
Thanks in advance
-Jacy
Comments
The other alternative would be to use your PC as the host controller. You'll need to write some kind of PC program that reads the joystick position and uses a serial port to talk to the Stamp to send the current joystick XY position and buttons. Again, there's no ready-made program although there may be past projects on these forums about that sort of setup. You'll need to do some searching (using search.parallax.com and browing).
I saw a post in which a teacher was talking about using joyticks with his BASIC Stamps in class all the time, and I was curious about that also.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
If you don't know one of these languages, then I suggest dropping the USB joystick idea and going to an simpler device. You could use the Datalogger, but my experience is that it's a tough beast. Your experience may differ.
The easiest thing to do would be to hook up some pots and build a joystick from them, or to buy an equivelent device. Then you just use RCTIME to figure out where the joystick is.
Attached is a program kindly given to me by a forum member.·This program·does exactly what you want IF you have a Logitech Dual Action Game Controller. (I bought one at Radio Shack--or maybe it was Nebraska Furniture Mart--for $19.95.)
The advantage of the Logitech device is that it has TWO joysticks and ten buttons. It also has another control called a D-pad which is not functional with the software attached, which is written in VB and may have some of my comments in it, but I am not its author.
I recommend you simply buy a Logitech Dual Action Game Pad, load the attached software into VB 6.0, and start pushing buttons.
Eventually, my Parallax based, remote control lawnmower will use this game pad along with a version of the attached software.
This is an extremely popular subject. A PC is an extremely useful device to hang on a Parallax Stamp. It extends the possibilities of using the Parallax Stamps in far more powerful applications.
Remember that this software is one way. All it does is read the game pad actions. I also have some Parallax Stamp/Bluetooth/BlueTooth/PC VB 6.0·code that will allow you to blink two LEDs ON COMMAND at least 100 feet away. (That's as far as I've tested it through concrete, anyway.) That code will also become part of my remote controlled lawn mower. The dirt simple VB 6.0 interface says it is controlling a lawnmower, but all it does is make one of two LEDs blink, or shuts them both off.
Good luck and thank you to the member that helped me with this HUGELY popular topic that receives so little attention.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Where can I get VB 6.0?
Post Edited (CorbettROV) : 10/29/2008 2:43:39 PM GMT
Unlike me and almost everyone else on this forum that freely shares software, Microsoft wants to make MONEY on their stuff! Hey! What's up with that, anyway?
You have to buy VB6.0, probably as part of Microsoft's Visual Studio. If you are a student, this can be a DIRT CHEAP deal and well worth the investment. (My college sold it for about $25.00.)
Microsoft also allows a person to download something called Visual Basic Express at no charge. Many folks on this forum use it. I know nothing about it. I just hope you are a student.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
While it's not VB 6.0, chances are you might already have a flavor of Visual Basic within Microsoft Excel. If you already have Microsoft Excel, here is a guideline to getting COMPORT control through this VB package.
1) Search for MSCOMM32.OCX on your computer... it might already be there. If not do an internet search for this file and download it.
2) Open up Microsoft Excel
3) Turn on Visual basic Tool Bars.... View --> Toolbars --> Visual Basic
4) Click on the 'Visual basic Editor' under the 'Visual Basic Tool Bars'
5) Add 'MSCOMM32.OCX' functions to Microsoft Excel ... Tools --> References... --> Browse (find location where you saved the 'MSCOMM32.OCX' file)
Note the OCX extension... you might need to change this from the default extension used in the file browser.
6) You should now have access to Serial port commands and functions under the "Object Browser" that you can include in your own programs.
In many cases, the USB port is "seen" as a COM port, so this becomes a matter of setting the correct COM port and reading the data from within your VB program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I tried the Excel thing, and I got everything to be as it should, but I have absolutle no idea what to do now.
Post Edited (CorbettROV) : 10/29/2008 5:23:52 PM GMT
Good! There is no telling what it will really cost. The head of the bookstore sets the price in colleges. In fact, you could probably go to your local community college, tell them you are a high school student very interested in Visual Basic and would consider enrolling in one of their courses if you could buy it from them at the student discount. (I am a retired college dean, that's why I know this stuff.)
On the other hand, try what Mr. Schwabe suggested. He has forgotten more than I'll ever know. (Beau, I USED to know a lot, so what's that mean for you? [noparse]:)[/noparse]
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.