Flash in a second, this is the first example we will use when we do microcontroller, using GASP to develop, will become simpler.

If you do not have GASP installed please refer to the GASP Internet of Things Programming Language Quick Start Installation section.

Let’s create a new project

gasp new blink
cd blink
Copy the code

We modify the file main.gasp to remove the code from it.

gpio blink {
    pin: "LED_BUILTIN",
    state: LOW
}

every toggle_blink 1000
Copy the code

In the code above, add a GPIO blink using the built-in LED with pin LED_BUILTIN and set the default point to LOW. Then set toGGLE_BLINK for each 1000 ms.

Execute gasp compile, and the compiled code is as follows

unsigned long get_current_time_ms(a);


unsigned long toggle_blink_timer_ms = get_current_time_ms();

int gpio_blink_pin = LED_BUILTIN;
int gpio_blink_state = LOW;


void setup(a) {
    pinMode(gpio_blink_pin, OUTPUT);

}

void loop(a) {
    if (toggle_blink_timer_ms + 1000< get_current_time_ms()) { toggle_blink(); toggle_blink_timer_ms = get_current_time_ms(); }}unsigned long get_current_time_ms(a) {
    return millis();
}

void open_blink(a) {
    gpio_blink_state = HIGH;
    digitalWrite(gpio_blink_pin, gpio_blink_state);
}
void close_blink(a) {
    gpio_blink_state = LOW;
    digitalWrite(gpio_blink_pin, gpio_blink_state);
}
void toggle_blink(a) {
    if (gpio_blink_state == HIGH) {
        close_blink();
    } else{ open_blink(); }}Copy the code

Finally, we compile the Arduino and upload it to the Arduino board, and our example is done.