arduino breathing light

Hardware
Here Insert Picture Description
Source: Arduino-UNO-LED
software
only official Arduino IDE can provide.
When you are ready to the above, as long as the next circuit connected, knocking a few simple lines of code, you can let the lamp flashes up!
Connecting circuit
Here Insert Picture Description
code is as follows:

void setup ()
{
  pinMode(13,OUTPUT);
}
 
void loop()
{
  //循环语句,控制PWM亮度的增加
  for (int a=0; a<=255;a++)
  {
    analogWrite(11,a);
    delay(8);//当前亮度级别维持的时间,单位毫秒
  }
  //循环语句,控制PWM亮度减小 
  for (int a=255; a>=0;a--)
  {
    analogWrite(11,a);
    delay(10);//当前亮度的维持的时间,单位毫秒  
  }
  delay(800);//完成一个循环后等待的时间,单位毫秒
}

Here Insert Picture Description

Published 111 original articles · won praise 177 · views 210 000 +

Guess you like

Origin blog.csdn.net/qq_45172832/article/details/105156069