1-1. The position of the Photo-resistor on the robot car
1-2. Learn about the Arduino board pins connected to the Photo-resistor of Omibox programmable robot
As shown in the above picture, we circled the Photo-resistor with a red wire frame.
According to the hardware quick manual, we can see that the Photo-resistor is connected to the A6 of the Arduino.
The part code for this experiment is as follows:
1.We need to open the code of this experiment: A_light.ino, click“√” under the menu bar to compile the code, and wait for the word "Done compiling " in the lower right corner, as shown in the figure below.
2. Click 【Tools】 --- 【Board】 -- we need to choose Arduino Uno. As shown in the figure below.
3.In the menu bar of Arduino IDE, we need to select 【Tools】---【Port】--- selecting the port that the serial number displayed by the device manager, as shown in the figure below.
4. After the selection is completed, you need to click “ → ”under the menu bar to upload the code to the Arduino UNO board. When the word “Done uploading” appears in the lower left corner, the code has been successfully uploaded to the Arduino UNO board, as shown in the figure below.
After the program is uploaded, turn on the power of the car. When there is light, No.0 RGB light is off , when there is no light, No.0 RGB light is on.
If the experiment effect is not good, you can print out the output value of the light sensor and modify the threshold in the program.
The code of the experiment: 9.Automatic lighting.rar