so i had a go at trying to work this out but still no joy am i anyway right
const int coinMecPin = 2; //the number of the coin mec pin
const int relayPin = 7; //the number of the relay pin
int buttonState = LOW; // variable for reading the buttonstate
void setup() {
// put your setup code here, to run once:
pinMode(relayPin, OUTPUT);
pinMode (coinMecPin, INPUT);
}
void loop() {
buttonState = digitalRead(coinMecPin); // read the state of the pushbutton value:
// Get current "time"
unsigned long now = millis();
// Is it time to decrement the time remaining?
if(now - lastDecrement > oneSecond)
{
lastDecrement = now;
timeRemaining--;
}
// Did a coin get dumped in?
if(gotCoin());
timeRemaining += 1000UL * 10 * 60; // Add 10 minutes
if(timeRemaining == 0 && deviceIsOn)
turnDeviceOff();
if(timeRemaining > 0 && !deviceIsOn)
turnDeviceOn();
void gotCoin() {
if (buttonState == LOW);
digitalWrite (relayPin, HIGH);
}
}