Interfacing Color Sensor (TCS3200) with Raspberry Pi 3 ๐จ
The TCS3200 color sensor can detect various colors using its array of photodiodes and filters. Let’s interface it with Raspberry Pi 3 and detect different object colors! ๐
๐ง Components Required
Component | Quantity |
---|---|
Raspberry Pi 3 | 1 |
TCS3200 Color Sensor | 1 |
Jumper Wires | 8 |
๐ Pin Connections
Sensor Pin | Raspberry Pi Pin | Pin Number |
---|---|---|
VCC | 3.3V | Pin 1 |
GND | Ground | Pin 6 |
S0 | GPIO 17 | Pin 11 |
S1 | GPIO 27 | Pin 13 |
S2 | GPIO 22 | Pin 15 |
S3 | GPIO 23 | Pin 16 |
OUT | GPIO 24 | Pin 18 |

Figure: TCS3200 Color Sensor connected to Raspberry Pi 3
๐ป Python Code
import RPi.GPIO as GPIO
import time
# Set up GPIO pins for S0-S3 and OUT
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.IN)
GPIO.output(17, True)
GPIO.output(27, False)
def read_frequency():
start = time.time()
for i in range(10):
while GPIO.input(24) == 0:
pass
while GPIO.input(24) == 1:
pass
duration = time.time() - start
return 10 / duration
try:
while True:
GPIO.output(22, False)
GPIO.output(23, False)
red = read_frequency()
GPIO.output(22, True)
GPIO.output(23, True)
green = read_frequency()
GPIO.output(22, False)
GPIO.output(23, True)
blue = read_frequency()
print(f"R: {red:.2f} G: {green:.2f} B: {blue:.2f}")
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
๐ Summary
The TCS3200 helps identify color shades in objects. Perfect for robotics, color sorting, or quality inspection projects! ๐ฏ๐จ
Raspberry Pi 3 เคธเคน Color Sensor (TCS3200) เคोเคกเคฃे ๐จ (เคฎเคฐाเค ी)
TCS3200 เคธेเคจ्เคธเคฐ เคตाเคชเคฐूเคจ เคเคชเคฃ เคตเคธ्เคคूंเค्เคฏा เคฐंเคांเคे เค เคूเค เคฎाเคชเคจ เคเคฐू เคถเคเคคो. เคเคฒा เคนे เคธेเคจ्เคธเคฐ Raspberry Pi 3 เคธोเคฌเคค เคเคธे เคตाเคชเคฐाเคฏเคे เคคे เคชाเคนूเคฏा!
๐ง เคฒाเคเคฃाเคฐे เคธाเคนिเคค्เคฏ
เคธाเคนिเคค्เคฏ | เคช्เคฐเคฎाเคฃ |
---|---|
Raspberry Pi 3 | 1 |
TCS3200 เคฐंเค เคธेเคจ्เคธเคฐ | 1 |
เคंเคชเคฐ เคตाเคฏเคฐ | 8 |
๐ เคตाเคฏเคฐिंเค เคोเคกเคฃी
เคธेเคจ्เคธเคฐ เคชिเคจ | Raspberry Pi เคชिเคจ | เคชिเคจ เค्เคฐเคฎांเค |
---|---|---|
VCC | 3.3V | เคชिเคจ 1 |
GND | GND | เคชिเคจ 6 |
S0 | GPIO 17 | เคชिเคจ 11 |
S1 | GPIO 27 | เคชिเคจ 13 |
S2 | GPIO 22 | เคชिเคจ 15 |
S3 | GPIO 23 | เคชिเคจ 16 |
OUT | GPIO 24 | เคชिเคจ 18 |
๐ป Python เคोเคก
# เคตเคฐीเคฒ เคंเค्เคฐเคी เคोเคก เคตाเคชเคฐा
๐ เคธाเคฐांเคถ
เคนा เคช्เคฐोเคेเค्เค เคฐंเค เคเคงाเคฐिเคค เคाเคจเคจी, เคฐोเคฌोเคिเค्เคธ เคिंเคตा เคธ्เคฎाเคฐ्เค เคกिเคต्เคนाเคเคธ เคกेเคต्เคนเคฒเคชเคฎेंเคเคธाเค ी เคเคชเคฏुเค्เคค เคเคนे! ๐๐️
Comments