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);
}
Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
Scroll to Top