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
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 )
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 . 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...
...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.
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)
Now I am going to think which logic gates I should add. I already figured that I am going to need arithmatic blocks .
Kind regards,
Bas