Last active
December 7, 2018 02:37
-
-
Save baobao/d6fbd47960c7472a52dae51cf95913bc 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
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(13, OUTPUT); | |
} | |
void loop() | |
{ | |
int val = analogRead(0); | |
// 取得した明るさの強さをログに吐く | |
Serial.println(val); | |
// 100*5/1023 = 約0.488V未満だったらLEDを点灯させる | |
if (val < 100) | |
{ | |
digitalWrite(13, HIGH); | |
} | |
else | |
{ | |
digitalWrite(13, LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment