Change internal logic from relays to an Arduino
Redo
![© Lead Image © donatas1205, 123rf.com © Lead Image © donatas1205, 123rf.com](/var/linux_magazin/storage/images/issues/2022/260/new-tech-retrofit/po-27227-123rf-donatas1205_123rf_com-steampunk_gears_resized.png/806050-1-eng-US/PO-27227-123RF-donatas1205_123rf_com-Steampunk_Gears_resized.png_medium.png)
© Lead Image © donatas1205, 123rf.com
An electronic project at a local science center was showing its age, calling for a refresh: in this case, rebuilding it almost from scratch with an Arduino instead of relays.
A museum exhibit called Buzzwire looks like outlines of two oversized hands giving you a high five (Figure 1). Each hand has a metal handle with a loop, and your goal is to move the loops up and down the hand without touching it. For an even bigger challenge, you can try to do both hands at once in the same or opposite directions. If either loop touches the hands, a buzzer and light come on and the handle vibrates.
The original circuitry for the hands comprised interconnecting timer relays to switch the assorted components. The design had no microcontrollers or anything smarter than a switch, which had several drawbacks – but the main one was that if the puzzle was abandoned mid-run, the light, buzzer, and vibration motor would run continuously until the handles were removed.
Because one of the components had burned out on more than one occasion, the decision was made to rework the exhibit with upgraded technology that addresses some of its problems.
New Tech
To design the new controller, I started with an Arduino Mega because I had one on-site. An Arduino Uno would have worked just as well, but in this case, the Mega is a standard part, is easy to trade out, and is kept in stock. (See the "Physical Rebuild" box.)
Physical Rebuild
While I rebuilt the control electronics, I sent the case out to be rebuilt as well. The original design was made out of plywood and had started to accumulate a lot of dings and scratches. The case rebuild was very helpful because it showed areas that needed to be reinforced. Ultimately, I had the entire front panel replaced with Delrin, a very hard plastic that will withstand wear and tear better than plywood. It also brings a fresh look for anyone that has seen it before.
The physical rebuild also incorporated larger vibration motors in the handles. The old version used pager motors, which were more heard than felt. The machine shop I worked with fabricated new handles from scratch that incorporated larger motors, making the buzz much more noticeable.
I started by assigning pins on the Arduino. The handles each need an input pin, so I started with those. Other than timers the handles are the only inputs to the circuit design. For outputs, I wanted several things to operate with different timing, so I set up four pins to control relays, which will handle both the assorted voltages and the ability to switch things on and off at different times (Table 1; Figure 2).
Table 1
Arduino Connections
Pin | Connection |
---|---|
2 |
Left handle input |
3 |
Right handle input |
8 |
Relay 1 control signal |
9 |
Relay 2 control signal |
10 |
Relay 3 control signal |
11 |
Relay 4 control signal |
GND |
Left hand (puzzle) |
GND |
Right hand (puzzle) |
GND |
Relay board ground |
5V |
Relay board power |
![](/var/linux_magazin/storage/images/issues/2022/260/new-tech-retrofit/figure-2/806056-1-eng-US/Figure-2_large.png)
Finally, for ease of connections into the exhibit itself, I assembled everything on a piece of plywood and brought all of the connections to a pair of barrier strips (Table 2). Each hand got its own barrier strip, and the two are identical except for power input on connections 11 and 12.
Table 2
Barrier Strip Connections
Connection No. | Left Barrier Strip | Right Barrier Strip |
---|---|---|
1 |
Hand (sculpture) |
Hand (sculpture) |
2 |
Handle |
Handle |
3 |
Ground (1) |
Ground (1) |
4 |
Ground (1) |
Ground (1) |
5 |
Ground (1) |
Ground (1) |
6 |
12V (switched) (2) |
12V (switched) (2) |
7 |
12V (switched) (2) |
12V (switched) (2) |
8 |
12V (switched) (2) |
12V (switched) (2) |
9 |
Ground |
Ground |
10 |
5V (switched) |
5V (switched) |
11 |
Ground |
Ground |
12 |
12V power in |
5V power in |
(1) Interchangeable ground terminals. Choose one. |
||
(2) Interchangeable 12V terminals. Choose one. |
Logic Flow
Now that all of the hardware was assembled and simple test programs tested the activation of the relays, which in turn vibrated the handle or turned lights and buzzers on and off, I needed to figure out the flow of the control program.
One of the things that is often overlooked in a project is documentation. So as not to fall into that trap, I made copious notes and typed them up into a documentation package. One of the things I included was a flowchart to describe the logic (Figure 3; see the "Flowcharts" box).
Flowcharts
Flowcharts are an excellent way to visualize flow through a system, program, or other process. In the early days of computers when programs were built on punched cards and you "programmed" on paper, they were an essential tool to understand flow. Although still useful for design, they aren't at the forefront, as they once were. Flowcharts are seeing a resurgence, though, in online forms where data moving through a system is now visualized in the flowchart style that once originally designed it.
![](/var/linux_magazin/storage/images/issues/2022/260/new-tech-retrofit/figure-3/806059-1-eng-US/Figure-3_large.png)
Walking through the flowchart, the first decision is the diamond right below Start asking whether the ring is touching the puzzle. If not (exit to the right), you wait 250ms, turn off the relays, and return to the original decision. It should be noted that Turn relays off will happen even if they are already off.
If the ring is touching the puzzle (exit the decision through the bottom), then turn the relays on. The next decision diamond checks whether the relays have been on for more than 10 seconds. If so (exit right), you turn off the relays and return to the first decision. If not (exit bottom), just return to the first decision.
That process will loop infinitely until power is removed from the Arduino. You should also note that this flowchart shows a simplified process. I don't specify assigning variables or duplicating the process for both hands, just the theory of operation about what's happening inside the logic. In this way, the program flow is easy for even a non-programmer to follow.
Code
Arduino code is made up of two sections. The setup
section runs once when the Arduino powers up, and the loop
section then runs infinitely until power is removed. As their names imply, they are designed to initialize everything and then run continuously.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.
-
SUSE Offers CentOS 7 Support with Liberty Linux Lite
SUSE's Liberty Linux support offering now includes CentOS 7, which means businesses won't be forced to migrate those servers for some time.
-
Ubuntu's App Center Finally Supports Local Installs Again
If you regularly download .deb files and would prefer a GUI method of installing, Ubuntu has your back.
-
AlmaLinux Now Supports Raspberry Pi 5
If you're looking to create with the Raspberry Pi 5 and want to use AlmaLinux as your OS, you're in luck because it's now possible.
-
Kubuntu Focus Releases New Iterations of Ir14 and Ir16 Laptops
If you're a fan of the Kubuntu Focus laptops or have been waiting for the right time to purchase one, that time might be now.
-
NixOS 24.05 Is Ready for Prime Time
The latest release of NixOS (Uakari) has arrived and offers its usual reproducible, declarative, and reliable goodness.
-
Linux Lite 7.0 Officially Released
Based on Ubuntu 24.04 and kernel 6.8, Linux Lite version 7 now offers more options than ever.
-
KaOS Linux 2024.05 Adds Bcachfs Support and More
With updates all around, KaOS Linux now includes support for the bcachefs file system.
-
TUXEDO Computers Unveils New Iteration of the Stellaris Laptop Line
The Stellaris Slim 15 is the 6th generation and includes either an AMD or Intel CPU