ESP32 Starter Kit
7. Code Explanation
analogRead(pot); Read the analog value. Put the input pin of analog value in brackets.
map(value, fromLow, fromHigh, toLow, toHigh) map(value,0,4095,0,255); Convert the range of value from 0-4095
to 0-255. Because the range of value does not conform to that of PWM, a conversion is necessary.
8.5.21 Project 20: Light Pillar
1. Description
The resistance(less than 1K) of the photoresistor varies from the light, thus it can control the brightness of the dot
matrix. When controlling, we connect this resistor to an analog pin on the board to monitor the change of resistance.
In this way, the light automatically controls the brightness of the display.
Besides, the photoresistor is widely applied to our daily life. For instance, a curtain automatically opens or closes
according to the outer light intensity.
2. Working Principle
When it is totally in dark, the resistance equals 0.2M, and the voltage at signal terminal (point 2) approaches to 0V. The
stronger the light is , the smaller the resistance and voltage will be.
8.5. Arduino Project 117