Friday 8 September 2017

3 in 1 Arduino Seven Segments Counter Project








As you know, the SSD or Seven Segments Display can make
numbers. It can be connected with arduino. So this 4 digit SSD is useful to
make some projects with arduino. This tutorial is to make counting units in 3
ways.



This is the most cheapest and effective SSD counter. And you can use it for three different purposes. Lets start to programme it with SetNfix.


Watch this sample Video





You can use the same programme for

01. Flood level meter

02.Visitor Counter

03.Continue Counter


But You have to do only few changes to the progtamme.



Following components are needed.


01.Push button switch

02.10k Potentiometer

03.Arduino Uno with Atmega 328

04.Seven Segments (4 Digits)



I have used here a comman Anode Seven Segment. Details as follows

KYX - 5461BS SSD was used in this project











  Pin connection to Arduino Uno

















SSD Pin No Arduino Pin SSD
1 6 e
2 5 d
3 1 Dp
4 4 c
5 8 g
6 9 Digit 4
7 3 b
8 10 Digit 3
9 11 Digit 2
10 7 f
11 2 a
12 12 Digit 1


















a
f b
g
e c
d



Circuit Diagram












01.Flood Level Meter





You can connect to Analog pin 0 the following Circuit










02 .Continue counter 





You can connect to Analog pin 0 the following Circuit






03.Visitors counter






If you want to count number of visitors then you can use the following diagram. Use LDR and light a laser and focus to the face of LDR.









Then you can copy and upload following codes to run the programme.




/*

/** This code is edited by www.SetNfix.com **/


int Ntime = 0;
int Otime = 0;
float X = 0;
int time = 4;

int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int pinDP = 1;

int DIG1 = 12;
int DIG2 = 11;
int DIG3 = 10;
int DIG4 = 9;

void choose_digit(char num) {
switch (num) {
default: digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, HIGH); digitalWrite(pinDP, HIGH); break; case 1: digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); digitalWrite(pinDP, HIGH); break; case 2: digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, HIGH); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break; case 3: digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break; case 4: digitalWrite(pinA, HIGH); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break; case 5: digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break; case 6: digitalWrite(pinA, LOW); digitalWrite(pinB, HIGH); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break; case 7: digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, HIGH); digitalWrite(pinE, HIGH); digitalWrite(pinF, HIGH); digitalWrite(pinG, HIGH); digitalWrite(pinDP, HIGH); break; case 8: digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, LOW); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break; case 9: digitalWrite(pinA, LOW); digitalWrite(pinB, LOW); digitalWrite(pinC, LOW); digitalWrite(pinD, LOW); digitalWrite(pinE, HIGH); digitalWrite(pinF, LOW); digitalWrite(pinG, LOW); digitalWrite(pinDP, HIGH); break;

;
}
}

void pick_digit(int digit) {
digitalWrite(DIG1, LOW);
digitalWrite(DIG2, LOW);
digitalWrite(DIG3, LOW);
digitalWrite(DIG4, LOW); switch (digit) {
case 1: digitalWrite(DIG1, HIGH); break; case 2: digitalWrite(DIG2, HIGH); break; case 3: digitalWrite(DIG3, HIGH); break; default: digitalWrite(DIG4, HIGH); break;
}

}

void decimal_place() {
digitalWrite(pinDP, LOW);
}

void seven_segment(int number) {
unsigned char thousands = int (number / 1000);
unsigned char hundreds = int ((number / 100) % 10);
unsigned char tens = int ((number / 10) % 10);
unsigned char ones = int (number % 10); //1234
if (thousands > 0) {
choose_digit(thousands);
pick_digit(1);
}

if ((hundreds > 0) | (thousands > 0)) {
delay(time); choose_digit(hundreds);
pick_digit(2);
}

if ((tens > 0) || (hundreds > 0) | (thousands > 0)) {
//decimal_place();
delay(time); choose_digit(tens);
pick_digit(3);
}


// add decimal point
delay(time); choose_digit(ones);
pick_digit(4);

delay(time);

}

void setup() {
pinMode(DIG1, OUTPUT);
pinMode(DIG2, OUTPUT);
pinMode(DIG3, OUTPUT);
pinMode(DIG4, OUTPUT);
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinDP, OUTPUT);

}

void loop() {
float sensor_value = map(analogRead(A0),0,1023,0,3000); // for Flood level Sensor this Eg:3000 is the maximum level




// Continue counter and Visitors counter
/**
Ntime = millis();
if (analogRead(A0) > 0) {

if ((Ntime - Otime) > 200) {
X = X + 1;
Otime = Ntime; // Active this to visitors counter
{
if (X == 9999) {
X = 0;
}
}
}
//Otime = Ntime; // Active this to continue counter

}

float sensor_value = X; */




seven_segment(sensor_value);

}


Code should be edited as follows.


01. Flood Level









02. Continue Counter






03. Visitors Counter







**Your comments are highly appreciated by SetNfix **





Previous Post
Next Post

post written by:

0 comments: