ES33B08 FAQ

Hello... My name is Eduardo and I'm testing the ES33B08 board.

I'm trying to use at the same time the 7 segments display and Darlington outputs:

a) The 7 segments tube is displaying the current IP adress the ESP32 received, after connecting to the WIFI

b) the darlignton outputs will command output LEDs and Stepmotor

 

Is it possible?

 

Below my current code

 

#include 

 

// Pinos conectados ao 74HC595

const int CLOCK_595 = 27;

const int LATCH_595 = 14;

const int DATA_595  = 13;

const int OE_595    = 4;

 

// Pinos para piscar

const int PULSE_PIN = 33;

const int DIR_PIN   = 25;

 

// Botão para futura expansão

const int BUTTON_PIN = 18;

 

// Segmentos para números 0–9 (comum ânodo)

uint8_t TUBE_SEG[] = {

  0x3f, 0x06, 0x5b, 0x4f,

  0x66, 0x6d, 0x7d, 0x07,

  0x7f, 0x6f

};

 

// Seleção de qual display acionar

uint8_t TUBE_NUM[8] = {

  0xfe, 0xfd, 0xfb, 0xf7,

  0xef, 0xdf, 0xbf, 0x7f

};

 

// Wi-Fi credentials

const char* ssid = "Posibras";

const char* password = "lucasmarzolla";

 

// IP para exibir

String ip_str = "";

int scrollIndex = 0;

unsigned long lastScroll = 0;

const int scrollDelay = 400;

 

uint8_t display_digits[4] = {0, 0, 0, 0};

bool digit_has_dot[4] = {false, false, false, false};

 

// Variáveis para piscar os pinos

bool pinsOn = false;

unsigned long lastBlink = 0;

const int blinkInterval = 500; // 500 ms

 

void Send_Bytes(uint8_t dat)

{

  for (int i = 8; i >= 1; i--)

  {

    digitalWrite(DATA_595, (dat & 0x80) ? HIGH : LOW);

    dat <<= 1;

    digitalWrite(CLOCK_595, LOW);

    digitalWrite(CLOCK_595, HIGH);

  }

}

 

void Send_74HC595(uint8_t com_num)

{

  uint8_t seg_data = display_digits[com_num];

 

  if (digit_has_dot[com_num]) {

    seg_data &= 0x7F;

  } else {

    seg_data |= 0x80;

  }

 

  uint8_t bit_num = TUBE_NUM[com_num];

 

  Send_Bytes(0);

  Send_Bytes(bit_num);

  Send_Bytes(seg_data);

  digitalWrite(LATCH_595, LOW);

  digitalWrite(LATCH_595, HIGH);

}

 

void TubeDisplay4Digit()

{

  for (uint8_t com_num = 0; com_num < 4; com_num++)

  {

    Send_74HC595(com_num);

    delay(2);

  }

}

 

uint8_t getCharSegments(char c)

{

  if (c >= '0' && c <= '9') return TUBE_SEG[c - '0'];

  return 0x00;

}

 

void scrollIP()

{

  if (millis() - lastScroll >= scrollDelay)

  {

    lastScroll = millis();

 

    for (int i = 0; i < 4; i++)

    {

      digit_has_dot[i] = false;

      int pos = scrollIndex + i;

 

      if (pos >= ip_str.length()) {

        display_digits[i] = 0x00;

      } else {

        char c = ip_str.charAt(pos);

        if (c == '.') {

          if (i > 0) digit_has_dot[i - 1] = true;

          display_digits[i] = 0x00;

        } else {

          display_digits[i] = getCharSegments(c);

        }

      }

    }

 

    scrollIndex++;

    if (scrollIndex > ip_str.length() + 4) {

      scrollIndex = 0;

    }

  }

}

 

void setup()

{

  Serial.begin(115200);

 

  pinMode(CLOCK_595, OUTPUT);

  pinMode(LATCH_595, OUTPUT);

  pinMode(DATA_595, OUTPUT);

  pinMode(OE_595, OUTPUT);

  digitalWrite(OE_595, HIGH);

  Send_74HC595(0);

  digitalWrite(OE_595, LOW);

 

  // Pinos para piscar

  pinMode(PULSE_PIN, OUTPUT);

  pinMode(DIR_PIN, OUTPUT);

 

  // Conecta ao Wi-Fi

  Serial.println("Conectando ao Wi-Fi...");

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)

  {

    delay(500);

    Serial.print(".");

  }

  Serial.println("\nConectado!");

  Serial.print("Endereço IP: ");

  Serial.println(WiFi.localIP());

 

  IPAddress ip = WiFi.localIP();

  ip_str = String(ip[0]) + "." + String(ip[1]) + "." + String(ip[2]) + "." + String(ip[3]);

  Serial.print("IP para display: ");

  Serial.println(ip_str);

}

 

void loop()

{

  scrollIP();

  TubeDisplay4Digit();

 

  // Piscar os pinos 33 e 25 a cada 500ms

  if (millis() - lastBlink >= blinkInterval)

  {

    lastBlink = millis();

    pinsOn = !pinsOn;

    digitalWrite(PULSE_PIN, pinsOn ? HIGH : LOW);

    digitalWrite(DIR_PIN, pinsOn ? HIGH : LOW);

  }

}

Answer :

We don't know if this code is correct. We suggest testing each function one by one and then gradually adding functions to find out where the error occurs.

Back to blog

Leave a comment