I want to use the Ticker class - and the compiler shows a very simple error message - why?
The sketch is a copy from an example. It looks like the compiler ignored the #include!?
The file "mbed.h" holds a couple of includes, also a line with #include <drivers/Ticker.h>
The error message:
TickerTest:4:1: error: 'Ticker' does not name a type; did you mean 'Socket'?
Ticker timer;
followed by a couple of error message, because timer is undefined.
The small Sketch:
#include <mbed.h>
Ticker timer;
#define led1 2
#define led2 3
volatile bool flip = false;
volatile bool update = false;
void setup() {
timer.attach(&attime, 5);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}
void attime() {
flip = !flip;
update = true;
}
void loop() {
if (update)
{
update = false;
if(flip == 0)
{
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
}
else
{
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
}
}
}