This a learning project. The Input/Output Machine is useful for communication between microprocessors and other electronic devices. It uses serial input to control an output device by simulating a "button press" through Arduino code. In this example, the I/O machine uses Morse code (input) to control a Speak & Read toy (output).
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials
2 breadboards (long)
Arduino MEGA (or clone)
Arduino Nano (or clone)
13 resistors (220 ohm)
13 leds (5 green, 8 red)
13 resistors (1k ohm)
18 NPN transistors
Wires (various lengths)
8 more LEDs
Output Device (a circuit that includes buttons)
Step 2: Set Up Breadboard #1
1) Start with your resistors. Insert each of your 13 resistors into “Row A” on your breadboard. The other end of each resistor goes to the positive rail. Space your resistors, leaving three holes between each one.
Resistors protect your LEDs. They limit the amount of current that is sent to an LED (or other element in a circuit). Without a resistor, you risk sending too much current to an LED and blowing it up (never to work again). Resistors have no polarity (positive and negative side). You may insert them the other way around and it will make no difference.
2) Next, insert your LEDs into “Row B”. LEDs have polarity (a positive leg and a negative leg) so it is important that they are inserted the right way. The anode (positive leg) is inserted into the same column as your resistor. The cathode (negative leg) is inserted into the hole beside it. (Typically, the positive leg of an LED is longer, but use a multi-meter to check the polarity if you are unsure.)
The LEDs (in this project) give visual feedback. They are multiplexed together to create 40 possible outcomes. (This will make more sense later when we get into the code.) The green LEDs represent the columns and the red LEDs represent the rows.
3) Flat side facing you, insert each of your 13 transistors into “Row C” of your breadboard. The left pin (COLLECTOR) of each transistor should be in the same column as the cathode of each LED.
Transistors (as I understand them) are like switches. They can turn things on and off. When code on the Arduino switches a pin to HIGH (ON), the middle pin (called the BASE) receives a small amount of current from the Arduino. Then, and only then, can current flow from the COLLECTOR to the EMITTER.
For more information on transistors visit:
4) Bridge positive and negative rails to each side of the breadboard.
Step 3: Attach to MEGA - Breadboard #2
1) Bridge from the middle pin (base) of each transistor to the other side of the breadboard with a 1k ohm resistor. Each of these will connect to a pin on the Mega.
2) Connect the right pin (emitter) of each transistor to ground.
3) Extend from the middle pin (base) of each transistor to Row A on a second breadboard. Extend from the anode of each LED to Row A of the second breadboard. (This makes things neater and easier to attach to the Mega and output device.)
4) Share a negative (ground) rail with the first breadboard.
5) Working from left to right, the base of each transistor is connected to a pin on the Mega as follows:
COL_W1 = 48; // Wire #1 to Pin 48
COL_W2 = 46; // Wire #2 to Pin 46
ROW_W3 = 44; // Wire #3 to Pin 44
ROW_W4 = 42; // Wire #4 to Pin 42
ROW_W5 = 40; // Wire #5 to Pin 40
ROW_W6 = 38; // Wire #6 to Pin 38
ROW_W7 = 36; // Wire #7 to Pin 36
ROW_W8 = 34; // Wire #8 to Pin 34
ROW_W9 = 32; // Wire #9 to Pin 32
ROW_W10 = 30; // Wire #10 to Pin 30
COL_W11 = 28; // Wire #11 to Pin 28
COL_W12 = 26; // Wire #12 to Pin 26
COL_W13 = 24; // Wire #13 to Pin 24
6) Load some test code. If everything is working as it should, for each letter of the alphabet a column wire should be pulled low while a row wire is pulled high. (This is a simulation of a "button press" on a keyboard.) View the serial port to see what is happening. Send some characters. If you see a green light turn off while a red light turns on, you're good to go!
Here's some test code to load onto your Mega.
If we were to label the green LEDs G1, G2, G3, G4, G5 and the red LEDs R1, R2, R3, R4, R5, R6, R7 and R8, the number of all possible combinations of “OFF Green & ON Red” can be more easily understood. Examples: G1 – OFF & R1 – ON or G1 – OFF & R2 – ON or G1 – OFF & R3 – ON … G2 – OFF & R1 – ON or G2 – OFF & R2 – ON …and so on. The total number of “OFF Green & ON Red” is forty.
So, if you send an “A” through a Serial connection, G1 will go off (while all other green LEDs are on) and R6 will come on (while all other red LEDs are off). For each letter of the alphabet there will be a unique combination of “OFF Green & ON Red”.
“Ah, ha,” you may be thinking. “There are only 26 letters in the alphabet and we have 40 possibilities.” And you are correct. There are still 14 more possible outcomes. Furthermore, you may be asking, could we not double the number of outcomes from 40 to 80 by introducing all the combinations of “OFF Red & ON Green” into the code? And, again, you would be correct. This is called “charlieplexing” and is used in those big LED displays. (Ahhhhh…..the wonders of the LED. A truly marvelous invention.)
For the video, I have added an LED matrix to this test to demonstrate the input of the 26 letters in the alphabet. See video: https://www.youtube.com/watch?v=IFKWUYoDY8M&feature=youtu.be Watch what is happening to the LEDs as each letter lights up.
Step 4: Output Machine
The output machine for this demonstration is a Speak & Read educational toy from the 80’s. It is like the Speak and Spell electronic toy that ET hacked to “phone home”. Remember? http://hackeducation.com/2015/01/13/speak-and-spe...
The Speak & Read electronic toy is the original inspiration for this project. Upon opening it up and examining the circuitry, I discovered that it had a keyboard matrix that could be controlled by 13 wires. Eureka! I could control this toy with an Arduino …5 wires for “columns” and 8 wires for “rows”, giving a total of forty possible key presses on the keyboard. Was there a way to simulate these key presses using the Arduino? Many sleepless nights were spent pondering the possible ways to press a button on the Speak & Read without ever actually touching the keyboard.
This part of the circuit is less understood by me. I only know that it works. If the connections to the Speak & Read were to mimic the LED matrix, the display on the Speak & Read gets messed up. So, to make it work, connect the anode (positive) pins (from breadboard #1) to either a transistor or LED (depending on whether it is a column wire or a row wire). Each of the Column Pins (1, 2, 11, 12, & 13) is connected to the middle (base) pin of an NPN transistor. Each of the Row Pins (3, 4, 5, 6, 7, & 8) is connected to the cathode (negative) pin of an LED.
Working from left to right on the Speak & Read (wires 1-13), attach each row wire to the emitter pin on the transistor and each column wire to the anode pin on the LED.
To trigger a “button press”, a row is pulled HIGH while a column is pulled LOW. For example, to play the game “READ IT" on the Speak & Read , my code calls upon Row 8 and Column 1. For 200 milliseconds (the length of a substantial button push), Row 8 is pulled high, while Column 1 is pulled low. After the "button push", all pins are set low (so that there are no circuits messing up the display on the Speak & Read). Upon receiving a new character on the serial port, all pins are reset (all columns set HIGH and all rows set LOW) so that the I/O Machine is ready to process a new “button press”.
Step 5: Input Machine
The Input Machine can be any device that can send Serial characters to the Mega.
I chose a Morse Code decoder.
The Arduino code has been loaded onto a separate Arduino (in this case a Nano). This Arduino code is based on Budd Churchward’s ”Teaching Arduino to Copy Morse Code”, but you can use any code or device that can output text to the serial port on the Mega.
Budd’s code and setup instructions can be found at: http://www.mypetarduino.com/ReadCode/readCode.18.h...
Finally, a wire is connected between the Arduino Mega and the Nano (TX on the Nano to RX2 on the Mega). This allows data (text) to be sent from the Nano to the Mega. For example, if I tap out an “A” in Morse code on the Nano (di-dah), it will be sent to the Mega and processed.
Oh, yeah. You may need to share a ground wire between components of the Input/Output Machine or you may experience unpredictable results or a non-working machine. Components (both input and output devices) can be individually powered, but will probably need a common negative (or ground) ...especially the two Arduinos.
For the sake of speed, I attached a physical button to Breadboard #1 that is used as a quick "ENTER" key during game play (Row 10, Column 13).
The final code for the Input/Output Machine can be found at: https://gist.github.com/13wires/18e50ee4355da72642...
So, now I have an Input/Output Machine that I can use to practice my Morse coding skills while playing a retro game on a Speak & Read toy. How cool is that? (If you are a geek like me, you will think this is VERY COOL indeed!) See a video of my Input/Output Machine in action.
Step 6: Conclusion
I believe the possibilities of the I/O Machine are limited only by your imagination!
Possible inputs include Bluetooth, spinning LEDs, button push counters, sensors, and tricorders (like the kind on Star Trek :).
Possible outputs include posting to a website (with an ESP8266), sound effects, lights, and games.
What will you invent using the Input/Output Machine?
Have fun! Be safe! And keep learning!
Pawkie (Paula Shedden)
“Good functions, unlike good literature, have predictable endings.” (Calculus for Dummies, P. 48)
Participated in the
First Time Author Contest