fbpx

Coding of LDR sensor


 


Steps to do coding in Tinkercad

1. Click the code editor button to open the coding panel.










Now to code LDR sensor,

  1. First, we will make a variable named as “sensorvalue”.

  2. We are making this variable to store the data or signal coming from the LDR sensor i.e from AO pin of Arduino Uno.

  3. Now, Let us print the value coming from the LDR sensor in the serial monitor using print to serial monitor block.

  4. In the end,map the value coming from the LDR sensor to a range between 0 to 255 and in accordance to the range the LED will Glow.

The code is shown below: