Last active
August 30, 2018 03:17
-
-
Save likersacademia/ba8ab7335ef9e229d01ebf9f99a1e480 to your computer and use it in GitHub Desktop.
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
// pwmpin 3,5,6,9,10,11 | |
#define ledPin 3 | |
// 初期化 | |
void setup(){ | |
// LEDのピンを出力に | |
pinMode(ledPin, OUTPUT); | |
} | |
// メインループ | |
void loop() { | |
int i; | |
// iの値を0~255で変化させる | |
for (i=0; i<256; i++){ //256を減らすと明るさが落ちますが、人の目で変化が分かるのは100以下くらいからです。 | |
// iの値でLEDを点灯させる | |
analogWrite(ledPin, i); | |
delay(10); //ここを増やすと変化が遅くなります | |
} | |
// iの値を255~0で変化させる | |
for (i=255; i>-1; i--){ //255を減らすと明るさが落ちますが、人の目で変化が分かるのは100以下くらいからです。 | |
// iの値でLEDを点灯させる | |
analogWrite(ledPin, i); | |
delay(10); //ここを増やすと変化が遅くなります | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment