Loading...
Welcome,
Guest
. Please
login
or
register
.
May 21, 2013, 02:45:28 am
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: Timer
« previous topic
next topic »
Pages: [
1
]
Go Down
Print
Author
Topic: Timer (Read 110 times)
0 Members and 1 Guest are viewing this topic.
Lavan
Offline
Jr. Member
Karma: 0
Posts: 57
Timer
«
on:
March 13, 2012, 10:58:42 am »
Bigger
Smaller
Reset
I am doing my first project and looking for the timer code to turn the output ON / OFF after certain time say 1 minute or 5 minutes. Currently I am using millis() to achieve this, but I think there will be a better way to do this, any suggestions are welcome!!!
Currently I am using below sketch to turn OFF the output after 1 minute.
********************************
unsigned long time;
void setup() {
pinMode(13, OUTPUT);
pinMode(9, INPUT);
}
void loop() {
if (digitalRead(9) == HIGH)
{
digitalWrite(13, HIGH);
time = millis();
}
if (millis() - time > 60000)
{
digitalWrite(13, LOW);
}
}
Logged
PaulS
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
Re: Timer
«
Reply #1 on:
March 13, 2012, 11:04:08 am »
Bigger
Smaller
Reset
On the top of every single page is a link to the Playground. On the main playground page, there is a link, in the left column, to user contributed libraries. A number of them relate to timing.
Logged
Pages: [
1
]
Go Up
Print
« previous topic
next topic »
|
Arduino Forum
::
Using Arduino
::
Programming Questions
:: Timer
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
-----------------------------
Using Arduino
-----------------------------
=> Installation & Troubleshooting
=> Project Guidance
=> Programming Questions
=> General Electronics
=> LEDs and Multiplexing
=> Displays
=> Audio
=> Motors, Mechanics, and Power
=> Sensors
=> Networking, Protocols, and Devices
=> Interfacing w/ Software on the Computer
-----------------------------
Topics
-----------------------------
=> E-Textiles and Craft
=> Robotics
=> Science and Measurement
=> Home Automation and Networked Objects
=> Device Hacking
=> Education and Teaching
=> Interactive Art
=> Product Design
-----------------------------
Development
-----------------------------
=> Suggestions for the Arduino Project
=> Other Hardware Development
=> Other Software Development
-----------------------------
Community
-----------------------------
=> Website and Forum
=> Products and Services
=> Gigs and Collaborations
=> Workshops and Events
=> Local Groups
=> Exhibition / Gallery
=> Bar Sport
-----------------------------
International
-----------------------------
=> Deutsch
=> Español
=> Français
=> Italiano
=> Portugues
=> Scandinavia
-----------------------------
Forum 2005-2010 (read only)
-----------------------------
===> Uno Punto Zero
===> Bar Sport
===> Frequently-Asked Questions
===> News
===> Exhibition
===> Workshops
===> Interfacing
===> Bugs & Suggestions
===> Development
===> Troubleshooting
===> Portugues
===> Deutsch
===> Español
===> Français
===> Italiano
===> Scandinavia
===> Development
===> Interfacing
===> Syntax & Programs
===> Bugs & Suggestions
===> Troubleshooting
===> Report Spam at Arduino.cc
===> Forum
===> Playground Wiki
=> General
=> Hardware
=> Software
=> International
=> Web/Forum/Email/Spam
-----------------------------
Using Arduino
-----------------------------
=> Storage
=> Microcontrollers
-----------------------------
International
-----------------------------
===> Humor y Debate
===> Talleres, Encuentros, ...
===> Tutoriels et cours
===> Réalisations et Projets Finis
===> Le bar
=> Nederlands
===> Software
===> Hardware
===> Proyectos
===> Documentación
=> India
===> Hardware
===> Software
===> Megatopic
-----------------------------
Products
-----------------------------
=> The Arduino Starter Kit
=> Arduino Due
-----------------------------
International
-----------------------------
===> Generale
-----------------------------
Products
-----------------------------
=> Arduino Esplora
=> Arduino GSM Shield
-----------------------------
Maker Faire Rome - The European Edition
-----------------------------
=> Makers
=> Events and Tour
Loading...