Advertisement
Guest User

Untitled

a guest
Jul 19th, 2012
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement