aboutsummaryrefslogtreecommitdiffstats
path: root/examples/blinky.cpp
blob: 209a6e65c9584eeb85d003eb11687ff92b999c35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Blinks the built-in LED

#include "wirish.h"

// Use the pin attached to the built-in LED
#define PIN BOARD_LED_PIN

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

int toggle = 1;

void loop() {
    // You could just use toggleLED() instead, but this illustrates
    // the use of digitalWrite():
    digitalWrite(PIN, toggle);
    toggle ^= 1;
    delay(100);
}

// Force init to be called *first*, i.e. before static object allocation.
// Otherwise, statically allocated objects that need libmaple may fail.
__attribute__((constructor)) void premain() {
    init();
}

int main(void) {
    setup();

    while (1) {
        loop();
    }
    return 0;
}