Bluetooth Communication for the Half-Byte Console (or how to make your HC-06 work)

WP_20140619_007Wireless transmission of data is mostly preferable to using physical connections and, in the Arduino world, it is no different. If you want a network of sensors or need to have several microcontrollers communicate with each other or a PC, you may not be able wire them together. Fortunately, there are several wireless alternatives that are simple and inexpensive.

While scouting eBay and other sources for parts for the Half-Byte Console, I found these cheap, simple and cute little Bluetooth modules. They also happen to work with the serial connection on your Arduino. If you decide to use the standard serial pins (RX/TX) then coding the module is a no brainer: just use Serial.Write, Serial.Print, etc. to send data or Serial.Read(), etc. to get data. If you need to use other pins, use SoftwareSerial.  It really is that simple.

The particular module I have is the JY-MCU BT-Board v1.02pro (HC-06).  It was $4.99 on eBay.

Wiring it up was simple: WP_20140619_014

  • RX->TX
  • TX->RX
  • GND->GND
  • VCC->+5v

When the module is powered up, and found by another Bluetooth enabled device, it shows as ‘HC 06’.  The key is ‘1234’.  Once the device pairs with the HC-06, you are now ready to communicate. On a PC, you’ll need some kind of terminal app that can access a virtual serial port or Bluetooth directly. I found a Windows 8 Modern Appbtserialterm called Bluetooth Serial Terminal and it works great (it is also free from the Windows App Store.) The application is very simple, there’s no real setup as it detects BT devices and configures itself accordingly.

The module defaults to 9600baud, which is a bit slow, but you can reconfigure it. I chose to leave it at the default since the particular application I have in mind will not require more than that.  I’ll spare the dirty details of configuring the module and leave it to ‘Stan’ at the 42bots blog.

Since the module is serial, it works with Arduino Tiny Basic.  As long as you keep it on the RX/TX pins, you can use the built-in Tiny Basic serial statements to talk to and send data over bluetooth.

SPRINT “Hey ma, I’m on Bluetooth now!”

will send that sentence over Bluetooth and be displayed on the BT enabled device. You can IN( 0 ) to receive data from the module. It is very simple.

WP_20140619_011This little module, coupled with an Arduino Pro Mini and some sensors would make a cool little environmental (one use) device. No screen would be needed, which brings cost way down. Instead, you could use your BT enabled phone or tablet and when it gets near the device, they auto pair and you can open up your terminal or, perhaps, dedicated app and get the data streamed to you. I envision, under Windows 8 or Windows Phone 8, having a live tile that would display this data for you. 

It also opens up some cool game ideas. Awhile back, I wrote of using Basic Stamps to create a meshed Star Trek like game.  These little BT modules could make that really easy to do.  There are always possibilities.

I am really impressed with this little module. It was super simple and really cheap and, it just works.

For a cheap, simple and effective means for wireless data in your Arduino projects, these little gems seem to be the way to go.


Developing a handheld console with Arduino

IMG_3163Since my first exposure to computers and video games, I have wanted to design and build my own. Lacking, however, the resources and knowledge, I thought it would just be a pipedream. Well, fortunately for me, that is not the case.  The technology is to the point where just about anyone can do so and for just a little money and the internet.

Microcontrollers are the key and companies like SparkFun and AdaFruit can supply the bits. If you are really tight on funds or just cheap (like me) you can save a bit by shopping eBay. 

So, what can these microcontrollers do for you? Well, anything you want. And, yes, they can play games.

My original plan was to use something like AdaFruit’s Trinket for the brains and the Nokia 5110 LCD for the screen. Well, the Trinket is just too limited (and, frankly, difficult to program.)  During a lengthy eBay search, I found a bunch of Arduino UNO clones that fit in about the same space as the Trinket, only with more I/O and more memory. I ordered a few of them and then waited almost a month to get them. In the mean time, I used my UNO to start writing code.

IMG_3182Along the way, I discovered the Arduino’s were capable of video, so I spent a few weeks playing with that and have built a game console that I will revisit once my plate is clear. Adafruit and other vendors sell interfaces for the Wii Classic Controller and the Nunchuk…both of which are very easy to code.

Back to the handheld. The Trinket filled in, physically, for my board layout. When the Mini Pro finally arrived, I socketed it and began to wire it up. A strip for the 5110, connector for the speaker and daughter board for the audio amplifier. I wrote up a short demo that married the audio to the graphics library and produced a static Mario splash screen and beginning of the game.  It plays the Super Mario Brothers 2 theme upon startup.1398742_562906223779137_852686949_o

My next tasks include a controller (a matrix of four buttons: Left, Right, Shoot, Start/Stop) and a case. The actual game code will be last. I want the hardware nailed down before I do all of the code.

The system will run off of three 1.5 volt AA batteries. I wanted to use a rechargeable battery, but the added complexity is more than I want to deal with for now.

1425448_569760583093701_1031881671_oThe case is my biggest headache. I was going to use Lego’s, but the cost is more than I want to pay. I have an old Mattel JuiceBox that I will attempt to use. It looks big enough and already contains a battery compartment, holes for the controls and a speaker bay. It’s just really ugly.

I am also building version two of the handheld concurrently. This one will be for myself (the other is for my step son) so it doesn’t need to be as friendly and compact.  At some future point, I may take lessons learned from both and make a third version.  My version will also output video and has a PS/2 keyboard connector.  I have a version of Tiny Basic that will work with this hardware and this will be my portable computer and game console.1267690_572617716141321_1112089022_o

I have, so far, been pretty successful with my creations, even though I have a very rudimentary knowledge of electronics. I know what resistors and capacitors do and an understanding of transistors. More importantly, however, I can read a schematic and everything I’ve done has come from schematics found on the internet. In some cases, I’ve only borrowed parts of the schematic, in other cases, I used a basic schematic from a datasheet (talk about boring) and have put this stuff together on my own.  AdaFruit and SparkFun have terrific user forums and they have been a big help as well.  But, there is one site in particular: Arduino-Info. This site has code, schematics and really easy to understand explanation about each project. It covers basic things like LCD’s, keypad’s, servo motors and basic Arduino. It explains many electronics concepts and has lots of examples. It has been invaluable.

The Nokia 5110 LCD is a low cost and easy to code panel. It is low res, 84 pixels wide by 48 down. It is challenging (I have an even better appreciation for developers in the ‘70s and early ‘80s) to come up with graphics that look good in such low res. My Mario character looks more like Mega Man. It is a great choice, however, because it has a low memory footprint: 504 bytes for the frame buffer. This still gives about 1.4K to work with, a gold mine.  You can get them from AdaFruit or Sparkfun for under ten dollars or on eBay from $1.88 to about $3.00.

That brings me to parts buying. If you buy them on eBay, it will likely be from an overseas vendor.  I ordered parts from several Chinese vendors and, in all but one case, I got the items within two weeks and free shipping. I would highly recommend getting them from North American vendors. If you look, you can get pricing that is close to the Chinese vendors and still get free shipping. I got my Mega and one of my UNO’s from vendors located in North America. I had those items in just a few days, so it was worth the extra dollar or two.  I also buy from AdaFruit, SparkFun and Jameco. Some things, like the UNO and Mega, cost two to three times the eBay price. I paid ten bucks for the UNO clone and AdaFruit wants $23 and JameCo had one for nearly fifty. Radio Shack sells the UNO for $34.00. As for the Chinese vendors, I bought a bunch of small parts: joysticks, Mini Pro’s, keypads, LCD panels, sensors, etc.  The smallest order was $1.88 and the biggest was $16.  In all but one case, I got the parts in about two weeks, one took a month and one never arrived, but they did issue a rebate and an apology. I would buy from them again, That was the $1.88 order.

I will post more about my project at a later date

Follow Half-Byte on Facebook for more frequent updates on my projects and other tech news.