Dota 2 Timer – Arduino Uno with LCD

This is a work of progress. This work is made in collobration with Antti Eloranta. We will update and explain the code later.

// include the library code:
#include <LiquidCrystal.h>
int led = 13;
int firstjungle = 0;
int junglecreepN = 1;
int firstTime = 1;

long day = 86400000; // 86400000 milliseconds in a day
long hour = 3600000; // 3600000 milliseconds in an hour
long minute = 60000; // 60000 milliseconds in a minute
long second = 1000; // 1000 milliseconds in a second
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
// set up the LCD’s number of columns and rows:
pinMode(led, OUTPUT);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.clear();
}

void firstJungle(){

firstjungle = 1;
lcd.clear();
lcd.print(junglecreepN);
lcd.print(“. Jungle Creeps”);
junglecreepN++;
for(int i = 0; i<6; i++){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
lcd.clear();
lcd.print(“Dota_Timer”);
lcd.setCursor(13, 0);
// print the number of seconds since reset:
lcd.print(millis()/1000);

}

void loop() {
lcd.print(“Dota_Timer”);
long timeNow = millis();
int minutes = ((timeNow % day) / minute) ;
int seconds = (((timeNow % day) % hour) % minute) / second;
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(11, 0);
// print the number of seconds since reset:
//lcd.print(millis()/1000);
if (minutes<10){
lcd.print(“0”);
lcd.print(minutes);
}
else {
lcd.print(minutes);
}
lcd.print(“:”);
if (seconds < 10){
lcd.print(“0”);
lcd.print(seconds);
}
else{
lcd.print(seconds);
}

if(seconds == 30 && firstjungle == 0){
firstJungle();
}

if(seconds > 1){
firstTime = 0;
}
if(seconds == 00 && firstTime == 0){
lcd.clear();
lcd.print(junglecreepN);
lcd.print(“. Jungle Creeps”);
junglecreepN++;
for(int i = 0; i<6; i++){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
lcd.clear();
lcd.print(“Dota_Timer”);
lcd.setCursor(13, 0);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
else{
}
}

Leave a comment