Introduction

Photoresistor Sensor Module are sensors that allow you to detect light. They are small, inexpensive, low-power, easy to use and don’t wear out. For that reason they often appear in toys, gadgets and appliances.

Features

How to use with Arduino?

Connection

Code Upload

Copy below code to your  IDE, choose the correct port and board for your Basic board, save and upload it to the Basic board.

 
int photocellPin = A0;
int val = 0;
void setup() {
  Serial.begin(9600); 
  pinMode(photocellPin,INPUT);
} 
void loop() {
  val=analogRead(photocellPin);
  Serial.println(val);
}  

Running Result

After compile this sketch, simply click the “Upload” button in the environment. Wait a few seconds – you should see the RX and TX leds on the board flashing. If the upload is successful, the message “Done uploading.” will appear in the status bar.

In the same time,change the brightness of the environment, open the Serial Monitor and you will get the output data as below :