Introduction: HackerBox 0047: Old School
Greetings to HackerBox Hackers around the world! With HackerBox 0047, we are experimenting with keyboard interfacing for microcontrollers, VGA video signal generation, old school BASIC ROM computers, microSD storage devices, locksport tools, and bootable Ubuntu Linux USB sticks.
This Instructable contains information for getting started with HackerBox 0047, which can be purchased here while supplies last. If you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at HackerBoxes.com and join the revolution!
HackerBoxes is the monthly subscription box service for enthusiasts of electronics and computer technology - Hardware Hackers - The Dreamers of Dreams.
Step 1: Content List for HackerBox 0047
- Exclusive Old School VGA PC Kit
- Two Arduino Nano Modules 5V 16MHz
- 200 Piece LED Kit in Plastic Storage Box
- Aluminium USB Flash Drive 8GB
- 6-in-1 Pocket Locksport Tool
- Precision Wire Cutters
- MicroSD Breakout Module
- MicroSD USB Reader
- Two 40 pin Male Breakaway Headers
- Female-Female 10cm DuPont Jumpers
- Ubuntu Linux Decal
Some other things that will be helpful:
- Soldering iron, solder, and basic soldering tools
- Computer for running software tools
- Salvaged VGA monitor (try a thrift store or old storage room at work)
- PS/2 keyboard (try a thrift store or old storage room at work)
Most importantly, you will need a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.
There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we really appreciate your taking a few minutes to read the FAQ.
Step 2: Locksport
Locksport is the sport or recreation of defeating locks. Enthusiasts learn a variety of skills including lock picking, lock bumping, and other techniques traditionally used by locksmiths and other security professionals. Locksport enthusiasts enjoy the challenge and excitement of learning to defeat all forms of locks, and often gather together in sport groups to share knowledge, exchange ideas, and participate in a variety of recreational activities and contests.
For a nice introduction, check out the MIT Guide to Lock Picking.
Also, watch this video and check out the amazing links in the description of the video.
TOOOL (The Open Organisation Of Lockpickers) is an organization of individuals who engage in the hobby of Locksport, as well as educate its members and the public about the security (or lack thereof) provided by common locks. "The mission of TOOOL is to advance the general public knowledge about locks and lockpicking. By examining locks, safes, and other such hardware and by publicly discussing our findings we hope to strip away the mystery with which so many of these products are imbued."
ETHICAL CONSIDERATIONS:
Carefully review, and take serious inspiration from, TOOOL's strict code of ethics which is summarized in the following three rules:
- Never pick or manipulate with the aim of opening any lock that does not belong to you, unless you have been granted explicit permission by the lock's rightful owner.
- Never disseminate knowledge or tools of lockpicking to individuals whom you know or whom have reason to suspect would seek to employ such skills or equipment in a criminal manner.
- Be mindful of the relevant laws concerning lockpicks and related equipment in any country, state, or municipality where you seek to engage in hobbyist lockpicking or recreational locksporting.
Step 3: Trim All the Leads
When soldering, there are always leads to be trimmer. Not to mention cutting the green wire while disarming dangerous movie props.
Use this tool in good health. Heed the warnings shown here from the manufacturer about always wearing eye protection. They do not want you to poke any of your eyes out. Neither do we.
Step 4: Arduino Nano Microcontroller Platform
We all love the Arduino Nano and this month we're gonna need two of them! The included Arduino Nano boards comes with header pins, but they are not soldered to the modules. Leave the pins off for now. Perform these initial tests on both Arduino Nano modules prior to soldering on the header pins. All that is needed is a microUSB cable and both Arduino Nano boards just as they come out of the bag.
The Arduino Nano is a surface-mount, breadboard-friendly, miniaturized Arduino board with integrated USB. It is amazingly full-featured and easy to hack.
Features:
- Microcontroller: Atmel ATmega328P
- Voltage: 5V
- Digital I/O Pins: 14 (6 PWM)
- Analog Input Pins: 8
- DC Current per I/O Pin: 40 mA
- Flash Memory: 32 KB (2KB for bootloader)
- SRAM: 2 KB
- EEPROM: 1 KB
- Clock Speed: 16 MHz
- Dimensions: 17mm x 43mm
This particular variant of the Arduino Nano is the black Robotdyn Nano. In includes an on-board MicroUSB port connected to a CH340G USB/Serial bridge chip. Detailed information on the CH340 (and drivers, if needed) can be found here.
When you first plug the Arduino Nano into a USB port of your computer, the green power light should come on and shortly after the blue LED should start to blink slowly. This happens because the Nano is pre-loaded with the BLINK program, which is running on the brand new Arduino Nano.
SOFTWARE: If you do not yet have the Arduino IDE installed, you can download it from Arduino.cc
Plug the Nano into the MicroUSB cable and the other end of the cable into a USB port on the computer. Launch the Arduino IDE software. Select "Arduino Nano" in the IDE under tools>board and "ATmega328P (old bootloader)" under tools>processor. Select the appropriate USB port under tools>port (it is likely a name with "wchusb" in it).
Finally, load up a piece of example code:
File->Examples->Basics->Blink
Blink is actually the code that was preloaded onto the Nano and should be running right now to slowly blink the blue LED. Accordingly, if we load this example code, nothing will change. Instead, let's modify the code a little bit.
Looking closely, you can see that the program turns the LED on, waits 1000 milliseconds (one second), turns the LED off, waits another second, and then does it all again - forever.
Modify the code by changing both of the "delay(1000)" statements to "delay(100)". This modification will cause the LED to blink ten times faster, right?
Let's load the modified code into the Nano by clicking the UPLOAD button (the arrow icon) just above your modified code. Watch below the code for the status info: "compiling" and then "uploading". Eventually, the IDE should indicate "Uploading Complete" and your LED should be blinking faster.
If so, congratulations! You have just hacked your first piece of embedded code.
Once your fast-blink version is loaded and running, why not see if you can you change the code again to cause the LED to blink fast twice and then wait a couple of seconds before repeating? Give it a try! How about some other patterns? Once you succeed at visualizing a desired outcome, coding it, and observing it to work as planned, you have taken an enormous step toward becoming a competent hardware hacker.
Before soldering anything to them, test out both of the Arduino Nano modules by loading a custom program onto each and ensuring that it runs correctly.
If you would like additional introductory information for working in the Arduino ecosystem, we suggest checking out the guide for the HackerBoxes Starter Workshop, which includes several examples and a link to a PDF Arduino Textbook.
Step 5: Old School VGA PC Kit
Old School VGA PC Kit Contents:
- Old School VGA PC Printed Circuit Board
- Two Arduino Nano Microcontroller Modules
- HD15 VGA Connector
- Mini-DIN PS/2 Keyboard Connector
- Two 68 Ohm Resistors
- Two 470 Ohm Resistors
- Piezo Buzzer
Over the next few steps, you will assemble and explore the Old School VGA PC Kit. Obviously, this will require some soldering. There are a lot of great guides and videos online about soldering (for example). If you feel that you need additional assistance, try to find a local makers group or hacker space in your area. Also, amateur radio clubs are always excellent sources of electronics expertise.
A few design notes: It is suggested that once both Nanos are installed, only plug one of them at a time into USB power, never both at once. Similarly, both Nanos can drive the buzzer from their A0 pin. Only ever configure one of the A0 pins as an output, never both at the same time. There is a row of I/O pins (header J1) just below the two MCUs (see schematic for pin assignments). The lower row (header J2) is just a "breadboarding space" and it does not connect to anything within the PCB.
Step 6: Old School PC - PS/2 Keyboard
To test out he keyboard interface and library, first populate only two items onto the PCB:
- Main MCU (Arduino Nano)
- Mini-DIN PS/2 Connector
The Main MCU requires the two long black header rows. The six pin (2x3) header is not used.
Install Paul Stoffregen’s PS2Keyboard Library for Arduino.
Within the Arduino IDE, open File>Examples>PS2Keyboard>Simple_Test
From the PCB schematic in the previous step, you can see that KBCLK is on pin D3 (not D5 as assumed by the example), so make sure the pin defines in the examples are set to:
const int DataPin = 8;
const int IRQpin = 3;
Then program that code to the Main MCU, connect a PS/2 keyboard, open the Arduino Serial Monitor to 9600 bps, and start typing.
Keyboard Scan Codes Demystified
Note that most older USB keyboards are combination USB and PS/2 keyboards and can be used with an adapter or rewired to connect to a PS/2 port. Those dual interface keyboards usually came with a small USB-to-PS/2 adapter plug. However, newer USB keyboards that did not come with a PS/2 adapter will usually not provide the PS/2 signals and will not work with such an adapter.
Step 7: Old School PC - VGA Video Output
Solder up the other Arduino Nano (VIDEO MCU), the four resistors (note there are two different values), the buzzer, and the VGA connector. Once again the six (2x3) pin header of MCU is not used.
Install Sandro Maffiodo's VGAX Library for Arduino. Plug in a VGA Monitor. Enjoy the example files under file>examples>VGAX
The git repo for the VGAX library has some highly educational information and recourses teaching how the humble Arduino is hacked into generating a VGA(ish) video signal.
Step 8: Old School PC - BASIC Programming Language
These keyboard, video, and MCU processing blocks can be combined into a simple, yet elegant, 8-bit VGA PC capable of supporting the BASIC programming language. Props to Rob Cai for putting all of these pieces together.
BASIC (Beginner's All-purpose Symbolic Instruction Code) is a general-purpose, high-level programming language emphasizing ease of use. Almost universally, home computers of the 1980s had a ROM-resident BASIC interpreter, which the machines booted into directly. These old school micros includes various types of Apple II, Commodore, TRS-80, Atari, and Sinclair machines. (wikipedia)
The dual MCU designs uses a first Arduino as the MAIN MCU, where TinyBasic Plus and PS2 keyboard library are uploaded. The second VIDEO MCU is used as a graphic display generator running the VGAX library. The VIDEO MCU can generate 4 color, 10 rows x 24 columns of ASCII characters.
Arduino I/O can be directly driven from BASIC programs. As shown in this video, a LED blinking is driven by a few program lines. The BASIC code can even be saved to the MCU's EEPROM.
THE CODE: Sketched for both MCUs and various other details are available in Rob Cai's Instructable for the project.
PROGRAMMING NOTE: When programing the MCU modules after they are on the PCB, sometimes trouble is encountered since the serial interfaces are connected and can interfere with the programming. Just hold the reset button on the Main MCU while the USB cable programming the Video MCU, and vice versa while the USB cable is programming the Main MCU.
Step 9: Run Ubuntu Linux Via USB Stick
Ubuntu is a free and open-source Linux distribution based on Debian. Ubuntu is released every six months, with long-term support (LTS) releases every two years. Ubuntu is developed by Canonical and the user community. Ubuntu is named after the African philosophy of ubuntu, which Canonical translates as "humanity to others" or "I am what I am because of who we all are". (wikipedia)
Why not try out Ubuntu on a USB stick?
- Install or upgrade Ubuntu
- Test out the Ubuntu desktop experience without touching your PC configuration
- Boot into Ubuntu on a borrowed machine or from an internet cafe
- Use tools installed by default on the USB stick to repair or fix a broken configuration
Creating a bootable Ubuntu USB stick is very simple, especially from Ubuntu itself. The process is covered in few steps here.
WARNING: Get in the habit of never trusting random USB storage devices. Yes, even the one included in this box. Don't ever allow anything to AutoRun from an unknown storage device. Most operating systems don't allow AutoRun as part of standard security practices, but on a Windows box, you should disable AutoRun/AutoPlay. Don't run or open anything you find on the storage device. If you want to make use of the storage device, wipe it and reformat it.
Step 10: MicroSD TF Breakout Module
What is the difference between a TF Card and a MicroSD Card? (source)
The tiny mobile storage device known as MicroSD card was first produced by SanDisk Corporation under the name TransFlash, back in 2004, and at the time it was introduced as the smallest external memory device in the world. Following its success in the mobile phone market, the TransFlash card was formally adopted by the current authority in digital storage, the SD Card Association, as part of the third category digital storage device in the official Secure Digital umbrella. The other two devices are MiniSD, and SD Memory Card. At some point along the way, SanDisk Corporation changed the device’s name to MicroSD Card and started producing what we now use as a standard memory storage chip, which the majority of mobile phones are designed to accommodate.
Note that MicroSD memory devices are 3.3V devices, so the simple breakout module shown here should be used in 3.3V systems. For example, with 3.3V microcontrollers. You will often find instances in the wild (example one, example two) of projects that just jam 5V I/O signals into MicroSD cards. These do generally work if you like to live dangerously, but they may be less stable and can even damage the MicroSD card. More correct/robust solutions for using MicroSD cards with 5V Microcontrollers include level-shifters or voltage-divider networks (both discussed here).
Step 11: Mandelbrot Zoom - Don't Fall In!
Images of the Mandelbrot set exhibit an elaborate and infinitely complicated boundary that reveals progressively ever-finer recursive detail at increasing magnifications. The "style" of this repeating detail depends on the region of the set being examined. The set's boundary also incorporates smaller versions of the main shape, so the fractal property of self-similarity applies to the entire set, and not just to its parts. The Mandelbrot set has become popular outside mathematics both for its aesthetic appeal and as an example of a complex structure arising from the application of simple rules. It is one of the best-known examples of mathematical visualization and mathematical beauty. (wikipedia)
Step 12: HackLife
We hope you are enjoying this month's HackerBox adventure into electronics and computer technology. Reach out and share your success in the comments below or on the HackerBoxes Facebook Group. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.
What's Next? Join the revolution. Live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month. Surf over to HackerBoxes.com and sign up for your monthly HackerBox subscription.
22 Comments
Question 1 year ago
So I connected mine and it constantly is making a noise out of the speaker. I read to not output from both A0's at the same time, does that mean I should just disconnect that PIN on one of them.
Tip 3 years ago
Some of the pins on the VGA connector might not exactly fit the board easily. You may need to bend the first couple of rows of pins forward very slightly before inserting in order to fit. Don't try to brute force it. Also, don't use the 6 pin header on the arduinos, even though there's a spot for them on the board, they didn't fit and you won't need them.
Reply 3 years ago
Thanks for the tip...I am having that exact problem.
Cheers!
Question 3 years ago
I’m getting this “not enough memory" error. What am I doing wrong? Thanks!
Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Nano, ATmega328"
Sketch uses 14,036 bytes (45%) of program storage space. Maximum is 30,720 bytes.
Global variables use 2,129 bytes (103%) of dynamic memory, leaving -81 bytes for local variables. Maximum is 2,048 bytes.
processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.
at processing.app.debug.Compiler.size(Compiler.java:338)
at processing.app.debug.Compiler.build(Compiler.java:117)
at processing.app.Sketch.build(Sketch.java:1162)
at processing.app.Sketch.build(Sketch.java:1137)
at processing.app.Editor$BuildHandler.run(Editor.java:2032)
at java.lang.Thread.run(Thread.java:745)
Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Answer 3 years ago
It seems if you use Arduino 1.6.4 you will encounter this problem, even though that's repeated several times as the correct target version. I just got it to compile and load with 1.6.13.
Reply 3 years ago
Thanks! I'll have to dig out that board and give it a try. I still have the board on the coner of my desk.
3 years ago
I had no problem with the video but the keyboard is giving me fits. (The above mentioned "hold the reset on the other nano" worked well) During the initial keyboard checkout I got mostly gibberish rather than codes back but pressed on to the next portion only to have the old school computer completely ignore any keyboard input. Anyone else have issues and advice? thanks!
Reply 3 years ago
I was not getting any response from the keyboard after I loaded the vga driver, and teh tiny basic. For kicks I unplugged the keyboard, and plugged it back in. Bam. I got my tiny basic responding. I think something confused the keyboard. I have the cheapest ps2 keyboard you can buy.
Reply 3 years ago
I wasn't getting anything, and it blocked me for a while. With the logic analyzer in box 49 I could verify I was getting the clock, and data signals correctly from the keyboard(1M samples at 100khz worked nicely). It also helped me understand the code, which uses the clock as an interrupt to read the data.
It might help you see where the problem is. My problem was that I need new glasses because I read the 3 as a 5 a few dozen times.
Question 3 years ago
Why is it off the screen to the left?
3 years ago on Step 10
I got everything soldered on fine and my Arduino's op tested fine.
The one thing I'm still fuzzy about is where exactly the SD card reader is supposed to go on this board for ubuntu.
3 years ago
I chose to install headers I purchased separately onto the board so that I could remove the nanos easily for other tinkering projects. I also chose to install the 2x3 pin sets on each, but intentionally stuck them out of the top of the nanos for easy patching in projects I might use them in later. I second that you may need to ever so slightly bend a row of the VGA pins to get them inserted. I moved my back row, about 1 pin width back, each.
3 years ago
Example video graphics images are way off center. Off the left side of the screen. Anyone else have this issue? I have not moved on to the 8-bit computer emu part of the kit build yet as I am still trying to sort out the video issue. Wondering if I am the only one...
3 years ago
Got the old school computer up and running but I'm missing the first 4-5 characters on the left side. I've reloaded the vga emulator several times and I'm running IDE 1.6.4 as specified. You can see the output in the "I made it pic above". Any suggestions would be appreciated. Thanks.
3 years ago
Make sure that you upload the vga sketch to the video mcu BEFORE soldering to the pcb. The RX pin on the Video controller must not have input in order to be programmed, so if you solder the MAIN and VIDEO on the PCB you'll have to ommit that pin or desolder the RX pin in order to be able to program the VGA. Make it easy on yourself and just program the VGA before soldering to the board. ;-P learned the hard way.
Reply 3 years ago
Yup, just discovered this the hard way. Looks like an interesting bit of desoldering coming my way.
Reply 3 years ago
Did you try the trick of holding the reset button on the Main MCU while programming the Video MCU, and then vice versa?
3 years ago
All these many years I would tell myself....."this is the week that I'm going to clear those useless old computer parts out of the attack"....but I never got around to it. Decades of procrastination have finally paid off! Who knew? Another thing that I'm glad I did was solder headers to the PCB board so that I could swap the Nano's in and out. Like others have mentioned, I can't seem to load code onto the Nano's when they are plugged into the board. Thinking ahead payed off.
3 years ago
The VGA connector was a bit of a bugger but I got it all soldered up. I followed the TinyBasic instructable and I am running BASIC programs on an Arduino. Eat your heart out MicroPython! ;)
Tip: If you are having problems uploading sketches after the boards are soldered on the PCB. While a sketch is uploading to one of them, hold down the Reset on the other. That worked for me.
3 years ago
How dare you assume that I have a PS/2 keyboard and a VGA monitor! Well, I do :)
You weren't kidding about the pins on the VGA connector. I used a female header to bend all the pins in a row at the same time. Then, as I was pushing the connector into the PC board, I gently wiggled it around at the same time. Took uncharacteristic patience from me.
I soldered female headers on the PC board for the NANOs so that I may take them out and use them again someday. It seems like it was a good thing I did that because I found that I couldn't get either NANO script to upload or to work properly when they were plugged in together. Everything worked great when they were plugged in separately.