Search code examples
c++esp32seven-segment-display

Using ESP 32 for 7 segment display


The void one() was not displaying in 7 segments. What might be the problem?

int pinout[] = {23,22,21,19,18,5,4};
int zeroseg[] = {23,22,21,19,18,4};
int oneseg[] = {22,21,19,18,4,23};

void setup() {
  Serial.begin(115200);
  for (int i=0; i<7; i++)
    pinMode(pinout[i], OUTPUT);
}

void d() {
  delay(1000);
}

void zero() {
  for (int i=0; i<6; i++)
    digitalWrite(zeroseg[i], HIGH);
}

void one() {
  for (int i=0; i<1; i++)
    digitalWrite(oneseg[i], HIGH);
}

void loop() {
  zero();
  d();
  one();
  d();
}

I try using array and for loop but it's not displaying.


Solution

  • You are just using digitalWrite(zeroseg[i], HIGH); -- HIGH and here as well digitalWrite(zeroseg[i], HIGH); -- HIGH

    You are never using LOW. Does all the segments stay ON or all of them stay OFF

    Regards