Fading LED using tinkercad (Arduino)

preview_player
Показать описание
Source Code:
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by Arduino
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255)
{
fadeAmount = -fadeAmount ;
}
delay(300);
}
.
Beginner tutorial.
Рекомендации по теме