Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How to return back to the initial screen when button is pressed?

I have three screens in the LCD connected to the 8051-microcontroller that scroll to the different screen when the button is pressed but I want to return back to the initial screen when again button is pressed. How can I do that, thank you?

#include <stdio.h>
#include <string.h>
#include <stdint.h>

void change_screen(void);    
int count = 0;

void change_screen(void)
  { 
    if (modebutton == 1) {      // when button is pressed       
        if (count == 0) {                       
        count++;
        delay(100);
        display_screen1();      
        modebutton=0;            
        }
    else if (count == 1) {          
        count++;            
        delay(100);
        display_screen2();      
        modebutton=0;
    }
    else if (count == 2) {          
        display_screen3(); 
        count = 0;       
        } 
     } 
   }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use the remainder operator % for this.

Example:

void change_screen(void) {
    static unsigned count = 0;

    if(modebutton) {
        delay(100);
        modebutton = 0;       

        switch(count) {
        case 0: display_screen1(); break; // first   fourth  ...
        case 1: display_screen2(); break; // second  fifth
        case 2: display_screen3(); break; // third   sixth
        }

        count = (count + 1) % 3;   // 0,1,2 then 0,1,2 etc...
    }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda