5 #define CREDIT_EXTENSION 10
8 int one_second_ago
= 0;
13 pinMode(COIN_BUTTON
, INPUT
);
14 pullUpDnControl(COIN_BUTTON
, PUD_UP
);
19 return (unsigned)time(NULL
);
24 if(one_second_ago
!= now() && expires
!= -1)
26 printf("You have %d seconds remaining\n", expires
- now());
27 one_second_ago
= now();
32 printf("It's all ogre now\n");
42 if(digitalRead(COIN_BUTTON
) == LOW
)
44 printf("Nice! I just added %d to your time.\n", CREDIT_EXTENSION
);
47 if(expires
== -1) //Initial credit, set the expiry to now plus time
49 expires
= now() + CREDIT_EXTENSION
;
50 } else { //expiry already set, simply extend by time
51 expires
+= CREDIT_EXTENSION
;
54 //wait for button to be released
55 while(digitalRead(COIN_BUTTON
) == LOW
)
57 //I don't see this happening, but in principle if the button is held down
58 //It would be possible to stop the switch happening after time runs out
59 //So we must check for that here.
75 printf ("Short pin 7 and 9 to increment timer.\n") ;
80 //I don't really need to call this here but I'm doing it to see output.