|
arduino IDEArduino
|
ColorSenzor
Color senzor work with refleted color captured by LRD.
Pin Definitions:
sensorPin: Pin for the light sensor (A0).
LedRed, LedBlue, LedGreen: Digital pins for red, blue, and green LEDs (3, 4, 5).
read_value, value_red, value_blue, value_green: Variables for storing values reflected by different color LEDs.
k: Tolerance threshold.
Setup Function:
Sets all three LED pins as outputs (OUTPUT).
Turns off (sets to LOW) all LEDs.
Sets up serial communication at a baud rate of 9600.
Brief delay.
Loop Function:
Turns on (sets to HIGH) the red LED for 150 ms.
Reads the value from the light sensor.
Prints the values to the serial monitor and turns off (sets to LOW) the red LED.
Repeats the same steps for the green and blue LEDs.
Waits for 2 seconds before the next reading.
The purpose of this code is to compare the reflected values of red, green, and blue LEDs. The program detects differences in the sensor values within the tolerance range and displays them on the serial monitor. In practice, this code could be used, for example, in controlling a color sensor or an RGB LED, where the reflected values are observed when different colored lights are applied.
<a ref="https://www.youtube.com/watch?v=9gBgA_nF0z4">Youtube</a>
ColorSenzor
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Istvan Sentes
-
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
127 0 0 -
DIY Laser Power Meter with Arduino
189 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
170 0 2 -