Initial commit
This is just the 2018 code configured for PlatformIO
This commit is contained in:
60
lib/DueTimer/examples/AvaliableTimer/AvaliableTimer.pde
Normal file
60
lib/DueTimer/examples/AvaliableTimer/AvaliableTimer.pde
Normal file
@ -0,0 +1,60 @@
|
||||
#include <DueTimer.h>
|
||||
|
||||
void playVideogame(){
|
||||
Serial.println("[- ] I'm playing Videogame!");
|
||||
}
|
||||
|
||||
void drinkWater(){
|
||||
Serial.println("[ - ] I'm driking water!");
|
||||
}
|
||||
|
||||
void makeSushi(){
|
||||
Serial.println("[ - ] Slicing Salmon...");
|
||||
}
|
||||
|
||||
void singOnShower(){
|
||||
Serial.println("[ - ] Hello World! Hello world!");
|
||||
}
|
||||
|
||||
void studyMath(){
|
||||
int x = random(1, 40), y = random(1,40);
|
||||
Serial.print("[ - ] ");
|
||||
Serial.print(x); Serial.print(" x "); Serial.print(y); Serial.print(" = ");
|
||||
Serial.println(x*y);
|
||||
}
|
||||
|
||||
void watchStarTrek(){
|
||||
Serial.println("[ - ] Long live and prosper \\\\//_");
|
||||
}
|
||||
|
||||
void eatSushi(){
|
||||
Serial.println("[ - ] ...");
|
||||
}
|
||||
|
||||
void readTextMessage(){
|
||||
Serial.println("[ - ] [Unlock ---->>]");
|
||||
}
|
||||
|
||||
void goToSleep(){
|
||||
Serial.println("[ -] zzzzzz");
|
||||
}
|
||||
|
||||
void setup(){
|
||||
Serial.begin(9600);
|
||||
|
||||
Timer.getAvailable().attachInterrupt(playVideogame).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(drinkWater).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(makeSushi).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(singOnShower).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(studyMath).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(watchStarTrek).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(eatSushi).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(readTextMessage).start(); delay(50);
|
||||
Timer.getAvailable().attachInterrupt(goToSleep).start(); delay(50);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
while(1){
|
||||
// ...
|
||||
}
|
||||
}
|
||||
29
lib/DueTimer/examples/MultipleTimers/MultipleTimers.pde
Normal file
29
lib/DueTimer/examples/MultipleTimers/MultipleTimers.pde
Normal file
@ -0,0 +1,29 @@
|
||||
#include <DueTimer.h>
|
||||
|
||||
void firstHandler(){
|
||||
Serial.println("[- ] First Handler!");
|
||||
}
|
||||
|
||||
void secondHandler(){
|
||||
Serial.println("[ - ] Second Handler!");
|
||||
}
|
||||
|
||||
void thirdHandler(){
|
||||
Serial.println("[ -] Third Handler!");
|
||||
}
|
||||
|
||||
void setup(){
|
||||
Serial.begin(9600);
|
||||
|
||||
Timer3.attachInterrupt(firstHandler).start(500000); // Every 500ms
|
||||
Timer4.attachInterrupt(secondHandler).setFrequency(1).start();
|
||||
Timer5.attachInterrupt(thirdHandler).setFrequency(10);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
delay(2000);
|
||||
Timer5.start();
|
||||
|
||||
delay(2000);
|
||||
Timer5.stop();
|
||||
}
|
||||
25
lib/DueTimer/examples/SimpleTimer/SimpleTimer.pde
Normal file
25
lib/DueTimer/examples/SimpleTimer/SimpleTimer.pde
Normal file
@ -0,0 +1,25 @@
|
||||
#include <DueTimer.h>
|
||||
|
||||
int myLed = 13;
|
||||
|
||||
bool ledOn = false;
|
||||
void myHandler(){
|
||||
ledOn = !ledOn;
|
||||
|
||||
digitalWrite(myLed, ledOn); // Led on, off, on, off...
|
||||
}
|
||||
|
||||
void setup(){
|
||||
pinMode(myLed, OUTPUT);
|
||||
|
||||
Timer3.attachInterrupt(myHandler);
|
||||
Timer3.start(50000); // Calls every 50ms
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
||||
while(1){
|
||||
// I'm stuck in here! help me...
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user