Date: January 2017
What is a pin-‘Uino? The term is a portmanteau of the words pinball and Arduino. As you are probably reading this article in Pinball News's Learn How section, you may be familiar with pinball machines. However, you may not be familiar with the Arduino.
Arduino is an open-source platform for ATmega 168 and 328 microcontrollers. You can use the microcontroller as part of your own custom pinball add-ons, modifications and toppers.
Arduino is the American-branded version. Genuino is the version branded for the rest of the world. Save labeling differences, both boards are very similar. An Arduino UNO board and Genuino UNO board are juxtaposed, below.
For more information about using an Arduino microcontroller, see the instructions put together for middle schoolers, Intro to Arduino. Be sure to read this instruction article before continuing with this project article (pin-‘Uino).
Don’t be fooled by the simplicity of the instructional article or this project article. Some very complex programs (sketches) can be run on most Arduino microcontrollers and their clones. In fact, entire pinball machines have been built using the surprisingly powerful Arduino and clever programming.
In a set of previous Pinball News articles, we shared with you relay controllers you could use to make your own custom pinball add-ons, modifications, and toppers.
Note: See these articles for information, description of discrete electronic parts and where to purchase those parts.
As in the previous two articles, although we are still going to use a light dependant resistor (LDR), this third article moves on from using a simple relay controller to a microcontroller; namely the Arduino UNO (R3, 5 Volts).
Note: See the end of this article for additional parts and purchasing information.
The discrete electronic component known as a relay is considered a 'dumb' device. We will be using a 'smart' (programmable) device; a microcontroller.
Though not capable of handling high power like a relay, with the 40 milliamp maximum peak (per pin) current handling capabilities of the UNO we can safely run a handful of Light Emitting Diodes (LEDs) to add new lamps to our pinball machines or pinball projects.
For the learning purpose of this project and as to NOT overload the microcontroller, we will be using a single indicating Light Emitting Diode (LED). An alternate sketch and additional add-on method for using a UNO microcontroller to light multiple LEDs are both mentioned later in this article, but they are not covered in much detail. If you want to light multiple LEDs see the links in the Intro to Arduino article and at the end of this article for more information.
In this primer article, we will be using either a single T-1 3/4 (ø5 mm) or T-3 1/4 (ø10 mm) radial leaded discrete electronic component. One of several colors will work. This type of LED usually requires about 20mA of direct current. Unfortunately, you can’t just plug an LED straight into your +5 Volt UNO. You must use a dropping resistor in series with the LED.
The LED/resistor table was made specifically for use with +5 Volt Arduino boards. From the table, you can see that the smaller the voltage for a specific LED, the larger the Ohm value for its dropping resistor. The larger Ohm value of the dropping resistor, the greater voltage 'dropped' across that resistor.
For our purpose, a 1/4 Watt axial leaded resistor should work just fine. This dropping resistor needs to be rated at a 1/4 watt to handle the electrical power going through it. And, its lead thickness is good for plugging into the headers of the UNO.
Look back at the LED/resistor table, notice there are five different calculated dropping resistor Ohm values. From an electronics engineering viewpoint and in practical use, only three nominal Ohm values are needed: 200, 150, and 100 Ohm. This is because the calculated Ohm values are close enough to the nominal values when lighting discrete indicator-type LEDs.
From a literal human viewpoint, due to the way we humans perceive brightness it is hard for us to even notice the slight change in brightness; when we use a near value resistor versus the calculated value when lighting a LED. This is an example of the inverse-square law of light in effect with human eye physiology.
The LED/resistor table shows both actual calculated values and nominal values. The calculated values are real values, whereas the nominal values are easily chosen close values, either for convenience or practical availability. In this case, calculated resistor values are based on useful nominal voltage values for each LED color.
HINT 1: Remember, even if you calculate the actual dropping resistor value, you may only be able to easily purchase a close nominal value.
HINT 2: In the case of round-up to the neared available nominal value, you can see from the LED/resistor table and its explanations that an increased difference of even 25 Ohms won’t make any practical difference.
HINT 3: We’ve had great luck and even better results with (and l-o-v-e) 'Gumdrop LEDs'. Use your favorite search engine if you want to find them.
You may either use the table provided as a practical reference, or you may choose to calculate the actual dropping resistor value (Rdrop) for your own LED. If you wish to calculate the actual value of you own dropping resistor, start by using the operating voltage of your UNO. Additionally, you will need to know the following:
The following formula is based on Ohm’s Law. Use the actual values above in the formula below:
Rdrop = (Vin – Vled) / Iled
When reviewing manufacturer’s specification, you many need to substitute the following technical names in the formula below:
R = (Vin – Vf) / If
If you chose to perform the dropping resistor calculation (Rdrop or R), why not use your UNO?
Enter the following sketch into your UNO to easily calculate the value of Rdrop or R.
NOTE 1: This program has been released under GPL. Freely use and modify the CalcLEDDropResist sketch.
NOTE 2: In order to use communication via the Serial Monitor window, you will need to keep a USB cable connected between your computer and your UNO.
The Calc_LED_Drop_Resist.INO sketch is a simple Ohm’s Law calculator/solver for single resistor/LED combinations.
Open the Arduino application and copy/paste the following sketch over the entire staring program in a new sketchbook window. Save the sketch as Calc_LED_Drop_Resist.INO. For information on how to do this, see Intro to Arduino.
You should see something similar to the following:
Use your UNO to calculate dropping resistor values:
Use the specific values from the Manufacturer’s specifications:
NOTE: The sketch will then automatically reset; for you to calculate as many dropping resistor values as you need.
In the end, programming comes down to just ones (1s) and zeros (0s). Due to limitations such as these, programmers must find creative solutions to complete their projects.
One creative solution can save us from having to solder. That solution is to use a clever combination of (2.54mm / 0.1 inch DuPont connector) male and female jumper cables.
The right combination of a variety of jumper cables works surprisingly well, using a little hot glue to shore up each junction.
The following pictures show such DuPont jumper cables, on their own and in use.
UNO Board LED/Resistor Jumper Cable:
TROUBLESHOOTING: If your LED does not light after you run your UNO sketch, simply turn around the LED.
LDR on the UNO board:
NOTE: You may also remotely mount the LDR on jumper cables, although it may be best to keep it on the UNO board.
IMPORTANT NOTE: When you are all done with wiring and programming, be sure to put your microcontroller LDR into a project box or use some other means to ensure your UNO project and its components don’t short to anything.
NOTE 1: This program has been released under GPL. Freely use and modify the pin_uino sketch.
The pinUino.INO sketch turns on a single LED when the value read from the LDR is above a certain threshold, eg. during normal game play, when all the GI lights of your pinball machine are lit.
Open the Arduino application and copy/paste the following sketch over the entire staring program in a new sketchbook window. Save the sketch as pin_uino.INO. For information on how to do this, see Intro to Arduino.
You should see something similar to the following:
LDR practical values:
NOTE: These reading can give you some idea of the useful range values of your specific LDR.
IMPORTANT NOTE: When you are all done with wiring and programming, be sure to put your microcontroller LDR into a project box. Or, use some other means to ensure your Arduino project and its components don’t short to anything.
TROUBLESHOOTING: If your LED doe not light after you run your UNO sketch, simply turn around the LED.
One advantage of using a microcontroller is the ease of using software changes over hardware changes.
Keeping the same hardware configuration, you can make the LED turn off when a certain value is read from the LDR. eg. during 'blackout' mode, just before multiball mode. Simply change one number in your software. Unlike in the other two articles mentioned at the beginning of this article, there is no need to rewire components.
To change from Light Sensing to Dark Sensing, simply change the greater-than sign in:
Don’t forget to also change your comment from:
Is the LED changing states not quite as you expected?
Simply change the number value of the threshold in:
to adjust the event threshold.
NOTE 1: The values from the Serial Monitor can help you select a useable threshold.
NOTE 2: Almost any LDR can be used with an adjustment in software.
You can make the LED blink, flash, fade, and perform other visual effects. Use the built-in examples of the Arduino software, and the built-in LED of the UNO board to see some of the ways you can light an LED. Be sure to explore all the built-in examples, not just 'Blink'.Navigate (drill down) to: File \ Examples \ 01.Basics \ Blink
Where do I get programs to use with my project?
Now may be the time for you to start writing your own sketches. However, one last sketch is included with this article:
This sketch lights two LEDs, one for each of two different conditions.
NOTE 1: The potentiometer may be replaced with a LDR
NOTE 2: Move the jumper side of the LED in the previous set up from pin '11' to pin '9'.
Put the following sketch in a new sketchbook window. Save the sketch as Conditional_If_Statements_with_Hysteresis.INO and view the Serial Monitor window as previously shown in this article.
Luckily for us, Arduino is open source. Just use your favorite search engine to search for example programs, additional help and other useful resources.
Once programmed, your Arduino can continuously run a loaded sketch without your computer. Just apply the proper power.
To power a project needing 1 Amp or less of peak current, you can use a spare USB cable (like you used to program your UNO) and an AC/DC (+5 Volt DC @ 2 Amp) USB phone charger. See the following picture of a custom holiday pinball topper.
USB Phone Charger to Project:
To power a more power-hungry project, use a Positive 9 to 12 Volt Direct Current (DC) power supply; rated at twice the estimated peak current of your project. For several Arduino boards, including the UNO, that power supply will need to have a 2.1 mm center-positive plug; which friction fits into the board's power jack.
This article introduced you to the Arduino/Genuino UNO. This microcontroller has several different 'flavours' and 'shrinkified' versions. Use your favorite search engine and the links at the end of this article to learn about different boards and where to purchase them.
There are many useful add-ons for the UNO. These add-ons may help you in the learning and prototyping stages, and may even keep you from having to solder your final project.
A board which plugs directly into the UNO main board is called a 'shield'. To name just a few, there are: Breadboard Shield (for directly plugging in discrete components), LED Shield (for multiple and/or multi-color LEDs), Motor Shield (for driving different motors), and Relay Shield (for controlling power to other devices).
Use your favorite search engine and the links at the end of this article to learn about different shields and where to purchase them. Any type of shield can usually be purchased preassembled. If you buy your shield as a kit, you can assemble it yourself and use the experience to practice soldering.
Pictured below is a Breadboard Shield.
There are learning kits, project cases and various modules available for many Arduino/Genuino boards; not just the UNO.
This next example shows a 5 Volt Arduino/Genuino compatible module; a discrete RGB LED called NeoPixel. The NeoPixel has its own built it microcontroller and it can utilize 'Libraries'. Libraries are sketches, put together by people from the Arduino/Genuino community to help make programming easier. The NeoPixel and Libraries are only mentioned in this introductory article to show just a tiny bit more of what you can do. Use your favorite search engine and the links at the end of this article to learn about different modules and where to purchase them.
Pictured below is a UNO/NeoPixel cycling through different colors and brightness levels. As the peak current requirements of this combination are only about 80 mA, a battery powered 1 Amp phone charger can easily power this set up for an entire night.
Lucky for us, the Arduino software has built in help. Also, be sure to 'Visit Arduino.cc'.
Navigate to: Help\User Chosen Section\
Sorry, but Pinball News does not provide Arduino/Genuino support. However, we’d love to hear about and see your projects.
© Pinball News 2017