Thanks Simon ...looks like i have cracked it Thanks to you …. this is what i am working on ........ Self Service Bar …… this is how it works …… you come into the pub pay for 8 pints + deposit (for box) you are given a small box with 8 led’s on it and a button when you press the button at first all led’s will light up indicating you have 8 full pints left you plug “your box” into a bar with a lager pump on and pull your first pint then unplug the box and keep it with them if you press the button again one of the lights will have gone out second pint two lights out and so on when you have pulled 8 pints the box not allow any more lager to be pulled until it is reset ……………..in the box is the arduino and a rechargeable 9v battery …… this is the code that works it ………….....THE PROBLEM now how do I reset the program without opening the box and pressing the button is there any way a can digital input to one of the pins .if so can any one tell me the code to do this thanks ………….this is my code
int outputPin = 13;//names pins
int inputPin =10;
int fullPin =8;
int aPin = 1;
int bPin = 2;
int cPin = 3;
int dPin = 4;
int ePin = 5;
int fPin = 6;
int gPin = 7;
int maxCount =1600;//number of pulse's befor end
void setup()
{
digitalWrite (aPin, HIGH);//turns all led's on
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (dPin, HIGH);
digitalWrite (ePin, HIGH);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, HIGH);
digitalWrite (fullPin, HIGH);
pinMode(aPin,OUTPUT);//sets state of pin's
pinMode(bPin,OUTPUT);
pinMode(cPin,OUTPUT);
pinMode(dPin,OUTPUT);
pinMode(ePin,OUTPUT);
pinMode(fPin,OUTPUT);
pinMode(fullPin,OUTPUT);
pinMode(gPin,OUTPUT);
pinMode(outputPin,OUTPUT);
pinMode(inputPin, INPUT);//make's pin 10 input pin
}
void loop()
{
static int lastState = 0;
static int count = 0;
int newState = digitalRead(inputPin);
if (count >1)
{
digitalWrite (fullPin, LOW);//turns first light of when pulse input
}
if (count >200)
{
digitalWrite (aPin, LOW);//turns next light off
}
if (count >400)
{
digitalWrite (bPin, LOW);
}
if (count >600)
{
digitalWrite (cPin, LOW);
}
if (count >800)
{
digitalWrite (dPin, LOW);
}
if (count >1000)
{
digitalWrite (ePin, LOW);
}
if (count >1200)
{
digitalWrite (fPin, LOW);
}
if (count >1400)
{
digitalWrite (gPin, LOW);
}
if (newState != lastState)
{
count ++;//adds one to count
lastState = newState;
if (count > maxCount * 2)//when count gets to the set number sends 5v to pin 13
{
digitalWrite(outputPin, HIGH);
}
}
}