ton prg pour qu'il compile, mais pas testé
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
int compteur;
int ok ;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
}
void loop()
{
if (buttonPin == LOW)
{
ok = 1;
} else
{
ok = 0;
}
if (ok == 1 && compteur != 255)
{
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 10)
{
analogWrite(ledPin, fadeValue);
delay(30);
compteur = 255;
}
if (ok == 1 && compteur == 255)
{
analogWrite(ledPin, compteur);
}
if (ok == 0 && compteur != 0)
{
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 10)
analogWrite(ledPin, fadeValue);
delay (30);
compteur = 0;
}
if (ok == 0 && compteur == 0)
{
analogWrite(ledPin, compteur);
}
}
}