Countdown Timer

Hi guys,just bought an Arduino Uno for a school project.
To cut it short, I have several inputs with push buttons.

  1. Once one button is pressed, I have 15 seconds to press the next button to display a fare else the system resets. I have tried using some IF count loops, but it does not really count down 15secs, it just loops the code 15times..

  2. Im using 'if (digitalRead(SwitchPin1) == HIGH && digitalRead(SwitchPin2) == HIGH);'
    This line requires both buttons to be pressed simultaneously instead of one after the other..should I use Serial Analog read?

I would be greatful if anyone could help me with this..I'm really going crazy!!

Post the code you have, otherwise it looks like you're just asking someone to write your assignment for you.

Im using 'if (digitalRead(SwitchPin1) == HIGH && digitalRead(SwitchPin2) == HIGH);

Bad idea - too many semicolons.

There is no such thing as serial analog read.

// Program to calculate Train Fair

#include <LiquidCrystal.h>

int SwitchPin1 = 6;
int SwitchPin2 = 7;
int SwitchPin3 = 8;
int SwitchPin4 = 9;
int SwitchPin5 = 13;

/*
Initialize the library with the numbers of the interface pins

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
    */

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

void setup()
{
pinMode(SwitchPin1, INPUT); //Initialising the Pins as Inputs
pinMode(SwitchPin2, INPUT);
pinMode(SwitchPin3, INPUT);
pinMode(SwitchPin4, INPUT);
pinMode(SwitchPin5, INPUT);

digitalWrite(SwitchPin1, LOW); // pulldown resistors are activated
digitalWrite(SwitchPin2, LOW);
digitalWrite(SwitchPin3, LOW);
digitalWrite(SwitchPin4, LOW);
digitalWrite(SwitchPin5, LOW);

myLCD.home();
myLCD.print("READY");
delay (3000); // waits for 3 seconds
myLCD.clear(); // clear LCD

}

void loop()
{
for (int i=0; i <= 15; i++){

if (digitalRead(SwitchPin1) !=LOW)
myLCD.print("AAA");
delay(1500);

if (digitalRead(SwitchPin2) !=LOW)
myLCD.print("AAA");
delay(1500);

if (digitalRead(SwitchPin1) == HIGH && digitalRead(SwitchPin2) == HIGH);
myLCD.print("1.70");

}
}

There's no such thing as a built-in pull-down

Please use the # icon when posting code.

Printing the same thing for two different conditions is not the most sensible act.

// Program to calculate Train Fair

You pay a fare to ride a train...

  digitalWrite(SwitchPin1, LOW);  // pulldown resistors are activated

Back to the reference section for you.

If you need to press two switches within a given period of time, you'll need to record when each switch was pressed (millis()). When both switches have been pressed, compute the difference in times. If small enough, do something. Otherwise, do something else.

Looping, reading the same pair of switches 15 times is accomplishing nothing.