Running a micro controller as a pass through GPIO pins?

I have been seeing some places that they are running micro controllers as pass through gpio pins without having to reprogram the microcontroller itself. Just running some script on the pc to display content on a oled screen or blink and led. I was curious on how is this possible from a programming point of view without having to reprogram the microcontroller itself?

Joseph

Maybe using the Configurable Custom Logic feature that e.g. some Attinies have. That's like a configurable logic switchboard where you can connect peripherals, including pins, directly to each other and apply Logic Functions on the go.


(page from the datasheet)

Can you please provide some links to where you have seen this ?

Interesting. How would the microcontroller know what to do if it hasn't been told (i.e. programmed) which input to pass to which output. Even if it were CCL (which I know less than nothing about!) it would still involve transferring some "settings" to the microcontroller - which to me is still programming - just a different part of the device. Much like putting data into the EEPROM section of a 328P micro - to me that's still programming.

Why ?
Wouldn’t it just be easier to connect the input and output wires together?
Skip the micro..

The key word here may be reprogram

I can certainly envisage a sketch that received commands from the PC via Serial and executed a limited range of preprogrammed inputs/outputs/actions

I have never used it, but is this how Firmata works ?

I think you are right. The key being reprogram as you say.

maybe you confuse a microcontroller with a logic logic circuit -chip
or with an FPGA. (An FPGA is a highly complex chip that can be pre-programmed for doing operations like you described it.

here's a program that use single character commands entered thru the serial monitor to configure, read and write I/O pins to learn how they work.

i use a version of this on all my programs to test and diagnose programs

// pcRead - debugging using serial monitor

const char version [] = "PcRead 240209a";

int debug = 0;

// -----------------------------------------------------------------------------
// process single character commands from the PC
#define MAX_CHAR  10
char s [MAX_CHAR] = {};

int  analogPin = 0;

void
pcRead (void)
{

    static int  val = 0;

    if (Serial.available()) {
        int c = Serial.read ();

        switch (c)  {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            val = c - '0' + (10 * val);
            break;

        case 'A':
            analogPin = val;
            Serial.print   ("analogPin = ");
            Serial.println (val);
            val = 0;
            break;

        case 'D':
            debug ^= 1;
            break;

        case 'I':
            pinMode (val, INPUT);
            Serial.print   ("pinMode ");
            Serial.print   (val);
            Serial.println (" INPUT");
            val = 0;
            break;

        case 'O':
            pinMode (val, OUTPUT);
            Serial.print   ("pinMode ");
            Serial.print   (val);
            Serial.println (" OUTPUT");
            val = 0;
            break;

        case 'P':
            pinMode (val, INPUT_PULLUP);
            Serial.print   ("pinMode ");
            Serial.print   (val);
            Serial.println (" INPUT_PULLUP");
            val = 0;
            break;


        case 'a':
            Serial.print   ("analogRead: ");
            Serial.println (analogRead (val));
            val = 0;
            break;

        case 'c':
            digitalWrite (val, LOW);
            Serial.print   ("digitalWrite: LOW  ");
            Serial.println (val);
            val = 0;
            break;

        case 'p':
#if !defined(ARDUINO_ARCH_ESP32)
            analogWrite (analogPin, val);
            Serial.print   ("analogWrite: pin ");
            Serial.print   (analogPin);
            Serial.print   (", ");
            Serial.println (val);
            val = 0;
#endif
            break;

        case 'r':
            Serial.print   ("digitalRead: pin ");
            Serial.print   (val);
            Serial.print   (", ");
            Serial.println (digitalRead (val));
            val = 0;
            break;

        case 's':
            digitalWrite (val, HIGH);
            Serial.print   ("digitalWrite: HIGH ");
            Serial.println (val);
            val = 0;
            break;

        case 't':
            Serial.print   ("pinToggle ");
            Serial.println (val);
            digitalWrite (val, ! digitalRead (val));
            val = 0;
            break;

        case 'v':
            Serial.print ("\nversion: ");
            Serial.println (version);
            break;

        case '\n':          // ignore
            break;

        case '?':
            Serial.println ("\npcRead:\n");
            Serial.println ("    [0-9] append to #");
            Serial.println ("  # A - set analog pin #");
            Serial.println ("  # D - set debug to #");
            Serial.println ("  # I - set pin # to INPUT");
            Serial.println ("  # O - set pin # to OUTPUT");
            Serial.println ("  # P - set pin # to INPUT_PULLUP");
            Serial.println ("  # a - analogRead (pin #)");
            Serial.println ("  # c - digitalWrite (pin #, LOW)");
            Serial.println ("  # p - analogWrite (analogPin, #)");
            Serial.println ("  # r - digitalRead (pin #)");
            Serial.println ("  # s  - digitalWrite (pin #, HIGH)");
            Serial.println ("    t  - toggle pin output");
            Serial.println ("    v  - print version");
            Serial.println ("    ?  - list of commands");
            break;

        default:
            Serial.print ("unknown char ");
            Serial.println (c,HEX);
            break;
        }
    }
}

// -----------------------------------------------------------------------------
void
loop (void)
{
    pcRead ();
}

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin(9600);

    Serial.println (version);
#if defined(ARDUINO_ARCH_ESP32)
    Serial.println ("esp32");
#endif
}

As @UKHeliBob pointed Firmata is one, here is another:

Hello all, @gcjr @StefanL38 @markd833 @jim-p @UKHeliBob @hmeijdam I’ll send some links when I get back home won’t be for a day. I’m on the road. I was just curious on from a programming point of view how is that possible and how would it work. I’m not home right now and I’ll upload some links when I get back.

it seems pretty common for someone inexperienced that exactly is needed to do things on an Arduino. So you write a program that turns on an LED, and a then a program to turn it on and off. Each change takes times to modifiy , compile, download and execute

similarly, if you write a bunch of functions, it's time consuming to exercise and test them -- modifiy , compile, download and execute

with todays processors and serial communications, it makes sense to support commands to exercise available functions, along with arguments to those commands.

so most modern day programs support diagnostic commands. The program needs to have functions to do so, it's not something generic to the processors.

And this is possible using the IDE's serial monitor to both output print statements from the code as well as sending commands to the Arduino

What you mentioned really sounds like "Firmata" ...

Feel free to read this

https://roboticsbackend.com/arduino-standard-firmata-tutorial/

Here are some Wokwi simulations of using serial commands to control/read GPIO pins:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.