Advertisement
computermuseo

effetto dissolvenza [fade] con arduino

Mar 10th, 2015
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. int led = 9;
  2. int brightness = 0;
  3. int fadeAmount = 5;
  4.  
  5. void setup() {
  6.  
  7. pinMode(led, OUTPUT);
  8. }
  9.  
  10.  
  11. void loop() {
  12.  
  13. analogWrite(led, brightness);
  14.  
  15. brightness = brightness + fadeAmount;
  16.  
  17. if (brightness == 0 || brightness == 255) {
  18. fadeAmount = -fadeAmount ;
  19. }
  20. delay(30);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement