Help using nested ifs on a simple 7-segment display program

I've narrowed this down to a code issue. I'm trying to get the display to switch to the next number when touched by a touch sensor (pin 13).

const int a=7; //a of 7-segment attach to digital pin 7
const int b=6; //b of 7-segment attach to digital pin 6
const int c=5; //c of 7-segment attach to digital pin 5
const int d=11;//d of 7-segment attach to digital pin 11
const int e=10;//e of 7-segment attach to digital pin 10
const int f=8;//f of 7-segment attach to digital pin 8
const int g=9;//g of 7-segment attach to digital pin 9
const int dp=4;//dp of 7-segment attach to digital pin 4
 
void setup()
{
//loop over thisPin from 4 to 11 and set them all to output
for(int thisPin = 4;thisPin <= 11;thisPin++)
{
pinMode(thisPin,OUTPUT);
}
pinMode(13,INPUT);
digitalWrite(dp,LOW);//turn the dp of the 7-segment off 
}
 
void loop()
{
digital_1();//diaplay 1 to the 7-segment
if (13 == HIGH){
  //wait for a second
digital_2();//diaplay 2 to the 7-segment
if (13 == LOW){
digital_3();
if (13 == HIGH){
digital_4();
if (13 == LOW){
digital_5();
if (13 == HIGH){
digital_6();
if (13 == LOW){
digital_7();
if (13 == HIGH);
digital_8;
if (13 == LOW){
digital_9;
}}}}}}}}
 
void digital_1(void) //diaplay 1 to the 7-segment
{
digitalWrite(c,HIGH);//turn the c of the 7-segment on
digitalWrite(b,HIGH);//turn the b of the 7-segment on
for(int j = 7;j <= 11;j++)//turn off the others
digitalWrite(j,LOW);
}
void digital_2(void) //diaplay 2 to the 7-segment
{
digitalWrite(b,HIGH);
digitalWrite(a,HIGH);
for(int j = 9;j <= 11;j++)
digitalWrite(j,HIGH);
digitalWrite(c,LOW);
digitalWrite(f,LOW);
}
void digital_3(void) //diaplay 3 to the 7-segment
{
unsigned char j;
digitalWrite(g,HIGH);
digitalWrite(d,HIGH);
for(j=5;j<=7;j++)
digitalWrite(j,HIGH);
digitalWrite(f,LOW);
digitalWrite(e,LOW);
}
void digital_4(void) //diaplay 4 to the 7-segment
{
digitalWrite(c,HIGH);
digitalWrite(b,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(a,LOW);
digitalWrite(e,LOW);
digitalWrite(d,LOW);
}
void digital_5(void) //diaplay 5 to the 7-segment
{
unsigned char j;
for(j = 7;j <= 9;j++)
digitalWrite(j,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(b,LOW);
digitalWrite(e,LOW);
}
void digital_6(void) //diaplay 6 to the 7-segment
{
unsigned char j;
for(j = 7;j <= 11;j++)
digitalWrite(j,HIGH);
digitalWrite(c,HIGH);
digitalWrite(b,LOW);
}
void digital_7(void) //diaplay 7 to the 7-segment
{
unsigned char j;
for(j = 5;j <= 7;j++)
digitalWrite(j,HIGH);
for(j = 8;j <= 11;j++)
digitalWrite(j,LOW);
}
void digital_8(void) //diaplay 8 to the 7-segment
{
unsigned char j;
for(j = 5;j <=11;j++)
digitalWrite(j,HIGH);
}
void digital_9(void) //diaplay 9 to the 7-segment
{
unsigned char j;
for(j = 5;j <=9;j++)
digitalWrite(j,HIGH);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
}

Thanks in advance. Partial code credit to Sunfounder.

if (13 == HIGH){

Does that seem likely to you?

Did you forget to read pin 13?

Partial code credit

sp. "blame"

}}}}}}}}

Don't you just hate it when that happens?

if (13 == HIGH){


// should be 



if (digitalRead(13) == HIGH){

AWOL:

sp. "blame"

[code]}}}}}}}}



Don't you just *hate* it when that happens?

I'm definitely not blaming anyone. I used Sunfounder's code as a base and developed on top. My errors are mine alone. Very nice of a Global Mod to act like that to someone who's new to the community, it gives just the right impression :slight_smile:

Also, no, I don't mind formatting like that. It drives some people on the walls, but keeping it together like that works for me.

BillHo:

if (13 == HIGH){

// should be

if (digitalRead(13) == HIGH){

Thank you! Now I feel silly.

When they gave me the mod badge, they didn't say I had to turn in my sense of humour.

If you jump down from your high horse for a moment, you'll see I gave you your answer within five minutes of you posting your problem.

You're welcome.