Programming an Arduino without typing a single word

Hello everybody,

For people who want to use arduino's but cannot or do not want to code. I made a GUI using logic gates. At first I was looking for existing stuff. I am aware that adafruit did something similar. But it was not that was searching for. I want to place SR memory gates, AND gates etc.. just like back on high school.

https://learn.sparkfun.com/tutorials/alternative-arduino-interfaces/all

So do that end I am building me this GUI:

In this GUI you can let an arduino do things without typing (well do you have to insert pin numbers with the keyboard). Besides true digital items like inputs and outputs, I also made analog items and some 'hybrids' as well. You can use PWM, analog input, servo motors, serial communication, delays, constants, comperators. There is a pulse generator, many logic gates like AND, OR, JK flipflop, SR memory and that sums it up ..... for now that is :wink:

If you want to use a potentiometer to move a servo motor, you will need to use a map block. This map block uses the map() function so you can scale 0-1023 to 0-180 (or 20-50 or all I care :stuck_out_tongue: )

The map function is what I dupe 'a hybrid'. If you set the ingoing range of a map block to 0-1 or 1-0 you can use digital blocks to create two analog values to set a certain pwm dutycycle or servo position.

The delay block is in fact also a hybrid. The delay block does not simply delay the input. It does that with '1' at the time. It keeps incrementing or decrementing the output (Q) by 1 after each interval. This allows you to create fading leds or slow down the movement of a servo motor.

The last items of interest for now are the serial communication blocks, MESS IN and MESS OUT. A mess out simply sends a message of choise over the Tx pin. Any received input over the Rx pin is relayed to all mess in block. If the received message is a match, the output if that block goes high.
This output remains high until a different message is received.

The GUI is made in processing, so not that particular fancy :stuck_out_tongue: . I did try to make it intuitive. You can place, and drag components and links by clicking on them. The texts on top tell you what the mouse buttons do at any given time.

If you press that green PROGRAM button an arduino program is assembled. It exists out of one header file and a relative short .ino files wich you can you compile and flash to an arduino board.

The generated source code which matches the example is this:

#include "functionBlocks.h"

static        Input d1 = Input(1) ;
static       Output d2 = Output(2) ;
static        Input d3 = Input(3) ;
static     SerialIn d4 = SerialIn(0) ;
static       Memory d5 = Memory() ;
static     SerialIn d6 = SerialIn(0) ;
static    SerialOut d7 = SerialOut(0) ;
static       Output d8 = Output(13) ;
static          Map a1 = Map(0,1,30,80) ;
static        Delay a2 = Delay(2000) ;
static   ServoMotor a3 = ServoMotor(4) ;
static        Delay a4 = Delay(20) ;

DigitalBlock *digitalBlock[] = {
    &d1 ,
    &d2 ,
    &d3 ,
    &d4 ,
    &d5 ,
    &d6 ,
    &d7 ,
    &d8 ,
} ;
const int nDigitalBlocks = 8 ;

AnalogBlock *analogBlock[] = {
    &a1 ,
    &a2 ,
    &a3 ,
    &a4 ,
} ;
const int nAnalogBlocks = 4 ;

void updateLinks()
{
     analogBlock[1] -> IN2 = digitalBlock[0] -> Q ;
    digitalBlock[1] -> IN2 =  analogBlock[1] -> Q ;
     analogBlock[0] -> IN2 = digitalBlock[2] -> Q ;
     analogBlock[3] -> IN2 =  analogBlock[0] -> Q ;
     analogBlock[2] -> IN2 =  analogBlock[3] -> Q ;
    digitalBlock[4] -> IN3 = digitalBlock[5] -> Q ;
    digitalBlock[4] -> IN1 = digitalBlock[3] -> Q ;
    digitalBlock[6] -> IN2 = digitalBlock[4] -> Q ;
    digitalBlock[7] -> IN2 = digitalBlock[4] -> Q ;
}

void sendMessage( String S )
{
    Serial.println( S ) ;
}
String getMessage()
{
    static String lastMessage ;

    if( Serial.available() ) // <== incomming message ;
    {
        lastMessage = "" ;          
        delay(3) ;          // use dirty delay to receive entire message

        while( Serial.available() )
        {
            char c = Serial.read() ;
            lastMessage += c ;
        }
    }

    return lastMessage ;
}   

void setup()
{
    // NOTE init servo motors
    Serial.begin( 9600 ) ;
}

void loop()
{
/***************** UPDATE FUNCTION BLOCKS *****************/
    for( int i = 0 ; i < nDigitalBlocks ; i ++ ) { digitalBlock[i] -> run() ; updateLinks() ; }
    for( int i = 0 ; i <  nAnalogBlocks ; i ++ ) {  analogBlock[i] -> run() ; updateLinks() ; }
}

There are currently 2 small bugs (which are in fact just not yet implemented features).
The servo motors are not yet initialized or tested. And the serial blocks still need texts. The GUI cannot do this.. yet.

Therefor the generated source cannot compile before you alter the construction of the serial objects.

These blocks...
image

...lead to this code

static     SerialIn d1 = SerialIn(0) ;
static       Memory d2 = Memory() ;
static     SerialIn d3 = SerialIn(0) ;
static    SerialOut d4 = SerialOut(0) ;
static       Output d5 = Output(13) ;

Replacing the '0's by meaning full texts..

static     SerialIn d1 = SerialIn("ON") ;
static       Memory d2 = Memory() ;
static     SerialIn d3 = SerialIn("OFF") ;
static    SerialOut d4 = SerialOut("TURNED ON") ;
static       Output d5 = Output(13) ;

... succesfully turns on and off led pin 13 with the texts ON and OFF and I get the message 'TURNED ON' sent back to me every time when the led is turned on.
image

Besides the missing feautures I mentioned, there are no known bugs AFAIK. I can save and load the program (<== .csv file). But I am still in the testing phase.

But as the base proved to be operational, I thought to post my progress on the Arduino forum as well.

If somebody wants to try it out: The source is on github:

If you have processing installed, you should be able to run it. If it does not load well, you need to alter the program.csv file to have lines with a 0 like (I put this on me bugs list)
image

Now I am going to think which logic gates I should add. I already figured that I am going to need arithmatic blocks :nerd_face:.

Kind regards,

Bas

1 Like

How is this related to covid19?

well that is a bummer, I seem to have clicked the wrong board -_-" I miss the old forum

Obviously, an effort of love and an interesting approach. That the GUI is written in Processing is clever: Old folks like myself are often amused at drag & drop as we started programming back in the IBM card deck days. These days drag & drop refer more to my getting the groceries from the garage to the kitchen.

Good wishes for evolution.

Or the 8 level punched paper tape!

I did use PT while in the military and later at Burroughs for the "L" series: mostly to load firmware and Cobol applications; although, I did write a few maintenance-tests in assembler which were on PT. Cards were so much faster, but PT did not have to be resorted when dropped ... although long programs did take some skill and patience to recoil the roll (like getting knots out of the old steel Slinky.)

The card reader on the Burroughs medium systems would sort you program cards for you! Believe it or not, their high speed check reader sorter, DP1000, would do the same thing with your sorted checks. But they said it could not happen, until they watched it happen!

Actually, this old knowledge can be very useful.
I once had to look at an application that was starting to take a huge amount time to run.
It was applying changes to signal records to be used in a telephone exchange development system and was written in some IBM scripting language. It worked by sequentially scanning a set of records. It started with record 1 and then sequentially scanned that complete set of records looking for references to record 1. It then moved on to record 2 and did the same etc. This, of course, works perfectly well with a small set of records but does not scale up well.
A set of N records required N*N comparisons. Using an algorithm of the type used for sorting and merging card decks or other unindexed records, I was able to reduce the run time of this system from hours to seconds to the amazement of my colleagues.

Used a similar approach in the ESP8266 to get the entire OUI ASCII database into SPIFFS and create a lookup algorithm.

Many new folk would be off looking for some search library. The Arduino library "problem" has become rather worrisome for me as the large Arduino community view libraries solely as "black boxes" and have little idea of the inner workings; using a library is good but not understanding the workings is not good, IMO.
I once supervised a group of 10 very well educated JAVA programmers. The company at the time insisted on code-reuse, often taking more time to integrate than just writing to the code requirements. Upstream churn in requirements often drove changes in lower libraries and played havoc with module testing. Lots of wasted time and money. Point is, even smart folk often fail when it comes to "black box" reuse.

The idea is cool, I love things like this. But there is usually a catch in the limitations of what you can code using it.

Everything which is not C or C++ is always 'worse' or limitated. I am an electrical engineer bit I am mostly writing software to earn my bread. If I am lucky I get to do write C, if I am less lucky assembly for the 8051. A chip which is 10 years older than I am.

Recently our company started to use Beckhoff PLCs. I dislike PLC's in general. But these beckhoff things are okay. Structured Text is also not my jam, but atleast it is workable.... unlike that abomination called logic ladder diagram :joy:

I can remember from highschool that I designed a complete digital alarmclock using nothing else but logic gates. I scotchtaped many A4 sheets togather and I drew the entire thing with a pen. Ofcourse I lost me some points on the 'layout'... :sweat_smile:

I think I have the servo motors working now! I have some old pcb laying around at home. With it I can test the functionality and shoot some video's.

The serial input/output blocks are halfway finished.

Kind regards,

Bas

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