Code Monkey home page Code Monkey logo

arduino_timer's Introduction

Timer

Getting Started

  1. Move the Timer folder to your Arduino Libraries folder (e.g. Documents/Arduino/libraries).
  2. Use #include <Timer.h> at the top of your sketch or click Sketch -> Include Library -> Timer.

Functionality

Constructor:

  • Default Constructor

LED Pulse Functions:

  • void initiate_pulse
  • void update_pulse

Wait Functions:

  • bool wait
  • void clear

Examples

Pulse LED

//  Declare Timer object as a global variable
Timer led_timer;

void setup() {
    //  Set the LED pin to 13 and the period to 1 second (1000 ms)
    led = 13;
    period = 1000;
    Call initiate_pulse once with the LED pin and period in milliseconds as arguments    
    led_timer.initiate_pulse(led, timer)
}

void loop() {
    //  Call update_pulse in a loop to flash the LED with the given period
    led_timer.update_pulse();
}

Wait

Timer delay_timer;

void setup() {
    //  Empty
}

void loop() {
    //  Set the period to 10 seconds (10000 ms)
    period = 10000;
    //  Use this Timer to wait until a given time period has passed to do something
    if (delay_timer.wait(period)) {
        //  Do stuff
    }
}

Author

Copyright 2018 Aidan Clyens

arduino_timer's People

Contributors

aidan-clyens avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.