Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Arduino Counting without Millis

/*
	A simple program designed to count in seconds without using the Millis function
	
    The program displays this timer on an I2C LCD screen
    
    Last modified - 01/06/2022
    by Plasma
	*/
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4); // 20 x 4 I2C LCD screen

LiquidCrystal_I2C lcd(0x27, 16, 2); // 16 x 2 I2C LCD screen

signed short hours, minutes, seconds;
char Total_Time[16];

void setup() {

  lcd.init();
  lcd.backlight();
  lcd.clear();
}

void loop() {
  lcd.setCursor(0,0);
  sprintf(Total_Time, "%0.2d:%0.2d:%0.2d", hours, minutes, seconds);
  lcd.print(Total_Time);

  lcd.setCursor(0,2);
  lcd.print("Your Name");
  
  delay(1000);
  seconds++;
  
  if (seconds == 60) {	// When seconds = 60
    seconds = 0; 	    // Seconds become 0
    minutes ++;			// Adds 1 minute
  }
  if (minutes == 60) {	// When minutes = 60
    minutes = 0;		// Minutes become 0
    hours ++;			// Adds 1 hour
  }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ return statement 
Cpp :: x += c++ 
Cpp :: c++ filesystem remove file 
Cpp :: run with cpp version 
Cpp :: hello world program in c ++ using standard namespace 
Cpp :: c++ delete int 
Cpp :: sinonimo de tratar 
Cpp :: make an x using asterisk c++ 
C :: color text in C 
C :: how to use gotoxy in c language 
C :: myFgets in c 
C :: printf format specifiers 
C :: c get file size 
C :: c program to find area of circle 
C :: come creare variabili casuali in c 
C :: how to get user input in c 
C :: sigaction in c 
C :: two bytes to int c 
C :: nested loop in c 
C :: va_list in c 
C :: Futter Square Button 
C :: c program to find minimum of 4 numbers using conditional operator in c 
C :: matrix multiplication in c 
C :: c print to stderr 
C :: C Programming to swap two variables 
C :: warning: function returns address of local variable [-Wreturn-local-addr] 
C :: c round float 
C :: c check if character is an alphabet 
C :: how compress string in c 
C :: function component with props 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =