Old Arduino board working slowly

I used this Arduino Uno for a almost three years to control lights. Everything worked perfectly. Last week I wanted to revise my program and I realized that Arduino wasn't recognized by my PC ( Windows XP OS) I tried it on another PC ( Windows 7)>> same happened. SoI downloaded new package, installed on Windows 7 and everything seemed to be back in business again.

First I tested with my original sketch. I push the switch and correct light is on. But when I switch it off, it takes 4 seconds to turn OFF the light.

I testet another sketch with one servo and one button. I push the button and Servo goes immediately. I should be able to push the button again to command servo back to its initial position but it works only if I first wait for a 4 seconds.

I uploaded my sketches to Arduino UNO which I bought this year and everyhting works fine. So, it can't be programing issue.

Text on the board says: BOARD MODEL UNO OPEN SOURCE ELECTRONICS PROTOTYPING PLATFORM DESIGN IN ITALY WWW.ARDUINO.CC

Still, it could be a Chinese copy

Sikter:
Text on the board says:
DESIGN IN ITALY

Still, it could be a Chinese copy

Definitely a Chinese copy. A real Arduino UNO would say “MADE IN ITALY”.

There are some expressions you can write that have ‘undefined’ behavior. Some of those produce different behavior in 1.6.x than in 1.0.x. Show us your sketch and maybe we will find one of those. The main one is value = value++; which incremented ‘value’ in 1.0.x and does nothing in 1.6.x.

Thanks
It could be the reason in my servo sketch which is:

#include <Servo.h>

Servo servoVolume; 

const int  buttonPin2 = 2; 
int buttonState2 = 0;         
int lastButtonState2 = 0;    
int buttonPushCounter2 = 0;   
boolean currentButton2 = LOW;
const int ledPin7 =  7;
const int ledPin6 =  6;  
const int ledPin13 =  13;

void setup() {

  pinMode(ledPin13, OUTPUT);      
  pinMode(ledPin7, OUTPUT);    
  pinMode(ledPin6, OUTPUT);    

  servoVolume.attach(9);  
  delay(15); 

  pinMode(buttonPin2, INPUT); 

}

boolean debounce2(boolean last2)

{
  boolean current2 = digitalRead(buttonPin2);
  if (last2 != current2)
  {
    delay(1);
    current2 = digitalRead(buttonPin2);

  }
  return current2;   

}

void loop(){

  buttonState2 = debounce2(buttonPin2); 



  if (buttonState2 != lastButtonState2) {

    if (buttonState2 == HIGH) {


      buttonPushCounter2++;

    } 
    else {
    }


    lastButtonState2 = buttonState2;

  }


  if (buttonPushCounter2 % 2 == 0) {

    digitalWrite(ledPin7, HIGH); 
    digitalWrite(ledPin13, LOW); 


    VolumeUp();

    delay(15); 

  } 
  else {

    digitalWrite(ledPin7, LOW); 
    digitalWrite(ledPin13, HIGH); 
    VolumeDown();
    delay(15); 


  } 

}

void VolumeUp() 
{
  servoVolume.write(120);
}

void VolumeDown() {
  servoVolume.write(0);

}

What about the other sketch?

void setup()
{ 
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  pinMode(6,OUTPUT);
  pinMode(8,OUTPUT); 
  pinMode(10,OUTPUT); 
  pinMode(11,OUTPUT); 
  
  }

void loop()
{
  int sensorVal3 = digitalRead(3); 
  int sensorVal4 = digitalRead(4); 
  int sensorVal5 = digitalRead(5); 
  
  if (sensorVal4 == HIGH) 
  {
    digitalWrite(8, LOW);
    digitalWrite(11, HIGH);
    
    
  } 
 if (sensorVal4 == LOW) 
  {
    digitalWrite(8, HIGH);
    digitalWrite(11, LOW);
   
  }
  
  
  if (sensorVal3 == HIGH) 
  {
    digitalWrite(6, HIGH); 
     } 
   {if (sensorVal3 == LOW) 
    digitalWrite(6, LOW); 
 }
 
 {
   if (sensorVal5 == HIGH) 
   {
      digitalWrite(10, HIGH); 
        }
  {if (sensorVal5 == LOW) 
    digitalWrite(10, LOW); 
      } 
        } 
          }

I’m now on my other PC (Windows XP) and can’t test anything because something is missing on it and won’t install my old boards.

It’s about USB. I’m getting this message:
A service installation section in this INF is invalid.

But my newer Arduino Uno and Mega aork fine.

This seems to be wrong:

boolean debounce2(boolean last2) {
  boolean current2 = digitalRead(buttonPin2);
  if (last2 != current2) {
    delay(1);
    current2 = digitalRead(buttonPin2);
  }
  return current2;
}

void loop() {
  buttonState2 = debounce2(buttonPin2);

You are passing a pin number (2) to debounce2() and then comparing it to current2 which is always going to be either 0 or 1. The only result is that it's going to read the button pin twice. There is no 'debounce' happening. It appears that you should be passing lastButtonState2 since the function already knows the pin number.

You should probably put this part INSIDE the "if (buttonState2 == HIGH)" so it only gets done when the counter changes, not every time through loop().

  if (buttonPushCounter2 % 2 == 0) {
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin13, LOW);
    VolumeUp();
    delay(15);
  } else {
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin13, HIGH);
    VolumeDown();
    delay(15);
  }

Sikter: I'm now on my other PC (Windows XP) and can't test anything because something is missing on it and won't install my old boards.

It's about USB. I'm getting this message: A service installation section in this INF is invalid.

But my newer Arduino Uno and Mega aork fine.

Boards that don't have the Atmega16u2 need a driver for the chip they do have (probably FTDI)

johnwasser: This seems to be wrong:

boolean debounce2(boolean last2) {
  boolean current2 = digitalRead(buttonPin2);
  if (last2 != current2) {
    delay(1);
    current2 = digitalRead(buttonPin2);
  }
  return current2;
}

void loop() {   buttonState2 = debounce2(buttonPin2);




You are passing a pin number (2) to debounce2() and then comparing it to current2 which is always going to be either 0 or 1. The only result is that it's going to read the button pin twice. There is no 'debounce' happening. It appears that you should be passing lastButtonState2 since the function already knows the pin number.

You should probably put this part INSIDE the "if (buttonState2 == HIGH)" so it only gets done when the counter changes, not every time through loop().


  if (buttonPushCounter2 % 2 == 0) {     digitalWrite(ledPin7, HIGH);     digitalWrite(ledPin13, LOW);     VolumeUp();     delay(15);   } else {     digitalWrite(ledPin7, LOW);     digitalWrite(ledPin13, HIGH);     VolumeDown();     delay(15);   } ```

I see, so even servo worked, program didn't bounce. It probably "misfired" sometimes, but I didn't realized. I'll revise my sketch.

Thank you.

DrAzzy: Boards that don't have the Atmega16u2 need a driver for the chip they do have (probably FTDI)

That's the main problem, and second one would be me not being able to find and install it.

I think I downloaded and tried everything available on the internet. :-)

This PC is counting its last days anyway. It's not worth spending any more time to get it work.

Thank you.