Can't find the bug...


so, i’m writing this program to basically “debounce” two sets of 2 contact switches. this debounced is very based on the example provided.
I set the debounce time for 1 sec, just for testing, as it gets better, i wanna get it as low as i can. The program works just fine for a while, but then it suddendly starts showing new results every millisecond. In it’s core, i shouls only get a new message every second or so, so something is really messed up, the problem is, i can’t seem to find out what is wrong… Can anyone help me please? Thank you

below is the coding:

#include <Servo.h>

Servo myservo[2]; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

int a;
int b;

int doit=0;

byte Pin1[2]={4, 6};
byte Pin2[2]={5, 7};

int currentreading[2];
int lastreading[2];
int time[2] ={0, 0};
int val[2];

void setup()

myservo[0].attach(10); // attaches the servo on pin 9 to the servo object

pinMode(10, OUTPUT);
pinMode(11, OUTPUT);

for (byte i=0; i < 2; i++){
pinMode(Pin1*, INPUT);*
_ pinMode(Pin2*, INPUT);_
_ digitalWrite(Pin1, HIGH);
digitalWrite(Pin2, HIGH);}
//End for*

*} *_

void loop()
*{ *
* int rot;*

* for (int i=0; i < 2; i++){*
* UpdateRot(i);*
_ rot=val*;*_

_ if (rot==1) myservo*.write(84);
if (rot>2) myservo.write(0);
else myservo.write(180);}}
if (doit==1) {
for (int i=0; i < 2; i++){

Serial.print(" ");}_

_ Serial.println(" ");
* }
void UpdateRot(byte IClaw) {
if (currentreading[IClaw]!=lastreading[IClaw]) {

* if ((millis()-time[IClaw])>1000){*
* if (lastreading[IClaw]!=val[IClaw]){*
* val[IClaw]=lastreading[IClaw];*
* doit=1;*
* }}*

int GetAngle(byte IClaw) {
* // 11=1 10=2 00=3 01=4*
* a=digitalRead(Pin1[IClaw]);*
* b=digitalRead(Pin2[IClaw]);*

// Serial.print(a);
* //Serial.print(" - ");*
* // Serial.print(b);*
* //Serial.print(" : ");*

* if (a==1) return (2-b);*
* else return (b+3);*
* } //End GetAngle*

 pinMode(Pin1, INPUT);

A subscript is required for arrays

Weird as it may seem, in my coding, on the arduino program, the parenthesis with the i are there... somehow, when i copied, they didn't show up...

Any ideas?

 int time[2] ={0, 0};

And the type returned by millis is?

Thank you. That must have been the problem, i changed int to unsigned long, and it works now. Thanks very much