Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blanboom/Arduino-Task-Scheduler
Enable Arduinos to run multiple tasks.
https://github.com/blanboom/Arduino-Task-Scheduler
Last synced: 3 months ago
JSON representation
Enable Arduinos to run multiple tasks.
- Host: GitHub
- URL: https://github.com/blanboom/Arduino-Task-Scheduler
- Owner: blanboom
- License: gpl-2.0
- Created: 2013-07-27T07:17:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-19T13:44:34.000Z (over 9 years ago)
- Last Synced: 2024-08-01T03:13:41.312Z (6 months ago)
- Language: C++
- Homepage: http://blanboom.org/arduino-task-scheduler-library.html
- Size: 173 KB
- Stars: 92
- Watchers: 11
- Forks: 34
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
- stars - blanboom/Arduino-Task-Scheduler
README
This is a task scheduler for Arduinos with a ATmega328p microcontroller. Inspired by *[Patterns for Time-Triggered Embedded Systems](http://books.google.com/books?vid=ISBN0201331381&redir_esc=y&hl=zh-CN&sourceid=cndr)*.
NOTE: This library uses Timer 1 on ATmega328p, so it is incompatible some libraries using the same timer. (Such as [Servo](http://www.arduino.cc/en/Reference/Servo), [Mozzi](http://sensorium.github.io/Mozzi/), or `analogWrite()` on pin 9 and 10)
## How to use?
**STEP 1**. Put ```Sch.init();``` and ```Sch.start();``` into ```void setup()```, and put ```Sch.dispatchTasks();``` into ```void loop()```, like this:
```C
void setup()
{
// Your code...Sch.init();
Sch.start();
}void loop()
{
Sch.dispatchTasks();
}
```**STEP 2**. Put tasks at the end of your code, like this:
```C
void setup()
{
// Your code...Sch.init();
Sch.start();
}void loop()
{
Sch.dispatchTasks();
}// Tasks
void task1()
{
// Your code...
}void task2()
{
// Your code...
}
```**STEP 3**. Use ```Sch.addTask()``` between ```Sch.init();``` and ```Sch.start();``` to add tasks into the task scheduler, like this:
```C
void setup()
{
// Your code...Sch.init();
Sch.addTask(task1,0,1000,1); // Add task1. Starts at the 0th ms, and runs every 1000 ms
Sch.addTask(task2,20,500,1); // Add task2. Starts at the 20th ms, and runs every 500 ms
Sch.start();
}void loop()
{
Sch.dispatchTasks();
}
```
中文简介在这里:http://blanboom.org/arduino-task-scheduler-library.html