You are on page 1of 8

Home

Arduino Tutorials

About Me

Tw eet

Like

Share

Search

Arduino Tutorial Series ON LED After A Button Push


Posted on December 24, 2012 by admin

t opics
android app arduino code do it yourself Extra gadgets hacking gadgets just looking my projects Software

... A slight modification of the previous article, Turning The LED ON with a Push Button. I modified it so that the LED stays ON with a single button push. Then it turns off after pushing for the second time. The debounce I used is base on delay so hold pressing the button will turn the led on and off repeatedly.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

r ec ent ar t ic les
Intel RST for Cooler Platform Controller Hub (PCH) I Installed a Lincensed ESET NOD32 Antivirus! The Tale of Impulsive Upgrader | From Windows.3x to Windows 8 / 8.1 Bluetooth File Transfer Protocol Version 2 Blocking The Globe Tattoo Ghost Web Icon A Laptop Cooling Pad Test Problem Solving | Bluetooth File Transfer from Android Phone to

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Transfer from Android Phone to PC

r ec ent comment s
Xcharles on The Unexpected Globe Tattoo 800MB Data Limit adnan adam on The Huawei Mobile Pocket Wifi E5220 Nico on The Huawei Mobile Pocket Wifi E5220 admin on The Huawei Mobile Pocket Wifi E5220 Nico on The Huawei Mobile Pocket Wifi E5220

Copy the sketch, paste, compile and upload.

t ags
/******************************** Setting up the push button circuit: 1) Set legs as A and B 2) Connect 5+ volts power to leg A 3) Connect 10k ohm resitor from ground to leg B 4) Connect Arduino pin 4 to leg B
open in browser PRO version
Are you a developer? Try out the HTML to PDF API

android arduino
battery camera computer ddwrt

electricity epson fan freedom


plan drive

globe hard disk hard


huawei internet
pdfcrowd.com

Setting up the LED 1) Connect Arduino pin 8 to 330 ohms resistor, then the resitor to longer/postive LED leg. 2) Connect the shorter/negative LED leg to ground. ********************************/ // set pin const byte // set pin const byte 4 as pushbutton pushbutton = 4; 8 as led pin led = 8;

drive

huawei internet

laptop lcd ldr led leds linux


mmorpg m otor mp3 phone potentiometer pow er supply psu push button

qos router samsung

sd card seven segm ents smart sony


stepper m otor

sun cellular

tattoo toshiba usb wifi


windows w ire wordpress

// set variable buttonstate // as boolean. boolean buttonstate; byte pushcounter = 0; /******************************** boolean carries only two values 0 and 1, or false and true ********************************/ void setup(){//void setup start // the pushbutton as input pinMode(pushbutton,INPUT); // the led as output pinMode(led,OUTPUT);
open in browser PRO version
Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

}// void setup end void loop() {//void loop start buttonstate = digitalRead(pushbutton); // a simple debounce using delay delay(300); if (buttonstate == true){//if buttonstate start // adds 1 to pushcounter variable when the // buttonstate is true pushcounter = pushcounter +1; }//if buttonstate stop if (pushcounter == 1){//if buttonstate start // turns the led on if the pushcounter value // is equal to 1 digitalWrite(led,HIGH); }//if buttonstate stop if (pushcounter == 2){//if buttonstate start // turns the led off if the pushcounter is // equal to 2, the resets it value to 0 digitalWrite(led,LOW); pushcounter = 0; }//if buttonstate stop }//void loop end

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

RE L A T E D P O S T S

1. Arduino Tutorial Series Turning The LED ON with a Push Button 2. Arduino Tutorial Series A Push Button and A Glowing LED 3. Arduino Tutorial Series Seven Segments Part 1 4. Arduino Tutorial Series The On-board Blinking LED ...
0 Tw eet 0 Like Share 0

This entry was posted in arduino and tagged arduino, led, push button by admin. Bookmark the permalink.

Leave a Reply
Your email address will not be published. Required fields are marked *

Name

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Email

Website

Post Comment

Arduino Tutorial Series Turning The LED ON with a Push Button Arduino Tutorial Series Reading and Converting
open in browser PRO version
Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Potentiometer Values

by luntianlaboratory.com 2010-2012 see change log, site rules & stuff posts with pictures of luntiancorner.com were moved articles. they are owned by the same author

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

You might also like