Advertisement
Guest User

Untitled

a guest
Jul 20th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. //defining ledpin. Setting a value for aduino to use as the pin number.
  2. int ledpin = 7;
  3.  
  4. //defining minimum brightness value for arduin to use
  5. int minbrightness = 0;
  6.  
  7. //defining LED brightness value for arduino to use
  8. int brightness = 1;
  9.  
  10. //defining max brightness,
  11. int maxbrightness = 250;
  12.  
  13. //inc/dec value
  14. int inc = 5;
  15.  
  16.  
  17. void setup()
  18. {
  19.  
  20.  
  21. pinMode(ledpin, OUTPUT);
  22. }
  23.  
  24. void transition()
  25. {
  26. if (brightness >= maxbrightness);
  27. brightness += inc;
  28. else if (brightness <= minbrightness);
  29. brightness -=inc;
  30.  
  31. }
  32.  
  33. void ledcolor()
  34. {
  35. analogWrite(ledpin, brightness);
  36. }
  37.  
  38. void loop()
  39. {
  40. transition();
  41. ledcolor();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement