Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Arduino Counting

/*
	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 :: how to make an enum in c++ 
Cpp :: passare un array a una funzione 
Cpp :: open a url with dev c 
Cpp :: pointer to constant 
Cpp :: print all even number using for loop c++ 
Cpp :: what is ++i and i++ 
Cpp :: cout<<"helloworld"<<endl problem 
Cpp :: c++ how to skip the last element of vector 
C :: c colour text 
C :: C bitwise integer absolute value 
C :: how to get time and date in c 
C :: dynamic 2d arr in c 
C :: sstf program in c 
C :: grepper vscode 
C :: how to prevent user from entering char when needing int in c 
C :: Creating a process in C 
C :: c get random float 
C :: factorial in c using recursion 
C :: 0/1 knapsack problem in c 
C :: c float to string 
C :: how to login to another user in powershell 
C :: string input c 
C :: strong number in c 
C :: gcc option to show rules of makefile 
C :: count distinct characters in a string C 
C :: number of hours, minutes, and seconds given the number of seconds. 
C :: 2 dimensional array in c 
C :: unable to locate package dos2unix 
C :: how to get file size in c 
C :: recursive in c 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =