Combining the Real World with the Virtual World
Before we have seen how to read out the color sensor and and how to determine the distance between the colored paper and the ultra-sonic distance sensor. We also saw how to create a virtual world with VPython. All that is left now is combing both parts.
Here is a photo of the hardware setup
In front you see the HC-SR04 ultra-sonic distance sensor (the one with the two cylinders sticking out) and the color sensor (the one with the black guard ring and the 4 LEDs). Behind the distance sensor you see an rgb LED on the left and a level converter on the right, converting the 5V TTL output signals from the distance and the color sensors to 3.3 V needed by the Raspberry Pi.
Here are the connections:
The HC-SR04 distance sensor:
Vcc |
5V |
|
Trig |
gpio 23 |
|
Echo |
gpio 24 |
via the level converter |
Gnd |
Gnd |
|
The rgb LED
+ |
3.3V |
red |
gpio 17 |
green |
gpio 22 |
blue |
gpio 18 |
The TCS34200 color sensor
Gnd |
Gnd |
|
Out |
gpio 19 |
via the level converter |
S2 |
gpio 13 |
|
S4 |
gpio 26 |
|
Vcc |
5V |
|
Gnd |
nc |
|
LED |
gpio 21 |
|
S0 |
gpio 26 |
|
S1 |
gpio 12 |
|
Vcc |
nc |
|
--
Uli Raich - 2018-03-07
Comments