Example Code for Arduino-Light Intensity Detection
Last revision 2026/01/07
This article is a step-by-step guide to detecting light intensity using Arduino, complete with hardware and software preparation, wiring diagrams, and example code, aimed at beginners and enthusiasts looking to add light detection to their projects.
Sample Code
void setup()
{
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}
void loop()
{
int val;
val=analogRead(0); //connect sensor to Analog 0
Serial.println(val);//print the value to serial
delay(100);
}
Was this article helpful?
