Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active Dec 7, 2018
Embed
What would you like to do?
光センサー使用サンプル
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