Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 0.64 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data