Arduinos are everywhere in hobby electronics, but you rarely see them in factories or industrial control panels. In their place you find PLCs (Programmable Logic Controllers). If you have ever wondered what makes them different, or whether you could run real PLC logic on a cheap Arduino, then this is the project for you.
The video is sponsored by Altium Develop, a cloud platform that brings electrical, mechanical, software, and sourcing teams together in one shared workspace. Get your free trial here.
Arduino vs PLC: A Different Way of Thinking
With a standard Arduino sketch you have a setup function and then a loop that runs continuously. That works fine for simple projects, but it has a real weakness: a single delay or an infinite condition can freeze the entire program. In an industrial machine, if a microswitch needs to trigger something, you cannot afford to have your code stuck somewhere else in the loop.
PLCs solve this with what is called a scan cycle. Each cycle has four stages that happen in strict order: read all inputs at once, execute all program logic, write all outputs at once, and handle any communication and diagnostics. Then repeat. Nothing inside the logic phase can block the next cycle. Every input is evaluated, every output is updated, and the whole thing starts again in a matter of milliseconds. That predictability is what makes PLCs the right tool for industrial environments where split-second reactions are non-negotiable.
Ladder Logic Basics
PLCs are programmed using ladder logic, a visual language that looks like electrical relay diagrams from the days before software. The three building blocks you need to know here are contacts, coils, and function blocks.
A contact represents a binary input, something that is either on or off. In this project, two push buttons connected to the Arduino serve as the contacts. A coil is an output that you energize, like the LED used in this demo. On top of those fundamentals, you can pull in blocks from the built-in library. The one used here is the SR bistable latch. When the set input (S1) receives a signal, the output (Q1) turns on and stays on. It only goes off when a reset signal arrives at the R pin.
The key thing to understand is that all contacts are evaluated at the same moment, all logic runs, and then all coils are energized or de-energized at once. There is no sequential execution like in an Arduino sketch. You cannot accidentally block one output by keeping another in a loop.
Setting Up OpenPLC Editor
OpenPLC is free software that lets you write ladder logic programs and then compile and upload them to an Arduino, an ESP32, or a range of other supported boards. When you open it for the first time you can create a new project or load an existing one. There is also a built-in simulator so you can test your logic on the computer before touching any hardware.
The simulator is the right place to start. You can click any input to force it true or false and watch the outputs respond in real time. Forcing the set input on turns the output green. Releasing it keeps the coil energized because the SR latch is holding state. Forcing the reset de-energizes the coil. Everything behaves exactly as expected before a single byte goes to the board.
Pin Mapping and the IEC 61131-3 Address Standard
When you target a physical Arduino, OpenPLC requires you to map your logical variables to physical pins using the address format defined by IEC 61131-3, the international standard for PLC programming languages.
Each address has three parts. The first is a location prefix: I for input, Q for output, and M for a memory location. The second is a data size indicator: X means a single bit, which is all you need for a simple on/off signal. The third is the memory address written as two numbers separated by a dot, the byte address and the bit address.
So the button on Arduino pin 2 maps to IX0.0 (input, bit size, byte 0, bit 0), and the button on pin 3 maps to IX0.1. The LED on pin 4 maps to QX0.0 because it is an output. Once those mappings are in place you select your board and serial port, then hit compile and download. OpenPLC pulls in the required libraries and builds the firmware. It takes a few minutes the first time, but when it finishes the Arduino is running real PLC firmware, not a sketch.
Circuit Walkthrough
The circuit is simple. Two push buttons connect to pins 2 and 3 of the Arduino Uno. Each button is pulled down to ground through a 1k resistor so there is no floating voltage on those pins when nothing is pressed. The input side of each button connects to 5V, so pressing one drives its pin HIGH. A current-limiting resistor sits in series with the LED on pin 4, with the far side of the LED going to ground.
Testing It Out
With the firmware uploaded, the demo behaves exactly like the simulator. Press button one and the LED lights up immediately. Because of the SR latch in the ladder logic, it stays on after you release the button. Press button two and the latch resets, turning the LED off again.
The scan cycle runs every 20 milliseconds by default, which is the same principle you would find in an industrial-grade PLC. The Arduino is no longer running a custom sketch. It is running a compiled ladder logic program that follows the PLC scan cycle: reading inputs, executing logic, and writing outputs, all in lockstep.
Conclusion
OpenPLC is an impressive piece of free software that makes the gap between hobby hardware and industrial control concepts much smaller than you might expect. If you want to understand how real PLCs work without buying expensive hardware, or if you want to bring more reliable, non-blocking control logic into your Arduino projects, this is absolutely worth trying. The demo here only scratches the surface as there are timers, counters, more complex function blocks, and a whole ecosystem to explore.
If this sparked your curiosity, subscribe to my YouTube channel so you do not miss what comes next. There is plenty more to build.
Links and Resources
- OpenPLC Editor (free download): https://autonomylogic.com/download
- Altium Develop (Sponsor): https://www.altium.com/yt/taste_the_code
- Arduino Uno: https://s.click.aliexpress.com/e/_c2uCtE2z
- ESP32 Developement Board: https://s.click.aliexpress.com/e/_c3qFwwvb
- Push buttons: https://s.click.aliexpress.com/e/_c3u4XXsd
- Breadboard Starter Kit: https://s.click.aliexpress.com/e/_c3YcR457
- Mini Breadboards: https://s.click.aliexpress.com/e/_c40EONED
- Soldering Station: https://s.click.aliexpress.com/e/_c3wKGx7b
- Bench Power Supply: https://s.click.aliexpress.com/e/_c4N33Vf7
- Soldering Microscope: https://s.click.aliexpress.com/e/_c41T3ic1