MCU pin setup

Generic visual pin layout setup tool for development boards,
including a setup-based automatic code generator.

Similar projects worth following

If you are familiar with development boards widely available, like an Arduino, you most likely looked at the pin-out image for it, because they have different layouts.

MCU pin setup is a visual WYSIWYG online tool, which allows you to setup the pin layout by clicking, see information, instant feedback of warnings or errors.

Then at the end you are provided with 2 things helping your project:
- Actual pin layout on screen: Allowing easy hardware setup
- Generated code: Providing an easy-to-use interface for the peripherals

What you get:
- Easy and quick boost for new projects, quick changes for existing ones, and with cross-board compatibility, quick change to custom hardware.
- Helps with education of embedded design and development.

The challenge:

This project tries to tackle is the disadvantage of the advantage of having many possibilities.

Also, I intend to have it as an embedded hardware development educational tool. Having the pin layout setting interactive makes it easier for advanced hobbyists, and is good for teaching the basics for starters.

If someone gets a development board, the first thing he/she looks at is the pin layout. For most boards, for example Arduino, the problem can be solved by providing a single image.

But for example looking into the official documentation the ESP32 provided by Espressif, it becomes obvious that a single image showing all is impossible to provide.

A brief look at complexity the challenge has:

There are 3 SPI interfaces with up to 3 CS pins in ESP32, each can be used as:

  • standard: "MISO+MOSI+SCK+SS/CS"
  • quad-mode: with 2 additional pins (mainly used for external flash and ROM)
  • 3-wire: where MISO and MOSI share the same pin.

There is also a possibility to have SS and SCK on the same pin.

All SPI inputs/outputs can be set to any pin you like.
However if you use other pins than the "primary" ones assigned to them, you can go up to only 40 MHz. So a setting also depends here on the pin layout.

If somebody would like to just start a project, and he/she doesn't use the virtual Arduino core provided, then:

  1. Needs to read through the documentation carefully.
  2. Grab a pen and a paper, figure out the pin layout.
  3. Write the code implementing it.
  4. Bump into errors and continue from step 2 or even step 1.

Of course someone can just use the virtual Arduino core which takes care of the pin setup, but it may have limitations to it. The goal is to avoid limitations, let the user decide the setup, but make is as easy as possible.

The challenge described here is explained mainly through the ESP32, but can be applied to other boards using MCUs with adjustable pin layout. For example the SPI1 on Maple Mini (STM32 core) can be set to 2 different positions.


The vision is a WYSIWYG tool which primarily serves as a visual guide for the pin layout setup.

Anyone looking at it could immediately see the board itself with all functional information for its pins.
Exactly the same as a single image provided for most basic boards.

The difference between this and single pin layout image is that this is fully interactive.


  • Quick menu for board changing. With boards using the same core, active settings could be quickly transferred and showed how they look on different boards.
  • Clicking on pin names show detailed information about that particular pin, including board-specific information (e.g.: on-board pull-up resistor, LED).
  • Peripherals are listed and can be enabled/disabled, if applicable for the active board. Some may not be available for some boards (disabled only), others may be connected to an on-board device (enabled only).
  • Different modes for interfaces can be selected, filtering selectable pins.
  • Peripherals also have a detailed information which is showed on-demand. Board-specific information also included.
  • Not only pins are selectable, but peripheral-specific options, like clock source, speed, etc. Dependencies are needed for some, like if using external clock source, then the specific source must be enabled.
  • Saving and loading the whole pin layout and setup.
  • Automatic code generation based on the setup. Code flavors may be selected.
  • Easy tool extension/correction: All MCU and board specific information stored in human-readable JSON format.

This tool of course could be really powerful with the automatic code generation.
A layer can be created between the core libraries and application code.
It could have several advantages:

  • Speeding up a project start-up. Click together the setup, then generate a code, and everything will be automatically set.
  • Focusing on the application code, and having the visual hardware tool is good for education of beginners.
  • Creating cross-board projects less painful: If a setup is not good for a specific board (e.g.:...
Read more »

  • 1 × Recent web browser with JavaScript capabilities
  • 1 × Board(s) which you intend to do a project with (hopefully listed in this tool)
  • 1 × IDE(s) for the MCU(s)

  • Code template not regex anymore!

    Norbert Fekete5 days ago 0 comments

    First things first, I've done the brief introductory video:

    And for this, I've made several modifications to the page.

    A big modification was for the code generator, which simply used a silly-looking regular expression. That temporary solution is now replaced with a template library. More advanced code generation can be done now, the real fun begins!

    Next steps

    • Start writing documentation for the JSON file formats. These store the MCU core, peripheral and module information in a human-readable style.
      The documentation will be available on Github Wiki of the page.
    • Add sanity checks so the tool can give warnings and errors instantly. Maybe also information like: "You may need external pull-up resistors for the I2C pins"
    • Start making an editor page where everything can be edited visually, instead of writing the JSON manually. Will speed things up. As it is a big sub-project, it won't be available in the near future.
    • Concentrate on the Arduino Pro Mini's all features, try to make at least the Arduino code flavor fully working, so it could be used as a base for others.
    • Think about some small project (ore more than one) which could be done with this tool. Example use-cases can show its potential.

  • First use of generated code

    Norbert Fekete04/07/2017 at 13:58 0 comments

    Here is the first cross-MCU code which was used as a test.

    A simple blink, which runs on a FreeRTOS task.

    #include "mps.h"
    void TaskBlink(void *pvParams)
      for (;;)
        digitalWrite(LED_BUILTIN, HIGH);
        Serial.println("LED on");
        digitalWrite(LED_BUILTIN, LOW);
        Serial.println("LED off");
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
    void loop() {}
    • Includes the MCU pin setup tool's generated main header. (Which includes all necessary headers as well)
    • Defines the task which blinks the led in an infinite loop, and prints out text on Serial.
    • Calls the MCU pin setup initialization function which does the initial setup. If our case for example "Serial.begin()" is called inside, if the UART was enabled in the tool.
    • Sets the builtin LED pin to output.
    • Starts the task, and does nothing in the idle loop.

    For Arduino, the Arduino-FreeRTOS library is needed, can be installed in Arduino IDE's Library Manager.

    For ESP32, the ESP-IDF needs to be set up, leave the "main.c" totally empty, and put this code into e.g.: "app.cpp". I know it is a bad workaround, will think about it more.

    In "make menuconfig", the idle loop for FreeRTOS must be enabled! It uses that for the main loop. It is ugly too, I know.

    But with this, the code is nice and readable, and is the same for Arduino Pro Mini and ESP32.

    Next step, do a video tutorial about this.

  • Code generation progress

    Norbert Fekete04/06/2017 at 13:50 0 comments

    New board added

    To have another MCU, I've added Arduino Pro Mini board with ATmega328. It is available now in the "Module" drop-down menu.

    Of course it's not complete and has flaws. Bugfixes will be done, this is still just at a proof-of-concept level.

    User can now select between "pin layout" and "generated code" views

    The layout view is the default which was available before.

    The code view allows the user to see what will the generated code exactly be. Of course it is not editable, but is instantly updated if settings are modified.

    For now nearly nothing is implemented, and it has only one code flavour: Arduino-FreeRTOS. This decision was made to test if I can make an application code which runs a RTOS "blink" task, and this very same code could run on an ATmega328 and ESP32. It was a success, however needed a bit of thinking, and handling colliding things, like minimal stack size for different MCUs. (Made the ESP32 go into reset-loop because of too small stack)

    The generated code has an Arduino flavour, so those who are used to the Arduino coding style can use familiar methods on other MCUs as well, with RTOS additions. The intention is not to replace Arduino, because other MCUs have virtual Arduino core. Of course "vanilla Arduino" flavour will be added as well.

    For now I would like this to act also as an educational tool to easily understand and start coding an RTOS application.

    A "Download" button was also added, in order to quickly download the whole generated code.

    Next steps

    • I intend to make an introductory video with the stuff already done. It's simpler to show what my intention is.
    • I've found a nice UML to code generator tool, will try it out, and if works well, it could be used together with my tool, simplifying the whole application creation even more. I believe that with visual tools, efficiency of education can be boosted.
    • I'll have access to a Maple Mini, I will add also that one, so I'll have also an ARM based MCU in the tool.
    • Define a more complex project, with I2C, SPI, ADC, inputs/outputs, several different tasks, event queues, and of course do it using the MCU pin setup, and optionally an UML to application code generator tool. It does not need to be fully cross-MCU, 8-bit and 32-bit cores are really different.

  • Automatic code generation

    Norbert Fekete03/28/2017 at 14:45 0 comments

    I've put the initial code generation commit into my website:

    It creates a basic header which can be downloaded as a zip file. Has no functionality in it yet.

    But if you turn on/off the "ADC", it will include/exclude code, so preprocessing via JavaScript can be done.

    I've been thinking lately a lot about the automatic code generator, which could be a powerful function of this tool.

    If I think in FreeRTOS, then there's several MCUs I can use, it is available for:

    • Arduino (even 16-bit with ones)
    • ARM-based MCUs, like STM32
    • ESP8266 and ESP32
    • and so on, and so on...

    There is a trend to become Arduino-compatible because of its simplicity and number of libraries it offers. Virtual cores are being developed for it so anyone familiar with Arduino can do a simple jump-start.

    Something similar could be achieved for FreeRTOS.

    Why FreeRTOS?

    It provides a different approach than the standard "main loop+interrupts". And can also be made easy using UML modeling tools supporting FreeRTOS. Imagine your kid just drawing the threads and state-machines, then simply generate the application code from it. Could be a great way of teaching multi-threaded real-time OS approaches to problems.

    Adding the MCU pin setup tool the virtual layer code can also be generated automatically, based on a very visual setup.

    If this tool could create a generic C header file as a basic interface for all kinds of MCUs and boards, and C sources would be based on the specific MCU with the specific setup done.

    A Makefile then could be used to select from targets, like "make arduino2560", "make esp32" or something like that.

    Now, this tool can be used to create the pin layout, and turn on/off and setup peripherals. Also, different MCUs can have specific peripherals available.

    This difference can be however handled by giving back an error code (or throwing an exception in case it would be in C++) if the code tries to access unavailable peripherals. For basic features like UART, I2C, SPI... it should not be a problem to have cross-compatibility. Other unique features should be handled by the application if it wants to be cross-MCU-compatible.

    As test I will try to make something run on an Arduino, an ESP32, and also an STM32. Wish me luck..

View all 4 project logs

  • 1

    Open the MCU pin setup tool page, and select the module you would like to create your project for.

  • 2

    With the help of the peripheral list on the side, setup the pin layout for the project.

  • 3

    By changing to code view you can check also the generated code. Download the whole code with the button on the top.

View all 7 instructions

Enjoy this project?



Mike Szczys wrote 4 days ago point

Very cool. I have spent a fair share of time playing "Where's Waldo" looking for particular pins when all are listed. It would be nice to have a tool that only shows what I'm looking for.

I have a feature request: an option to show the labels from the bottom side of the board.

  Are you sure? yes | no

Norbert Fekete wrote 19 hours ago point

Thank you! Yup, it can be annoying, and several very similar boards with same core route out pins to different places. And lots of debugging lead to: "Oops, wrong pin.."
Also there are the hidden features: I read through the Arduino documentation now to have the basic features listed and got surprised by the fact that USART can also be used as SPI. No pinout image mentions this. I didn't find it even in the Arduino code. Only the pin labels hint for it: "TXO" and "RXI". At first look I though those are digital pin number zero and one, but nope, "TXO" is "D1" and "RXI" is "D0".
Now I get it: "TXd+misO" and "RXd+mosI".
I think there are many people who accidentally though of them as zero and one, leading to cursing.

About the feature request: Thanks! I forgot the boards have actually two sides. :)
I'll add it to the page, maybe as a "flip board" button.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates