Skip to content

Instantly share code, notes, and snippets.

@Benargee
Last active August 21, 2017 01:00
Show Gist options
  • Save Benargee/29f98e1bdfebcc67aeec03bd756ca495 to your computer and use it in GitHub Desktop.
Save Benargee/29f98e1bdfebcc67aeec03bd756ca495 to your computer and use it in GitHub Desktop.
Controller for 24v LED lightbar driven by IRFZ44 MOSFET
/*
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