Introduction: Up Down Counter Using Arduino

Picture of Up Down Counter Using Arduino

Hello Ardu-man!

Today I am going to make a UP/DOWN counter using Arduino.

Step 1: Things That Are Required

1) Arduino Uno (any board)

2) Breadboard

3) 2x1k ohm resistor

4) 2x push switch

5) 1x 10k potentiometer

6) 1x 16x2 lcd

7) Jumper wires

Step 2: Circuit Diagram

Picture of Circuit Diagram

Step 3: Code

Picture of Code

//UP DOWN Counter.

#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

int A;

int B;

int t;

int ctr=0;

void setup()

{

lcd.begin(16,2);

lcd.print("UP DOWN Counter");

delay(2000);

}

void loop()

{

A = analogRead(A0);

B = analogRead(A1);

t = 300;

if(A < t && B > t)

{

ctr = ctr + 1;

delay(900);

}

else

{

ctr = ctr;

}

if(A > t && B < t)

{

ctr = ctr -1;

delay(900);

}

else

{

ctr = ctr;

}

lcd.setCursor(0,0);

lcd.print("Counter : ");

lcd.setCursor(10,0);

lcd.print(ctr);

delay(100);

lcd.clear();

}

Comments

rhorne5 (author)2017-02-16

How easy would it be to modify this so that when the counter hits a certain number it triggers a micro switch?

Adil95 (author)rhorne52017-02-17

Very easy.

Just add a "if" statement.

Oujidon123 (author)2016-11-21

I've been needing a 7 segment arduino up down counter that goes from 0 to 9, can anyne help?

Eric Brouwer made it! (author)2016-11-20

What a coincidence...

I just published my own Up/Down counter :) :)

https://www.instructables.com/id/7-Segment-UpDown-Counter/

About This Instructable

4,900views

42favorites

License:

Bio: Technology enthusiastic, crazy about embedded system, love Arduino and raspberry pi.
More by Adil95:IoT based Temperature monitoring systemUp Down Counter Using ArduinoLED chaser using raspberry pi
Add instructable to: