StateChangeDetection - /* State change detection (edge...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* State change detection (edge detection) Often, you don't need to know the state of a digital input all the time, but you just need to know when the input changes from one state to another. For example, you want to know when a button goes from OFF to ON. This is called state change detection, or edge detection. This example shows how to detect when a button or button changes from off to on and on to off. The circuit: * pushbutton attached to pin 2 from +5V * 10K resistor attached to pin 2 from ground * LED attached from pin 13 to ground (or use the built-in LED on most Arduino boards) created 27 Sep 2005 modified 30 Dec 2009 by Tom Igoe This example code is in the public domain. */ // this constant won't change: const int buttonPin = 2; // the pin that the pushbutton is attached to const int ledPin = 13; // the pin that the LED is attached to c // Variables will change: int buttonPushCounter = 0; // counter for the number of button presses
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/31/2011 for the course CS 302 taught by Professor J.parker during the Spring '08 term at University of Texas at Austin.

Page1 / 2

StateChangeDetection - /* State change detection (edge...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online