About This Project

In this project, we will learn about how to count a number using WHILE LOOP in Arduino. When the program is uploaded on the Arduino, the number will increase automatically until the limit given in the coding is reached.

Project Info

  • Programming Platform: Arduino IDE
  • Difficulty: Intermediate
  • Estimated Time: 1 Hr
  • Category: Arduino
  • Tags: Arduino, Jumper Wires, BreadBoard, LEDs, Resistor

Watch the video for While Loop in Arduino here.

Introduction

Do you know how to count a number? It is simple but counting through programming code might appear to be tricky. Not at all! If you are looking for how to count numbers through programming and coding then this is the right place. This tutorial will help you count numbers from infinity to infinity using WHILE LOOP.

What is a WHILE LOOP?

A WHILE LOOP is one of the control statements in a programming language that can make a certain task like counting numbers from a certain number to a certain number.It works within a limit set by the programmer.

Components Required

IMAGE COMPONENT QUANTITY

led-light

RGB LED

1

jumper-wire

Jumper Wires

As Per Requirement

resistor

Resistor

1

arduino

Arduino

1

Breadboard

Breadboard

1

Building Guide

Step 1: Assembly

  • Gather all the required components required for the project.

count-a-number-using-While-loop

Step 2: Circuitry

  • Connect one terminal of the Jumper Wire (male pin) on the Arduino Digital Pin-6 and the other side (female pin) to one of the terminals of Resistor’s Pins, now connect the other terminal pin of the resistor to the positive pin of the LED.
  • Repeat the same for all other LEDs’ pins with Arduino Digital Pins 7,8 and 9 respectively.
  • After all the connections to the positive terminals are done, now, connect all the negative terminals of the LEDs to the GROUND PINS of the Arduino.

count-a-number-using-While-loop-arduino

Step 3: CODING

count-a-number-using-While-loop-arduino-code

Step 4: Run the program after upload. Now, we can see that the number has started counting from 0 till the limit set in the coding.

count-a-number-using-While-loop-arduino-code-1

Step 5: As the number starts counting LEDs are also following the number respectively and helps us to look like a Police Siren Light by following the light one after another.

The following code will help you to make count a number using while loop in arduino.

Code

DESCRIPTION

DOWNLOAD CODE

Count A Number Using While Loop In Arduino.


Download Code

This way you can make a number counter using While Loop. Isn’t this an interesting project to work on? Have you tried it out? Do let us know.