le but du programme est de régler la luminance de la led en appuyant plus ou moins longtemps sur le bouton :
<code lang=arduino>/*
set the value of the led by pushing the button more or less longtime
This example code is in the public domain.
led : 8
button : 7
*/
#define led 8
#define bton 7
int value;
void setup() {
value=0;
pinMode(led, OUTPUT);
pinMode(bton, INPUT_PULLUP);
}
void loop() {
if (digitalRead(bton)==LOW){
if (value!=0){
value=0;
}
else{
while(digitalRead(bton)==LOW){
if (value<255) {
value++;
analogWrite(led,value);
delay(40);
}
}
}
}
analogWrite(led,value);
delay(40);
}
</code>
==tentative sur smoothieboard==