Retro Computer: Arduino Pro Mini stuffed in a keyboard

WP_20150325_16_25_02_ProSo, during the Half-Byte Console project, I purchased quite a few PS/2 style PC keyboards.  Since the project is pretty much over, I have a few of these keyboards still. They are actually fairly decent keyboards for the price.  Well, I had envisioned a future Half-Byte Computer living in something like a keyboard, like the old Commodore 64 or Vic 20.  So, I set out to build one.

I wanted to use one of my Half-Byte Console boards, alas, though, it is too big. Since I ordered a truckload of Arduino Mini Pro’s, and they are really small, I used one of them.

The first thing I had to do was figure out what I wanted in this thing and where to put the parts.WP_20150325_15_44_57_Pro

I grabbed one of the keyboards and took it apart. It is really simple, a standard membrane matrix with full travel keys.  However, even though it is a full size keyboard. there isn’t much room inside.  However, there’s enough for the mini pro, wires and not much else.  I had to cut holes for the power connector and video out.

WP_20150325_15_44_49_ProWhat I was not going to do this iteration was include sound, nunchuck or FTDI connectors.  That can all come later. I’m putting HB Tiny Basic  on the this one, so I won’t need to be programming it often. The nunchuck will be easy enough to add later, as will sound. Just not that industrious at the moment.

I cut the cable from the keyboard as the pc board inside is marked and easily accessible.  I wired it directly to the pro mini: data to pin 5 and clock to pin 4.

I decided to put the video jack on the left side,  but first had to cut a hole for the connector.WP_20150325_16_24_37_Pro  Next, I put the power jack on the bottom, where the keyboard’s cable came out. I had to enlarge that opening and super glue the connector.  Next, I wired up the video out jack and the two resistors (470 ohm and 1kohm) to the pro mini (470 ohm to pin  9 and 1k to pin 7 see my previous postings on the video out subject.)  Then the power was wired up and I tested the whole thing.  Amazingly, it worked.  It took two attempts at laying out the wire and board to get the case to  go back together and for all of the keys to work. 

WP_20150325_16_20_05_ProI now have my true retro computer, complete with Tiny Basic and blocky graphics.  Truly, an awe inspiring device.  Yep. Awe inspiring.

NOTE: yes, the wiring  is a bit sloppy, but I’m no Ben Heckendorn and this was for me.  I will clean it up when I add the other connectors.

From design to built: the Half-Byte Console

IMG_4376For years, I yearned to build my own computer and, recently, as I have written here, I did. Only, this time, the computer I built was not someone else’s design, but my own. Now, for some, that’s not a big deal. For me, not being an engineer, it is big. 

Last fall, I had built an Arduino, copying someone’s schematic. It worked and worked well. I got to playing around with Arduino more and more, discovering the video and audio capability and the ability to code for this thing, rather easily, just got me more and more intrigued.

I worked on a port of Tiny Basic, nearly rewriting the wonderful Mike Field Tiny Basic for Arduino. I’ve added a ton of features-graphics, audio (ok, beeps), hardware support…etc. And I’ve optimized it to not only work with a PS/2 Keyboard and video, but it also gives you nearly 1k of RAM to use for your Tiny Basic programs. That may not sound like much, but there is a surprising amount of things you can with ‘only a k’ of RAM.

So, now I have this nifty little computer, that is not only a throwback to the home computers of the 1970’s, it is also fun to build and program.

As I am using the TVOut Arduino library un altered, pretty much any program or game that uses this library and a 328p compatible Arduino will work on the console.

So, how did I design this thing?

hbc1I downloaded the Fritzing schematic/pc board/breadboard designer package. It is free and you can generate industry acceptable ‘gerber’ files that can then be used to create a professional look printed circuit board.

I studied the basic circuitry for a 328p based Arduino compatible microcontroller. Turns out, it’s really simple. With encouragement from my wife, son and friends, I set out to design something and then turn into a product.

I had to decide what was going into the computer, what features. Well, the idea I had was that this be a fun project for parents and children to do together. Mom or Dad do thbackpice soldering and the kids help with inserting the parts and then programming the computer.  Games had to be a priority. So, the Wii Nunchuck became the controller. Unfortunately, only one is supported, due to the way it works.  (I have since discovered a way to allow more than one. That will be in the next version.) Video and sound have to be there. We need to be small and somewhat expandable.

BLACK_6_5_2014 6_03_05 PMMy first prototype looked great. I built it up on a proto board and it worked fine.  My proto, however, didn’t fully replicated my design.  After building it, I made changed to the design, but did not reflect them all on the proto. I realized, later, I should have.

So, I finish up my design, run the rules check and it passes. I study it for several days before sending it off to Fritzing to have one board made. That was expensive…forty dollars for the one board. Wow, there’s no way I can ‘mass’ produce these things at that price.  So, I search and search for a cheap fab house.  That search lasted a couple of months.  In the mean time, the board arrives, I photograph it and then put it together.  I solder the last connector and plug in the 328 chip.  Insert the power and…viola! NOTHING.  Scratching my head, I check my work and try again. Nothing happens.  I study the power circuit. I check voltage. NOTHING.XANDER - WIN_20140326_212243

Hmmm…So, I check polarity of the connector and…BINGO! The pins are backward.  This is where my inexperience with Fritzing comes in.  I misread the symbol. Damn. So, I cut the traces, solder jumper wire and try again.

This time, the Tiny Basic welcome message displays. Success! So, I wire up the keyboard because I realized that I also had the PS/2 connector wrong.  So, after correcting my mistakes with Fritzing, I get down to ‘burning in’ the board.  I run battery life tests (12 hours running constant random graphics, not too bad as it is also generating video) and communications test. Everything working great, even the Wii Nunchuck works fine.  Now, I have to find cheap components and a fab house.

Finding the components was easy, for the most part. No one dealer  had everything.  Weird how PS/2 keyboard connectors and board mounted RCA phone jacks are hard to find now.

101_3326During my experimenting and eBay purchasing, I struck up a relationship with a Chinese vendor.  I inquired about fabbing the boards and they could do it really inexpensively. So, that made this possible.  I finished up revising and cleaning up my design. I checked, rechecked and double checked. It’s going to be perfect.  Off it went to the fab.  I buy parts.  The parts begin showing up. Not too long after the parts started to roll in, but the boards did too.

My, were they pretty.

101_3346I grabbed one of the blank boards and photograph it. Then, as with the first, I build it up. Plug it in and…it worked! First time. Whew!  Finally, it works. Well…not so fast.  Everything worked but the bloody Nunchuck. My heart sinks.  Upon close examination, I see that, while I had put the labels to the connector pins correctly, I neglected to re-arrange the ground and 3.3 volt pins.  Man. I have hundreds of these boards. What the hell am I going to do?

Ah…I’ll correct the issue on the Solarbotics made Nunchucky adaptor board.  So, I fix the problem on the adapter and try. It works!  Awesome. IMG_4386

Now, I have a nice design that works. It has audio, video, game controller (that you can unplug from the main board) and it can talk, via serial, to other devices. 

I have a ton of ideas for follow up accessories, the first of which is the PS/2 keyboard and Tiny Basic programmers kit.  The standard kit is just the console, Nunchuck adapter and a 9volt battery clip. The programmers kit is the standard kit, plus a PS/2 connector, Tiny Basic in the 328, A Learn to Program with Tiny Basic manual and either a PS/2 Keyboard OR a USB to PS/2 keyboard adapter. I am also working on a real time clock, Bluetooth connectivity and an experimenters kit. 

This has been a fun project and one I thought I’d never do.  I’m a programmer,not a hardware engineer. And, anything more complicated will, likely, require a real engineer. But, in the mean time, I have more projects like this. 

IMG_4394The console and Tiny Basic will be licensed as the original works are, I will post that later.  I will post the source code for Tiny Basic, the schematic, parts list and Fritzing files.  I will be selling the blank boards and the two aforementioned kits with printed documentation very soon.

In the mean time, if you want a blank board, I am selling them now.  Go to the Half-Byte eBay store and pick one up.

Half-Byte Serial Graphical Terminal

BLACK_6_5_2014 6_03_05 PMIn a previous post, I wrote of a dual screen Arduino set up. Using the Half-Byte Console and one of the early prototypes for the console, I wrote a simple terminal program that will allow not only ASCII data from the host, but also will interpret special commands to clear the screen, set or reset pixels, draw lines and boxes. Even at 9600baud (which, if you do not know, is pretty slow) the speed is more than adequate. This opens the door for some simple two player graphical games (remember, the console only has 1k available in Tiny Basic or 1.5k if you use the Arduino IDE) or want to display secondary game info on a second screen.

The current version lacks keyboard support, but that is coming as well as Nunchuck support. 

I am going to explore wireless connections as well. Either Bluetooth or the simpler NRF24L01 wireless transmitter/receiver combo.  The range of the NRF is decent and they are cheap enough.

The terminal is super simple and uses the TVOut library. Currently, for max use, I am using a resolution of 136 by 96 which yields about 32 characters wide by 16 lines down, using a 4 by 6 font (not the prettiest, but it works.)

Communications, via serial on the Arduino/Half-Byte Console, can be done via Tiny Basic’s ECHO, SPRINT and OUT statements.  SPRINT will display data on the screen. Anything you can do on the consoles main screen via PRINT, you can do on the serial screen.  In addition, using CHR, you can send the special commands via the SPRINT statement:

120 SPRINT CHR(26)

will clear the screen.

You can also use OUT:

120 OUT 26

Here is a complete list of commands to send:

Command: What it does:
26 Clear the screen
27 x,y Set the cursor position to x,y
28 x,y Set a pixel at x,y
29 x,y Reset a pixel at x,y
30 x,y,x1,y1,c Draw a box from x,y to x1,y1 either black (c=0) or white (c=1)
31 x,y,x1,y1,c Draw a line from x,y to x1,y1 either black or white (o or 1)

For commands that have parameters, send each parameter separately and without any delimiter. So, to draw a line from the top left to top right corner:

100 OUT 31: OUT 0: OUT 0: OUT 134: OUT 0: OUT 1

The 31 initiates the draw line command. The next four outs will set that start and end points and, finally, the last out will tell the terminal to light up the line. If that was a zero, the line would be erased.

I will be making the source code available for download soon. I am cleaning it up at the moment.

Dual Screen Arduino Fun

TVTempSo, I was working on my HalfByte Arduino Tiny Basic and ran into a problem. As it turns out, it wasn’t really a problem, I only thought so.  To aid in my debugging of the non-existent problem, I modified the character out routine to echo to both the television and the serial port so I could see on the computer if anything were happening.  Well, after investigating a bit more, I realized that my change to one of the functions (DREAD and AREAD) were actually working, I just misunderstood the digital read function in the Arduino.  WP_20140526_002

Well, forgetting that I had the echo to the serial left in, I began playing around with some example code for Tiny Basic.  At some point, I reopened the serial monitor in the Arduino IDE.  Lo and behold, text was outputting to the monitor as well. I decided to leave it in. It will give the user another display option. Of course, none of the graphics and cursor positioning work this way, but that’s OK, for textual output of more than 20 or characters, the serial monitor will work fine.

Thinking about other uses for this, I hit upon the idea of using another graphic screen.  A simple Arduino or another HalfByte console and a special sketch will allow the second device act as a dumb terminal.  Modification of said sketch will allow for simple cursor positioning and, possibly, graphics. Since the second device is only serving video and, perhaps, the keyboard,

WP_20140526_003So, what will this do for us? Well, considering the host device will still have just shy of 1k bytes, not much in the way of sophisticated games, BUT…a two player Star Trek, Tic-Tac-Toe or other simple game is not out of the question.  To accommodate output ONLY to the second screen, I added SPRINT to Tiny Basic. This also means a switch to PRINT that will turn off the echo feature.  Not sure how I want to implement that.

Other possible single player uses are the said Star trek game with a ‘tactical display’ on one screen and most of the game play on the other.  Non-game uses might include graphing on the primary display with numerical table like data on the second.  Connect a temperature sensor and real time clock to show the differences in temp throughout the day.  One screen has the numerical data, the other is graphical.  Tiny Basic can handle it.  Everything is there (hmm…may add support for the popular temp sensors…) and only your imagination is the limit.

HALFBYTE Console Tiny BASIC update

XANDER - WIN_20140222_110454 (2)The HalfByte Console is nearly complete. The hardware design is pretty much done and a prototype built. It is a fairly simple ATMega328 based computer with audio and video out, Wii Nunchuck interface (the Wii Classic Controller also works), PS/2 Keyboard support and will run off of battery, wall wart or can be powered via FTDI.  It is pretty small, about the size of an Arduino UNO. It is designed to be easy to use and build. (The console featured in the photo above is the first prototype and is not the final design. The final prototype is not presentable here, this one looks nicer.)

One of the goals of the console is to aid in learning to program.  For now, this can be done in two ways: standard Arduino IDE or on console via Tiny Basic.

Yes, Tiny Basic. 

I have adapted the wonderful little version of Tiny Basic from Mike Field.  I did this for the XGamestation and have done it for the HalfByte Console as well. This version of the language supports graphics, low level hardware access and the Nunchuck. It is standard Tiny Basic in every other aspect: integer variables, single letter variables, line numbers, GOTO, small memory footprint and is easy to learn. It makes the perfect introduction to programming.

Because the 328 is limited, RAM wise AND the video takes up most of that RAM, we are left with only 726 bytes of memory to use for programming. The 52 bytes for variable storage and stack already have RAM dedicated, so you do not need to factor that in.  As such, the big feature I wanted to include, SD Card support, could not be done.  To implement FAT16, you need a 512 byte buffer and we simply do not have that, so, for now, EEPROM is used to store a program. Again, memory issues only allow for ONE saved program.  Since RAM is low anyway, we can fit it in the 1k EEPROM space we have.  And, remember, this is more of a learning tool than a ‘serious’ development platform.  The console can, of course, be programmed for games and other applications outside of Tiny Basic and there are a lot of really clever games that utilize the TV OUT library.

So, what can we do with Tiny Basic? Well, even with these limitations, a lot.  Throw some motors on the console and control them with Tiny Basic.  Add some LED’s and make them blink.  Create small, clever games.  Your imagination is the limit.

I won’t discuss the basics of BASIC, but would like to touch on the hardware specific enhancements, like graphics and controller support.


There are five graphics statements and one function.  The five statements are:

  • SET x,y
  • RESET x,y
  • LINE startx,starty,endx,endy,on or off
  • BOX startx,starty,endx,endy,on or off
  • CIRCLE startx,starty,radius,on or off

The function is:

  • <var>=GET(x,y)

GET will return the setting of a pixel at x,y. If the pixel is lit, it returns a TRUE (1) otherwise a FALSE (zero).

For LINE, BOX and CIRCLE, ‘on or off’ means a one for on and a zero for off.  If you BOX a section of the screen with text or other graphics, you can set ‘on or off’ as a 2 and it will invert that section of the screen. This is a good way to highlight text.


There are two statements that can set pins on the 328:

  • AWRITE <pin>,on or off or value (sets the ANALOG pin)
  • DWRITE <pin>,on or off or value (sets the DIGITAL pin)

There are three functions to read values from the hardware:

  • <var>=AREAD(<pin>)
  • <var>=DREAD(<pin>)
  • <var>=IN( 0 )

AWRITE and DWRITE will send a value to the specified pin. A zero sets the pin LOW, a one sets it HIGH, any other value is simply sent to the pin. AREAD and DREAD will return a value from the specified pin. NOTE: the ‘A’ in AREAD and AWRITE specify the ANALOG pins, while the ‘D’ means DIGITAL pin.

IN( 0 ) returns the current value from the RX pin (D0) on the 328p chip. This could be useful to monitor the serial interface for incoming data.


Since adding support for graphics and the Nunchuck, simple games like Space Invaders or simple shoot them ups are fairly easy.  Nunchuck support is complete, too…you can not only read the buttons and the thumbstick, but also the accelerometer. While the Classic Controller will work, no support for it is included. Maybe a later version.

The first sample I want to show is Kaliedoscope:

100 CLS
110 X=RND(40)
120 Y=RND(20)
130 P=RND(40)
140 Q=RND(20)
150 SET X,Y
160 SET 80-X,Y
170 SET 80-X,40-Y
180 SET X,40-Y
210 RESET 80-P,40-Q
220 RESET 80-P,Q
230 RESET P,40-Q
240 IF INKEY(0)=27 STOP
250 IF RND(100)<95 GOTO 290
260 BOX 0,0,79,39,0
270 FOR I=1 TO 500
280 NEXT I
290 GOTO 110

This little gem will display random pixels that are mirrored in four quadrants on the screen.  Randomly, the screen will invert. It can be quite mesmerizing.

Here’s a Nunchuck example:

110 SET(X,Y)
160 IF Q>200 Y=Y+1
170 IF Q<100 Y=Y-1

This bit of code is akin to an etch-a-sketch. PAD is the function which reads the controller. The parameter passed tells Tiny Basic which part of the controller to return a value: the x and y axis for the stick, the C and Z buttons and the accelerometer.  the modes are:

PAD number

Return value


Thumbstick x


Thumbstick y


‘C’ button




Accelerometer x


Accelerometer y


Accelerometer z


This example will blink the PIN 13 LED:

100 FOR K=1 TO 50
120 FOR I=1 TO 500 #DELAY
130 NEXT I
150 FOR I=1 TO 500
160 NEXT I
170 NEXT K

Looking at the code, you see that line 110 turns on the LED and 140 turns it off.  120 and 150 create a delay so you can actually see the LED turn on and off.  We could add a line between 120 and 140 to test for the status of pin 13:



Now, these lines are rather pointless in the example, because we know they SHOULD be set accordingly, you can see the utility of them. 

As you can see, there is a nice foundation here for something that can be quite useful in not only teaching a child how to program (or, anyone) but it is also useful for scripting hardware functions as well.  This version of Tiny Basic should run, as is, on an Arduino Mega2560. On that board, you will have more RAM to work with and create some really nice, useful or fun code.  You could also modify the interpreter for a slightly high resolution.

I have prototyped using a second 328 strictly for video generation. This gave me an effective resolution of 128 x 96 graphics and 22 by 12 text.  However, communication between the two is serial and I did not fully implement graphics. Once the console is complete, I will return to this side project and fully develop it. Perhaps HB Console II will feature two 328 chips.

Developing this Tiny Basic has been fun and brought up many memories of when I was a wee lad, experimenting with this new thing called a home computer with my Dad.  I hope this can create similar memories for parents and children going forward and, along the way, spark an interest in these nifty little computers.

NOTE: I am currently stumped with the PIC16 version of TINY BASIC.  I have the interpreter working very nicely with low res color graphics, sound and hardware support. BUT…I’ve been stumped with a big bug in the SAVE-LOAD code.  We utilize the SD Card (FAT16) library and can read and write and get the directory listing. If you are familiar with the PIC and know C and would like to help, PLEASE drop me a note.  I can’t reward you with a financial reward, but you will have my eternal thanks and recognition both here and in the Tiny Basic code.

EDIT: since publishing this post, I have been able to squeeze 200 more bytes into RAM by moving the keyword scan tables into PROGRAM MEMORY. More optimization may be possible. Who knows, maybe I can get a whole 1k of RAM. That’s what the original ZX-81 had.

Half-Byte’s handheld and more

Windows Phone 038In previous posts, I’ve written about developing a handheld gaming console.  While it is not yet complete, the console now has a case and a controller.  Finishing touches to the hardware will include a new bezel, battery compartment and screen mount.  I used an original Gameboy case from 1989. Don’t worry, nothing has been cut and I kept the electronics.  I got it off of eBay for about four dollars. It was as a broken unit, though the seller says it did work ‘once in a while.’ I purposefully bought a broken unit as I could not bring myself to rip apart a working Gameboy.

When the unit arrived, it was well worn, so I cleaned it up, dismantled it and painted it metallic black.  Finding Testors model car paint locally was as hard as finding the micro female HDMI connector for my Raspberry PI Laptop. I also clear coated the case once the paint had dried.Windows Phone 008

Fitting the handheld in the unit was a bit tricky, but it does fit, although I have to do some work with the screen mounting.   I was also able to use the d-pad and one of the two red buttons. The other three buttons will be either for expansion or, likely, I’ll just fix them in place for looks. Not sure yet.

The result is going to be pretty nice, albeit large for today.  I knew the old Gameboy was huge, but I forgot just how big they were. The main board uses surface mount parts, which kind of surprised me. I know the original device was based on the Zilog Z-80, but, looking at the board, there is a custom Nintendo CPU chip. I’m guessing it has a complete Z-80 as well as whatever custom pieces parts that Nintendo put in. At any rate, it is the perfect size for the somewhat retro handheld that is going in the case.

WP_20131219_001The specs for the handheld are, indeed, retro: 2K of RAM, 8K of ROM, 84 by 48 monochrome graphics, a vintage ‘90s cell phone screen, vintage ‘80s case…Mario style side scroller game.

When test fitting the two boards in the case, I realized that my custom controller almost fit the button layout. Only one button needed to be moved and that was the action button. So, rather than desoldering the existing button, I cheated and added a separate button and mounted it so it was under the ‘A’ button. I reused the speaker that came with the Gameboy, since it fits perfectly. I have added a power switch and a reset button that is accessible through one of the small holes on the side of the case. Now, since the handheld will not have every connector and switch that the Gameboy had, there will be a few open holes on the side and bottom of the case. I may fill them but, will probably just leave them alone for now.  I do plan to upgrade the screen at some point, so I may revisit the holes then.

This project has inspired me to go a bit further and design something from scratch.  I have a PC Board designed and am building the prototype from that design. The board is a bare bones Arduino UNO without the expansion connectors. It will feature audio and video connectors, a Wii Nunchuk/Classic Controller connector, optional PS/2 keyboard connector and be based on the same Atmel328 processor that the UNO uses. The design is super simple and is designed for games and learning to program.  I am also considering the same treatment for the handheld. I have modified the Tiny Basic code to include things like primitive string handling, limited graphics and memory saving shortcuts for several statements and functions. There is also a beginner’s guide in the works.

Stay tuned for more on this.

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.

Real do it yourself computer using Arduino or…how to make your own game console

IMG_3043Ever since I was a kid, there were two things I’ve always wanted to build: a computer and my own video game ‘console.’ Now, I grew up in the seventies and eighties, so both of these things were pretty crude, some even crude when they were new (RCA Cosmac, I’m looking at you!) While in the intervening years, I did ‘build’ both, I cheated in doing so. With the computer, ‘building’ one was simply buying premade cards and a motherboard and installing them, hardly building one. With the video game ‘console’, I assembled a ‘pong’ style game from a kit (which I wrote about here.)

Now that I have discovered the wonderful world of microcontrollers, I can, finally, actually build both of them.mk121pal

Today’s microcontrollers are as powerful, if not more so, than yesterday’s microcomputers. For instance, the ATMega 328 is every bit as capable as the 8080, one of the mainstays in the 1970’s. Because of this, you can build real computers that are very small and require little power. They also require substantially fewer parts to work and be useful.

While I am no electronics engineer, these chips are simple enough for even someone like myself to design and build a working computer that can, subsequently, become a game console.  Companies like Adafruit, iConstrux, Spark Fun, Arduino and others all have components that are geared toward these nifty little devices. Adafruit, for example, sells the Nunchucky, which is a tiny little board that allows you to easily interface a Nintendo Wii Nunchuck controller. These controllers are, themselves, very cool and underrated. They feature accelerometers, a joystick and two buttons and are easily read by these little processors. And, with the Nunchucky, you do not need to cut its cable.

IMG_3070While it is old news, it is new news to me…the Arduino’s are capable of limited video generation and, hence, limited graphics. Now, while the graphics ability will never threaten nVIdia or AMD, they will give the aforementioned RCA Cosmac a run for its money. 

Armed with this knowledge, the Nunchuck/Nunchucky, some basic soldering skill and enough knowledge of electronics to be somewhat dangerous, I have set out to build that computer/game console.

I am actually doing two consoles: a handheld for my stepson and a somewhat more capable one as my exercise in designing and constructing said system. The handheld will utilize a small joystick, a Nokia 5110 LCD and a speaker in addition to the Mega328 Mini Pro.

Unfortunately, I ordered a great deal of my parts from eBay and just about all are shipping from China, apparently by foot as they have not all arrived.

IMG_3041However, since my Uno did arrive, I’ve been able to design and build the Half Byte game shield and start working on a prototype game, based on the Super Mario games. No, the game will not be made public, but, perhaps, a modified version with different characters may be. I do not have license to distribute any copyrighted material from Nintendo.

The game shield currently features the audio and video out connectors, the 1kohm and 470ohm resistors that allow the video to work (along with a library for the Arduino), the Nunchucky board, Arduino I/O pins and the header for the Parallax Serial LCD (which uses digital pin 2.) I may add digitized sound output as well and, perhaps, blinky LED’s and support for my custom three button controller.

arduinovideoThe tricky thing with the video is that it is all handled by the processor. The resistors ‘fool’ most televisions into ‘thinking’ there is a legit video signal. The 1k resistor handles the sync while the other handles the video itself. It was very easy to do and only involved the sacrifice of one video cable (and, since then, I acquired actual connectors so I can use better cables.)  Because the processor does all of the work, and has a very limited memory space (2k of ram, tops) the resolution is a paltry 120×96, though I had to back it down a bit to about 100×96, I needed a bit more ram. There is a common library, called TVOUT, available that most people use, though a few have written their own. The common library provides for three different fonts, lines, circles, inverse video and other niceties. It also can display bitmaps, though they MUST be correctly formatted and converting a bitmap for use is a bit of a pain. You must first resize the bitmap to fit the tiny screen, then you have to save it as a monochrome bitmap, process that file through another program that creates the hex codes that go into an array in the Arduino PROGRAM memory (NOT RAM, but the Flash memory that stores your code.) I’ll post more instructions in a later post.

proto Mario 1So, once I got the video and audio up and working, I played around with some code. First, the TVOUT demo then my own code. The TVOUT demo is pretty cool with a nice rotation sequence. It also displays the bitmap for the schematic to generate the video, an interesting inclusion.

My ‘mario’ game began as a demo. I wanted to move an image around, controlled by the Nunchuck. I wanted to use Spongebob, but I could never get him to look right in such low resolution. Now, how damned hard is it to represent a SPONGE? UGH.  Mario looked much more recognizable and that’s what I went with. Once I had my bitmaps done, moving them around was easy.  I now have Mario, a Koopa Troopa and a Warp Pipe in my level.  I am using another game called Poofy for some direction. Poofy is a side scroller for Arduino that uses some interesting methods and code that are in the public domain (and developed by the people who brought us Hackvision, an Arduino based console similar to what I am doing.)

My next step with the game is a scrolling world, Mario’s ‘weapon’ and a story.

I will be documenting the process, so stay tuned!

For quicker updates, follow Half-Byte on Facebook.