pseudo

Arduino::Pseudo

Write Arduino pseudocode in Perl


Introduction

Arduino::Pseudo is a Perl module that mimics the working of an Arduino board. Is intended to do rapid prototyping of Arduino code, before building a physical circuit.

It is not an Arduino emulator, it doesn't even try. The code is plain Perl, it just "resembles" Arduino code. It is not an electrical circuit simulator. The abstraction is as simplified as possible, no voltage, no resistors, nothing. Just an Arduino::Pseudo object to which you can connect equally abstract components (so far: push buttons, leds, a generic pot(entiometer) and an LCD screen).

Perhaps is easier if we look at a code example. This is the standard Blink tutorial from the Arduino website, only stripped of comments:

Arduino code Arduino::Pseudo code
int led = 13;

void setup() {
    pinMode(led, OUTPUT);
}

void loop() {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
}
use Arduino::Pseudo;

my $led = 13;

my $arduino = Arduino::Pseudo->new();

$arduino->connect( $led => 'led',
    pos => [ 10, 10 ],
    color => 'red',
);

$arduino->MainLoop;

sub loop {
    my($arduino) = @_;
    $arduino->digitalWrite($led, $arduino->HIGH);
    $arduino->delay(1000);
    $arduino->digitalWrite($led, $arduino->LOW);
    $arduino->delay(1000);
}

That's it. When you run the program, you have a Wx window with a blinking led:

Download

Source code is available on GitHub.

Soon to be released on a CPAN mirror near you :-)