• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Arduino LED Blinks with Pushbutton Pause

By Abhishek Ghosh June 16, 2023 7:28 pm Updated on June 19, 2023

Arduino LED Blinks with Pushbutton Pause

Advertisement

We have published several simple articles on Arduino, LED and pushbuttons. They are a great learning tool for the children, as well as great “templates” for the adults to start a new project. Here is a list of some of the old articles:

  • Arduino 2 Push Button One LED: Switch On/Off
  • Make Beep Sound in Arduino Project Upon Push Button Press
  • Arduino Blink LED Rate Depending On Push Button Press Duration
  • Arduino: Blink LED and Beep Every X Seconds Upon Push Button Press
  • Arduino Flip-Flop Blinking LED With Push Button
  • Arduino Blink LED With Pushbutton Control to Turn ON and Off
  • One Push Button Multiple Functions (Single Press, Double Press, Long-Time Press)
  • Arduino 3 LED and One Push Button

In this article’s code, the LED will start blinking on its own. When we will press the push button it will pause or start the blink. We have added a potentiometer which will set the delay() for the blink.

Arduino LED Blinks with Pushbutton Pause

I found that Zeynep Öztürk already created a similar project and the simulation is available here on Tinkercad.

Advertisement

---

I have forked it here. The forked version is slightly different. You can try it here by first clicking the “Simulate” button, then clicking the push button:

Here is the code:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
int led = 11; // led connected to 11th port
int button = 7;// button connected to 7th port
int pot =0;// potentiometer connected to A0
 
int potValue;
int buttonStatus = 0;
int ledStatus = 0;
 
void setup()
{
  pinMode(led, OUTPUT);// led set to output
  pinMode(button,INPUT);//button set to input
  Serial.begin(9600);
  digitalWrite(led, LOW);// led set to off mode
}
 
void loop()
{
  buttonStatus = digitalRead(button); //reads the value from the button
  delay(100); // wait 10 milliseconds
  
  if(buttonStatus == 1) // if you pressed the button
  {
    
    if(ledStatus == 0) // if led status is in off mode
    {
      ledStatus = 1;// make led status is on mode
    }
    else
    {
      digitalWrite(led,LOW);
      ledStatus = 0;
    }
  }
  
  if(ledStatus == 1)//if led status is in on mode
  {
    potValue = analogRead(A0)*10;//The potentiometer value and analog readout were equaled.
    //multiplied by 10 to convert to seconds
    Serial.println(potValue/1000);//divided by 1000 so that the value given on the serial monitor is in seconds.
    digitalWrite(led, HIGH);// led turns on
    delay(potValue);//The led stays on for as many seconds as the pot value.
    digitalWrite(led, LOW);// led turns off
    delay(potValue);//The led stays off for as many seconds as the pot value.
 
    
  }
  
}

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Arduino LED Blinks with Pushbutton Pause

  • Arduino and LED Bar Display : Circuit Diagram, Code

    Here is a Guide Explaining the Basics, Circuit Diagram, Code on Arduino and LED Bar Display. LED Bar Display is Actually Like Multiple LED.

  • Arduino Blink LED With Pushbutton Control to Turn ON and Off

    Arduino Blink LED With Pushbutton Control to Turn ON and Off is Few Steps Higher Than Basic Example. There is Matter of Repeat Checking by Microcontroller.

  • Mini Christmas Light With Arduino (Very Easy)

    Here is a Mini Christmas Light With Arduino as Project Which Needs 3 Resisters and 3 LEDs, No External Power Supply. It Has 2 Blink Effects.

  • How to Control Multiple Relays With Single Arduino ESP32?

    Before How to Control Multiple Relays With Single Arduino ESP32 Testing, You Need to Learn How to Create Multiple MQTT Channels & Fetch Data.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy