making an psx arcade need help !!

hi all
i am make an arcade . i need help in make a timer to countdown when coin is increted. one coin should add 3 min to the lcd. if another coin is added 3 more min will be added. and if the time runs out a relay will be triggered.

help plz

When the first coin is inserted set a timer to 180,000 milis and save startmillis.
Each time through loop, take startmillis from current millis, subtract from timer. If timer is zero then time is up.

If another coin dropped during active time, add 180,000 millis to timer. And save new startmillis
Each time through loop do as above.

Weedpharma

can help with code or plz forward me any.

hi i got code can someone help me modify this and make it simple.

this has so many extra feature which i dont need for my project.

i just need simple system like when the arduino is on the 16x2 LCD shows insert coin and ones coin is inserted the countdown starts from 3min and if another coin is added 3 more min will be added to current tine remaining. and when the time runs out the relay is turned off.

this is all i need.

The guy how made this code has many features which i dont want.
this is were i got the code from https://adambyers.com/2013/09/coin-operated-xbox/

sketch_jan09a.ino (15.4 KB)

When you have done the basic removal of unwanted features show us the code for any further suggestions on improving it.

So far you have not done any of the work, just found someone else's code.

Weedpharma

hi every one

i got this normal timer from french website but its almost want i need. can u help me in a small thing.

when it shows "Time is up" then after a few seconds i want it to go back to start showing the welcome msg. (like a loop).

i try resetting the arduino with digital pin connected to the reset pin and calling from the code but it didnt work.

where i added line u wil see //<<<<<<<<<<<<<< i added this

thanks any help appreciated

/*
arduino CondownTimer
====================

by Markus Klingler

5min-70min
set time in steps of 5 minutes with a button

====================
*/

//liberys
#include <LiquidCrystal.h>


LiquidCrystal lcd(2, 3, 4, 5, 11, 12);

//pins
const byte button = 10;                            //the button                  (conectet to ground)
const byte buzzer = 8;                             //a piezo buzzer              (conectet to ground)
const byte bgr = 9;                                //backgroundlight from lcd    (conectet to ground)
const byte outp = 7;                               //an output pin, it drivs up when time's up


const byte testled = 13;        //<<<<<<<<<<<<<< i added this



byte readbutton =1;

//values                                          -why it dos'nt work with unsigned long?
double time =0;                                   //the absolutly time in microseconds
double timeb =0;                                  //the restly time till the end - it displayt on lcd in minutes and seconds      
double secondsa=0;                                //values to convert "timeb" to display it on lcd in seconds and minutes
int secondsb=0;
double secondsc=0;
int minutes=0;
double timebgr=0;                                 //for backlight timeout
double mic=0;


void setup(){
  
 //set inputs and outputs
  pinMode(button, INPUT);
  digitalWrite(button,1);
  pinMode(buzzer, OUTPUT); 
  pinMode(bgr, OUTPUT);
  digitalWrite(bgr, HIGH);
  pinMode(outp, OUTPUT);
  pinMode(outp,LOW);

  
 //init lcd
  lcd.begin(16, 2);
  lcd.clear();
  
 //display welcome message
  lcd.print(" ready to play");
  lcd.setCursor(0,1);
  lcd.print("   by MakerMan ");
  delay(2000);

  //clear lcd
  lcd.clear();
  lcd.print("  incert  coin");
}


//  main Loop
void loop(){
  

  
  //convert timeb value
  secondsa=timeb/1000000;
  minutes=secondsa/60;
  secondsc=minutes*60;
  secondsb=secondsa-secondsc;
  
  //and print it to lcd
  lcd.setCursor(0,1);
  lcd.print("  ");
  lcd.setCursor(0,1);
  
  if(minutes<10){
  lcd.print("00");
  lcd.setCursor(1,1);
  }
    
  lcd.print(minutes);
  lcd.setCursor(2,1);
  lcd.print(":");
  lcd.setCursor(3,1);
  lcd.print("  ");
  lcd.setCursor(3,1);
  
  if(secondsb<10){
  lcd.print("00");
  lcd.setCursor(4,1);
  }
  
  lcd.print(secondsb);
  delay(50);

  //--------------------------------countdown
  if(time!=0){ //count only time isn't 0 (button dos'nt pressd)
    lcd.setCursor(0,0);
    lcd.print("time left");
    timeb=time-micros();
    mic=micros();
     if(timebgr<mic){                            //Backlight timeout - check if button 2 seconds dosn't pressd                     
      //  analogWrite(bgr, 80);                  //and dimm the backlight of lcd
     
    
    digitalWrite(testled,HIGH);        //<<<<<<<<<<<<<< i added this
   

} 
    //time's up (end loop)   
      while(timeb<=0){       
      digitalWrite(outp,HIGH);
      lcd.setCursor(0,0);
      lcd.print("Time is up      ");
      tone(buzzer, 1100);
      delay(500);
      noTone(buzzer);
      // digitalWrite(bgr,LOW);
    //   delay(500);
     //  digitalWrite(bgr,HIGH);
     
     digitalWrite(testled,LOW);         //<<<<<<<<<<<<<< i added this
     
      
       
     
      }  
  }


//--------------------------------button and timeseting

  //read button
  readbutton= digitalRead(button);
  //button presed
   if(readbutton==LOW){
    delay(50);
    digitalWrite(bgr,HIGH);
    
     if(time==0){  //do this if time = 0 (while starting, if button pressed fist)
      time=time+micros();
      timeset();  //call sub: timeset
     }
     
     //set the time
 mic=micros();
 if(timebgr>mic){    //set time if backlight 100% - else no
   timeset();
 }
      
    timebgr=micros()+2000000;  //for backlight timeout
    readbutton=digitalRead(button);
    while(readbutton==LOW){
    readbutton=digitalRead(button);
    delay(50);
   } 
  }
  
}




//======================================sub: timeset 
//                                      to set time while button pressed
void timeset(){

 //      tone(buzzer, 1100, 50);
       if(time<42000000){  //add 5 minutes if time smaler then 70 minutes (the overflowpoint of micros();)
         time=time+5000000;   //time + 5 minutes
       }else{                //or no if biger then 70 minutes
         lcd.setCursor(0,0);
         lcd.print("Max Time reached");
         delay(750);
       }
     

}