A simple way to get a high-level program running on a PC/Laptop, or even a mobile device communicating to a low level interface device such as an Arduino.
This is a combination of three things – firstly a low-level protocol used to communicate between the two devices (typically over a serial interface), secondly a program running in the device to interpret these commands, and finally a high level set of functions running on a host device. The protocol and high-level routines are designed to emulate the Arduino “wiring” instructions.
The actual protocol is designed to be both machine and human usable, so the intention is that you can connect up a serial terminal (e.g. minicom or hyperterminal) to the target device to perform some simple tests before writing a program to send the commands. The commands being simple one-byte commands than then take 1 or 2 more bytes of data.
I developed DRC to enable programs written in BASIC to communicate with an Arduino, however any high level language with serial port support is capable of talking to it from any host – Linux (e.g. Raspberry Pi), Win and Mac with appropriate interfacing and serial software.
Current commands implemented are:
- PinMode: This sets the mode of an IO pin on the target device to either Input, Output or PWM output.
- DigitalWrite: Sets a pin to a high or low logic level.
- PwmWrite: Sets a pin to the given PWM value (0 through 255)
- DigitalRead: Returns the state of a input pin – the return value is TRUE or FALSE representing a logic high or low on the pin.
- AnalogRead: Returns the analog input value on the pin. This will typically be from 0 to 1023, but may be different depending on the target device.
HEX files as well as full source code is available for both the Arduino and a Linux host. See the downloads link for more details.