Created
April 27, 2019 09:22
-
-
Save geenloop/4dc8784282c850f6c5e89a576ab10818 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