Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //defining ledpin. Setting a value for aduino to use as the pin number.
- #define ledpin 8
- //defining minimum brightness value for arduin to use
- #define minbrightness 0
- //defining LED brightness value for arduino to use
- #define brightness 1
- //defining max brightness,
- #define maxbrightness 250
- //inc/dec value
- int inc = 5;
- void setup()
- {
- pinMode(ledpin, OUTPUT);
- }
- void transition()
- {
- if (brightness >= maxbrightness)
- inc = -5;
- else if (brightness <= minbrightness)
- inc = 5
- }
- void ledcolor()
- {
- analogWrite(ledpin, brightness);
- }
- void loop()
- {
- transition();
- ledcolor();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement