Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

4 digit 7 segment display
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

4 digit 7 segment display

by LitingWolf on Sun Aug 02, 2020 3:46 am

im trying to get numbers to stay on but i went to us delay(001) and delay(1) but its not staying on i see the digit turn on and off rapidly
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_MCP23017.h>
#include <SevSeg.h>

Adafruit_MCP23017 mcp6;

void setup () {

 mcp6.begin(B101);
  mcp6.pinMode(9, OUTPUT);//pinA
  mcp6.pinMode(5, OUTPUT);//pinB
  mcp6.pinMode(2, OUTPUT);//pinC
  mcp6.pinMode(1, OUTPUT);//pinD
  mcp6.pinMode(0, OUTPUT);//pinE
  mcp6.pinMode(8, OUTPUT);//pinF
  mcp6.pinMode(3, OUTPUT);//pinG
  mcp6.pinMode(10, OUTPUT);//D1
  mcp6.pinMode(7, OUTPUT);//D2
  mcp6.pinMode(6, OUTPUT);//D3
  mcp6.pinMode(4, OUTPUT);//D4

}

void loop () {

digit1();two();
digit2();zero();
digit3();two();
digit4();zero();

void zero(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, HIGH);
mcp6.digitalWrite(8, HIGH);
mcp6.digitalWrite(3, LOW);
  }

void one(){
mcp6.digitalWrite(9, LOW);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, LOW);
mcp6.digitalWrite(0, LOW);
mcp6.digitalWrite(8, LOW);
mcp6.digitalWrite(3, LOW);
}

void two(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, LOW);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, HIGH);
mcp6.digitalWrite(8, LOW);
mcp6.digitalWrite(3, HIGH);
  }
 
void three(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, LOW);
mcp6.digitalWrite(8, LOW);
mcp6.digitalWrite(3, HIGH);
    }
   
void four(){
mcp6.digitalWrite(9, LOW);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, LOW);
mcp6.digitalWrite(0, LOW);
mcp6.digitalWrite(8, HIGH);
mcp6.digitalWrite(3, HIGH);
    }
   
void five(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, LOW);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, LOW);
mcp6.digitalWrite(8, HIGH);
mcp6.digitalWrite(3, HIGH);
    }
   
void six(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, LOW);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, HIGH);
mcp6.digitalWrite(8, HIGH);
mcp6.digitalWrite(3, HIGH);
    }
   
void seven(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, LOW);
mcp6.digitalWrite(0, LOW);
mcp6.digitalWrite(8, LOW);
mcp6.digitalWrite(3, LOW);
    }
   
void eight(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, HIGH);
mcp6.digitalWrite(8, HIGH);
mcp6.digitalWrite(3, HIGH);
    }
   
void nine(){
mcp6.digitalWrite(9, HIGH);
mcp6.digitalWrite(5, HIGH);
mcp6.digitalWrite(2, HIGH);
mcp6.digitalWrite(1, HIGH);
mcp6.digitalWrite(0, LOW);
mcp6.digitalWrite(8, HIGH);
mcp6.digitalWrite(3, HIGH);
    }

void digit1(){
mcp6.digitalWrite(10, LOW);
mcp6.digitalWrite(7, HIGH);
mcp6.digitalWrite(6, HIGH);
mcp6.digitalWrite(4, HIGH);
      }
     
    void digit2(){
mcp6.digitalWrite(10, HIGH);
mcp6.digitalWrite(7, LOW);
mcp6.digitalWrite(6, HIGH);
mcp6.digitalWrite(4, HIGH);
      }
     
    void digit3(){
mcp6.digitalWrite(10, HIGH);
mcp6.digitalWrite(7, HIGH);
mcp6.digitalWrite(6, LOW);
mcp6.digitalWrite(4, HIGH);
      }
     
    void digit4(){
mcp6.digitalWrite(10, HIGH);
mcp6.digitalWrite(7, HIGH);
mcp6.digitalWrite(6, HIGH);
mcp6.digitalWrite(4, LOW);
      }
}

LitingWolf
 
Posts: 37
Joined: Thu Jan 02, 2020 3:03 pm

Re: 4 digit 7 segment display

by adafruit_support_carter on Mon Aug 03, 2020 1:15 pm

I don't see a delay in your loop.

Also, move your function definitions outside of the loop().

adafruit_support_carter
 
Posts: 16944
Joined: Tue Nov 29, 2016 2:45 pm

Re: 4 digit 7 segment display

by LitingWolf on Mon Aug 03, 2020 1:29 pm

If i do the display will ony run once

LitingWolf
 
Posts: 37
Joined: Thu Jan 02, 2020 3:03 pm

Re: 4 digit 7 segment display

by adafruit_support_carter on Tue Aug 04, 2020 11:14 am

Define the functions outside the loop and add calls to them inside the loop.

adafruit_support_carter
 
Posts: 16944
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.