if (home_screen == true){
if (Seconds % 4 == 0){
Print_Temp()
I am unsure what % is in the programming language. This bit of code solved a problem I was having, but I would like to understand why it did.
if (home_screen == true){
if (Seconds % 4 == 0){
Print_Temp()
I am unsure what % is in the programming language. This bit of code solved a problem I was having, but I would like to understand why it did.
Modulo "truncates" and wraps a value. You can think of it as the remainder after a division.
x % 4 means "divide by 4 and give me the remainder", so if x is 7, then 7 % 4 is (7/4 = 1.75) = 1 with 3 left over. So the result is 3.
Again, in sequence:
0 % 4 = 0
1 % 4 = 1
2 % 4 = 2
3 % 4 = 3
4 % 4 = 0
5 % 4 = 1
6 % 4 = 2
7 % 4 = 3
8 % 4 = 0
... etc ...
Basically you are calling your method every 4 seconds