Last active
December 22, 2018 23:14
-
-
Save crossdjinn/d0821cc3e9c9edd26cc58c245eb00b9a to your computer and use it in GitHub Desktop.
C++, Arduino, LED pulse effect everytime different one
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
int ledPin = 11; | |
float sinVal; | |
int ledVal; | |
void setup(){ | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop(){ | |
for(int x=0; x<180; x++) { | |
if(x == 90){ | |
digitalWrite(LED_BUILTIN, LOW); | |
delay(random(30000)); | |
digitalWrite(LED_BUILTIN, HIGH); | |
} else if(x == 179){ | |
digitalWrite(LED_BUILTIN, LOW); | |
analogWrite(ledPin, LOW); | |
delay(random(60000)); | |
digitalWrite(LED_BUILTIN, HIGH); | |
} else { | |
sinVal = (sin(x*(3.14159265359/180))); | |
ledVal = int(sinVal*255); | |
analogWrite(ledPin, ledVal); | |
delay(55.333); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment