• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need working circuit for this "arduino based 7 segment counter || Finger Click speed || Race"

Thread starter #1
Hello Friends,
Please have a look in the video below. I am working in a project like this. This guy presents his code and circuit in his video description, code is perfectly compiling but the circuit is not good. Please help me in designing a good circuit for this project with all buttons and resistors in place. Thanks


Things i have in my hand:
4 x single digit 7 seg display - Common Cathode
1 x Arduino Uno
5 x Push buttons
 

tomizett

Active Member
#2
Could you start by showing us that circuit you have already tired that's not working? Perhaps someone can tell you what's wrong with it.
 

Mike - K8LH

Well-Known Member
#4
That schematic you posted depicts common anode displays with PNP "source" drivers. The program 'sketch' appears to be for common cathode displays with NPN "sinking" digit drivers.

To use your common cathode displays with that program 'sketch' the schematic should probably look something like that shown below, though I'm not sure if the BC547 would be a suitable NPN transistor.

Cheerful regards, Mike

CC Mods.png
 
Last edited:

dr pepper

Well-Known Member
Most Helpful Member
#5
And if the code is written for common anode you'll need to invert the outputs, either by replacing the lookup table for the 7 seg, or by inverting the bits just before you write them using the ! operator.
 

Mike - K8LH

Well-Known Member
#6
As I mentioned in post #4, the program appears to be written for common cathode displays with NPN "sinking" drivers;

C:
byte seven_seg_digits[10][7] = {
        { 1,1,1,1,1,1,0 },  // = 0
        { 0,1,1,0,0,0,0 },  // = 1
        { 1,1,0,1,1,0,1 },  // = 2
        { 1,1,1,1,0,0,1 },  // = 3
        { 0,1,1,0,0,1,1 },  // = 4
        { 1,0,1,1,0,1,1 },  // = 5
        { 1,0,1,1,1,1,1 },  // = 6
        { 1,1,1,0,0,0,0 },  // = 7
        { 1,1,1,1,1,1,1 },  // = 8
        { 1,1,1,0,0,1,1 }   // = 9
};
const int one_u = A0;
const int one_d = A1; 
const int one_ahlah = 10;
const int one_baga = 9;
int one_us=0;
int one_ds=0;
int one_ufront = 0;
int one_dfront = 0;
int one_count = 0;
//up2 a2-up, a3-down, 12-ahlah,11-baga
//a4 - reset
const int two_u = A2;
const int two_d = A3; 
const int two_ahlah = 12;
const int two_baga = 11;
int two_us=0;
int two_ds=0;
int two_ufront = 0;
int two_dfront = 0;
int two_count = 0;

const int reset = A4;
int reset_s = 0;
int res = 0;

void setup() {             
  pinMode(2, OUTPUT);       // segment A
  pinMode(3, OUTPUT);       // segment B
  pinMode(4, OUTPUT);       // segment C
  pinMode(5, OUTPUT);       // segment D
  pinMode(6, OUTPUT);       // segment E
  pinMode(7, OUTPUT);       // segment F
  pinMode(8, OUTPUT);       // segment G
  pinMode(9, OUTPUT);       // ones left
  pinMode(10, OUTPUT);      // tens left
  pinMode(11, OUTPUT);      // ones right
  pinMode(12, OUTPUT);      // tens right
  pinMode(one_u, INPUT);
  pinMode(one_d, INPUT);
  pinMode(two_u, INPUT);
  pinMode(two_d, INPUT);
  pinMode(reset, INPUT);
}
void sevenSegWrite(byte digit) {
  byte pin = 2;
  for (byte segCount = 0; segCount < 7; ++segCount) {
    digitalWrite(pin, seven_seg_digits[digit][segCount]);
    ++pin;
  }
}

void loop() {
  res = digitalRead(reset);
  if(res==HIGH && reset_s==0){ reset_s =1; }
  if(res==LOW && reset_s ==1){ reset_s =0; one_count = 0; two_count = 0;}
  one_us = digitalRead(one_u);
  if(one_us==HIGH && one_ufront ==0){one_ufront =1;}
  if(one_us==LOW && one_ufront ==1) {one_ufront =0; one_count++;}
  one_ds = digitalRead(one_d);
  if(one_ds==HIGH && one_dfront ==0){one_dfront =1; }
  if(one_ds==LOW && one_dfront ==1) {one_dfront =0; one_count--;}
 
  if(one_count>99){one_count = 99;}
  if(one_count<0){one_count = 0;}   
   ////////////////////////////////////
   two_us = digitalRead(two_u);
  if(two_us==HIGH && two_ufront ==0){ two_ufront =1; }
  if(two_us==LOW && two_ufront ==1) { two_ufront =0;  two_count++; }
  two_ds = digitalRead(two_d);
  if(two_ds==HIGH && two_dfront ==0){ two_dfront =1; }
  if(two_ds==LOW && two_dfront ==1) { two_dfront =0;  two_count--; }
 
  if(two_count>99){two_count = 99;}
  if(two_count<0){two_count = 0;}

 
    digitalWrite(one_ahlah,1);      // left "tens" digit
    digitalWrite(one_baga,0);
    digitalWrite(two_ahlah,0);
    digitalWrite(two_baga,0);
    sevenSegWrite(one_count/10);
    delay(2);
    digitalWrite(one_ahlah,0);      // left "ones" digit
    digitalWrite(one_baga,1);
    digitalWrite(two_ahlah,0);
    digitalWrite(two_baga,0);
    sevenSegWrite(one_count%10);
    delay(2);     
    digitalWrite(one_ahlah,0);      // right "tens" digit
    digitalWrite(one_baga,0);
    digitalWrite(two_ahlah,1);
    digitalWrite(two_baga,0);
    sevenSegWrite(two_count/10);
    delay(2); 
    digitalWrite(one_ahlah,0);      // right "ones" digit
    digitalWrite(one_baga,0);
    digitalWrite(two_ahlah,0);
    digitalWrite(two_baga,1);
    sevenSegWrite(two_count%10);
    delay(2); 
 
}

//up2 a2-up, a3-down, 12-ahlah,11-baga
//a4 - reset
 

Latest threads

EE World Online Articles

Loading

 
Top