Skip to content
Arduino binding for Céu
Makefile Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs SPI documentation Aug 29, 2017
env (>) ISRS from queue to fixed vector and no payload Sep 18, 2018
examples (>) update examples to new version Oct 15, 2018
include/arduino adicionando constantes para o PCINT2 Oct 4, 2018
libraries Update libraries Makefile Mar 27, 2019
.gitignore (+) automate libraries May 28, 2018
HISTORY (^) v0.8 Jun 25, 2014
Makefile Update Makefile Mar 1, 2019
Makefile.conf (>) require path to Ceu dir because of string.ceu and c.ceu Sep 19, 2018
README.md Update README.md Mar 27, 2019
make.sh Merge May 19, 2017

README.md

Céu-Arduino supports the development of Arduino applications in the programming language Céu:

Arduino Arduino is an open-source project that created microcontroller-based kits for building digital devices and interactive objects that can sense and control physical devices.

Céu is a reactive language that aims to offer a higher-level and safer alternative to C:

Céu-Arduino empowers the development of Arduino applications with the following extensions:

  • Awaiting events in direct/sequential style.
  • Parallel lines of execution with
    • safe abortion;
    • deterministic behavior (in contrast with threads).
  • Asynchronous loops for heavy computations.
  • Interrupt-driven operation mode (optional and experimental).
  • Seamless integration with standard Arduino (e.g., analogRead, random, etc).

Install

Install Arduino

Requires arduino-1.5 or higher:

https://www.arduino.cc/

Install Céu:

https://github.com/ceu-lang/ceu/

Clone Céu-Arduino:

$ git clone https://github.com/ceu-lang/ceu-arduino
$ cd ceu-arduino/

Configure:

Edit the Makefile.conf to set your configurations and preferences:

$ gedit Makefile.conf

Clone the Libraries:

$ cd libraries/
$ make clone

Each library provides documentation in separate:

https://github.com/ceu-arduino/

Use

Run make with the file you want to compile & upload:

$ make CEU_SRC=examples/blink-01.ceu

This example blinks the on-board LED every second.

Certify that your Arduino is connected to the USB.

Examples

The examples/ directory contains a number of examples.

Blinking a LED

The example blink-01.ceu assumes that a LED is connected to pin 13.

The program is an infinite loop that intercalates between turning the LED on and off in intervals of 1 second:

#include "out.ceu"              // uses GPIO (OUT_13)
#include "wclock.ceu"           // uses timers (await 1s)

output high/low OUT_13;         // declares OUT_13 an output pin

loop do                         // runs an infinite loop that
    emit OUT_13(high);          //   - turns the LED on
    await 1s;                   //   - awaits 1 second
    emit OUT_13(low);           //   - turns the LED off
    await 1s;                   //   - awaits another 1 second
end                             //   - repeats

Switching a LED

The example button-01.ceu requires a simple circuit with a switch button connected to pin 2.

The program waits for changes on pin 2 (the switch), copying its value to pin 13 (the LED):

#include "out.ceu"
#include "int0.ceu"                 // declares input `INT0` (UNO=D2, MEGA=D21)

output high/low OUT_13;

var high/low v = call INT0_Get();   // gets current value of the pin
emit OUT_13(v);                     // sets the LED to this value

loop do
    await INT0;                     // waits for a pin change event
    v = call INT0_Get();            // gets the new state of the pin
    emit OUT_13(v);                 // sets the LED to this value
end

Blinking in Parallel

The example blink-02.ceu requires two additional LEDs connected to pins 11 and 12.

The program blinks the LEDs with different frequencies, in parallel:

#include "out.ceu"
#include "wclock.ceu"

output high/low OUT_11;
output high/low OUT_12;
output high/low OUT_13;

par do
    loop do
        emit OUT_11(high);
        await 1s;
        emit OUT_11(low);
        await 1s;
    end
with
    loop do
        emit OUT_12(high);
        await 500ms;
        emit OUT_12(low);
        await 500ms;
    end
with
    loop do
        emit OUT_13(high);
        await 250ms;
        emit OUT_13(low);
        await 250ms;
    end
end

Fading a LED

The example pwm-01.ceu assumes that an LED is connected to pin 06.

The program fades the LED from 0 to 255 and from 255 to 0 in two consecutive loops:

#include "pwm.ceu"
#include "wclock.ceu"

loop do
    var int i;
    loop i in [0->255] do
        spawn Pwm(6, i);
        await 5ms;
    end
    loop i in [0<-255] do
        spawn Pwm(6, i);
        await 5ms;
    end
end

Serial Echo

The example usart-01.ceu reads and write strings from and to the serial in a continuous loop:

#include "usart.ceu"

spawn USART_Init(9600);

loop do
    var[20] byte str = [];
    await USART_Rx(&str, _);
    await USART_Tx(&str);
end
You can’t perform that action at this time.