Pesquisar neste blog

14/01/2020

Programa 16

Delay e millis no Arduíno



#define pinLedVd 10
#define pinLedVm 8
#define pinBotao 2

boolean estadoBotao = true;
boolean estAntBotao = true;
boolean estadoPisca = false;

unsigned long delay1 = 0;

void setup() {
  pinMode(pinLedVd, OUTPUT);
  pinMode(pinLedVm, OUTPUT);
  pinMode(pinBotao, INPUT_PULLUP);

  digitalWrite( pinLedVd, HIGH);
}

void loop() {

  estadoBotao = digitalRead(pinBotao);
  if (!estadoBotao && estAntBotao) {
     estadoPisca = !estadoPisca;
  }
  estAntBotao = estadoBotao;

  if (estadoPisca) {

    if ((millis() - delay1) >= 500) {
       digitalWrite( pinLedVm, HIGH);
    }

    if ((millis() - delay1) < 500) {
       digitalWrite( pinLedVm, LOW);
    }
   
    if ((millis() - delay1) >= 1000) {
      delay1 = millis();
    }
  } else {
    digitalWrite( pinLedVm, LOW);
  }

  delay(10);
}

Programa 15 -

Impressão e contador no Arduíno usando display LCD

Simulação feita no Tinkercad





















#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
     // set up the LCD's number of columns and rows:
     lcd.begin(16, 2);
     // Print a message to the LCD.
     lcd.print("DEUS E MAIOR ");
}

void loop() {
     // set the cursor to column 0, line 1
     // (note: line 1 is the second row, since counting begins with 0):
     lcd.setCursor(0, 1);
     // print the number of seconds since reset:
     lcd.print(millis() / 500);
}


Palavras chave:

Printing and counter in Arduino using LCD display
Impresión y contador en Arduino usando pantalla LCD
Priontáil agus cuntar in Arduino ag baint úsáide as taispeáint LCD
Druk en toonbank in Arduino met LCD-skerm
Drukowanie i liczenie w Arduino za pomocą wyświetlacza LCD
Друк та лічильник в Ардуїно за допомогою РК-дисплея
Skriva ut och räknar i Arduino med LCD-skärm
הדפסה ודלפק בארדואינו באמצעות צג LCD
Nyithak lan kontra ing Arduino nggunakake tampilan LCD
Ispis i šalter u Arduinu pomoću LCD zaslona
Печат и брояч в Arduino с помощта на LCD дисплей