9 int one_second_ago
= 0;
14 pinMode(COIN_BUTTON
, INPUT
);
15 pullUpDnControl(COIN_BUTTON
, PUD_UP
);
20 return (unsigned)time(NULL
);
25 if(one_second_ago
!= now() && expires
!= -1)
27 printf("You have %d seconds remaining\n", expires
- now());
28 one_second_ago
= now();
33 printf("It's all ogre now\n");
43 if(digitalRead(COIN_BUTTON
) == LOW
)
45 printf("Nice! I just added %d to your time.\n", config
.credit_value
);
48 if(expires
== -1) //Initial credit, set the expiry to now plus time
50 expires
= now() + config
.credit_value
;
51 } else { //expiry already set, simply extend by time
52 expires
+= config
.credit_value
;
55 //wait for button to be released
56 while(digitalRead(COIN_BUTTON
) == LOW
)
58 //I don't see this happening, but in principle if the button is held down
59 //It would be possible to stop the switch happening after time runs out
60 //So we must check for that here.
78 printf ("Short pin 7 and 9 to increment timer.\n") ;
83 //I don't really need to call this here but I'm doing it to see output.