Prototyping with Arduino and compatibles is fairly easy, especially when it comes to the hardware. A breadboard simplifies things quite a bit. A few months ago, I realized that I did not have any, so I purchased one, in a kit, on Amazon from a company called Elagoo. The kit, for about sixteen dollars (US) contained a lot of parts and the breadboard. Well, the board is fairly small, so I decided to create a portable workspace and mount the breadboard, an Arduino UNO R3 clone, a 2 x 16 LCD and some cord organizers. It works great, and I can take my project around. Nice. Problem, though, is that I still need to be tethered to the computer in order to write code.
This got me thinking…could I come up with a small but easy to use interface language that could be coded with nothing more than a 12 key keypad?
The answer is yes. So, I have come up with an initial set of opcodes for programming with nothing more than what is on my workspace.
This language would more resemble CHIP-8 than, say, the Arduino language. Commands, statements and functions all use a single byte but can have one or more subsequent values for parameters.
The tables below outline the main features. The keypad I am using (because it was less than a buck) does not have enough keys for full hexadecimal, so I had to improvise. Still working on a scheme to allow alphanumeric entry without connecting a full ASCII keyboard. For now, the language will be limited to reading sensors, accepting decimal (though integer only) numbers. No video, serial out to the 2×16 LCD or a Bluetooth module.
For the tables, the first column is the opcode, second is what the opcode does, third is any parameter( s ) necessary and the last is a description.
Assignment:
01 |
Let |
Var (00-0F) |
Value (00-FF) |
Conditionals:
02 |
IF |
Var (00-0F) |
01 is equal, 02 is <, 03 is >, 04 is <> |
03 |
Jump if true |
Addr (00-FF) |
Program Flow:
04 |
Goto |
Addr (00-FF) |
Transfer control to address |
05 |
Call |
Addr (00-FF) |
Call a subroutine |
06 |
Return |
||
07 |
End |
Ends program |
Input/Output
10 |
Inkey |
Var (00-0F) |
Gets input from the keyboard |
11 |
Out |
Var (00-0F) |
Outputs a value |
12 |
Temp |
Var (00-0F) |
Gets a reading from the temperature sensor |
13 |
Pinset |
00-FF |
Send a value to pin |
14 |
Pinread |
00-FF |
Get a value from pin |
15 |
Xfer Pin |
Var (00-0F) |
Transfers value from read pin to variable |
I would envision the interpreter being fairly small, so it may be possible to integrate several libraries for the more popular sensors, like DHT-11 temp sensor and others.
So, what do you think? Is this something of interest? Please post your thoughts in the comments below.