Advertisement
AnindyaBiswas

BlinkMofo

Feb 27th, 2023
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int led = 11;
  2. int brightness = 0;
  3. int fade = 5;
  4.  
  5. void setup() {
  6.   // put your setup code here, to run once:
  7.   pinMode(led, OUTPUT);
  8.   Serial.begin(9600);
  9. }
  10.  
  11. void loop() {
  12.   // put your main code here, to run repeatedly:
  13.   analogWrite(led, brightness);
  14.  
  15.   if(brightness == 0)
  16.     delay(500);
  17.  
  18.   brightness = brightness + fade;
  19.  
  20.   if(brightness >= 255 || brightness <= 0)
  21.     fade = -fade;
  22.  
  23.   Serial.println(brightness);
  24.   delay(40);
  25.  
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement