Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. int ledPin = 5;
  2. void setup() {
  3. // nothing happens in setup
  4. }
  5. void loop() {
  6. // fade in from min to max in increments of 5 points:
  7. for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
  8. // sets the value (range from 0 to 255):
  9. analogWrite(ledPin, fadeValue);
  10. // wait for 30 milliseconds to see the dimming effect
  11. delay(30);
  12. }
  13. // fade out from max to min in increments of 5 points:
  14. for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
  15. // sets the value (range from 0 to 255):
  16. analogWrite(ledPin, fadeValue);
  17. // wait for 30 milliseconds to see the dimming effect
  18. delay(30);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement