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."
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.
- 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:
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 email@example.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.