Last active
August 21, 2017 01:00
-
-
Save Benargee/29f98e1bdfebcc67aeec03bd756ca495 to your computer and use it in GitHub Desktop.
Controller for 24v LED lightbar driven by IRFZ44 MOSFET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Breathing Led bar | |
By: Benargee | |
*/ | |
int ledPin = 9; // LED connected to digital pin 9 | |
int count = 2; | |
int inerval = 1; //interval in miliseconds between loops | |
int order = 1; //indicates order of decreasing or increasing intensity. 1: increasing -1:decreasing | |
const int minVal = 1; | |
const int maxVal = 254; | |
void setup() | |
{ | |
pinMode(ledPin, OUTPUT); // sets the pin as output | |
} | |
void loop() | |
{ | |
switch (count) { | |
case minVal: | |
order = 1; | |
break; | |
case maxVal: | |
order = -1; | |
break; | |
} | |
count = count + order; | |
analogWrite(ledPin,count); | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment