Arduino z joystickiem i LED

Rozjaśnianie i ściemnianie diody LED za pomocą joysticka

#define YJOY_PIN A2  
int intensity = 0;
int ledPin = 3;
void setup()
{
  Serial.begin(9600);
}
 
void loop()
{                   
  int joyY = analogRead(YJOY_PIN) ; 
  if(joyY > 600 && intensity < 255){
    intensity += 1;
    delay(10);
  }else if(joyY < 400 && intensity > 0){
    intensity -= 1;
    delay(10);    
  }else{
    delay(10); 
  }
  analogWrite(ledPin, intensity);
}
Scroll to Top