Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 19th, 2012  |  syntax: None  |  size: 0.63 KB  |  views: 517  |  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. #define ledpin 8
  3.  
  4. //defining minimum brightness value for arduin to use
  5. #define minbrightness 0
  6.  
  7. //defining LED brightness value for arduino to use
  8. #define brightness 1
  9.  
  10. //defining max brightness,
  11. #define 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.     inc = -5;
  28.   else if (brightness <= minbrightness)
  29.     inc = 5
  30.    
  31. }
  32.  
  33. void ledcolor()
  34. {
  35. analogWrite(ledpin, brightness);  
  36. }
  37.  
  38. void loop()
  39. {
  40.   transition();
  41.   ledcolor();  
  42. }