Arduino Nano: Tutorial to turn on and turn off a led using Timers

in #utopian-io7 years ago (edited)

Screenshot.jpg
photocredits

Timers in Arduino

In many tutorials the delay is used to temporize things, so we used a delay of about 250 ms for an LED to turn on and off, quietly. Of course this means that we can not do anything else until the delay is over.

For that we have scheduled interruptions or Timers, so that ring the bell when we have to execute a programmed function, without having to be continually checking if it is the time.

we are going to use the arduino nano to turn on and off a led. the nano has an integrated LED to pin 13 so we will use this pin for more convenience.

Here we are going to see a photo of the arduino nano:
Screenshot002.jpg
PhotoCredits

Activity

We are going to use an arduino timer, specifically the "TimerOne" library to turn on a led in arduino nano

difficulty

This tutorial is for those who know the basics of Arduino.

Requirement

  • Arduino nano with USB Cable
  • Laptop with Arduino IDE
  • "TimerOne" Library

Steps to follow

  • Prepare the equipment needed for the activity.
  • Connect the arduino to the Laptop using the usb cable
  • Open Arduino IDE

now let's use the blink example and we will modify it to use the timer.
for this open the blink example:
Sin título.png

you will see this window:
Sin título1.png

now we are going to "manage libraries" to install the "TimerOne" library:
Sin título2.png

Once there we look for TimerOne and then we install it:
Sin título3.png

After we install the library we look for it to add it to the project:
Sin título4.png

when we import the library you are ready to use it.

In the following image we will see the code to turn on the built-in led to the nano using timers, the code is explained. remember that you must have basic arduino notions.

Program

Sin título5.png

Using the interruptions gives us the advantage that we can do anything else while we wait for the event to happen, simply when the event occurs it alters the natural flow of the program to address that interruption, basically it is an order of priorities.

Collaborations



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.031
BTC 62731.36
ETH 2678.00
USDT 1.00
SBD 2.54