Tags:
create new tag
view all tags

Reading the Color Sensor and creating the virtual world

Introduction

Reading the color sensor is rather tricky but we are lucky to find a ready made module that contains the access code.

Exercise Session 3

The TCS3200 Color sensor

1. Connecting the color sensor and switching the LEDs

Connect the color sensor according to the following table:

Read the code of the TCS3200 class and try to figure out

  • how to import its code

  • how to create an instance of the TCS3200 class

  • how to switch the LEDs on and off

2. Calibration and and color readout

Write a program to calibrate the sensor (find black and white color) and read the rgb color of a paper. Print the rgb value

3. Color sensor and rgb LED

Extend exercise 2 to display the paper color on the rgb LED

The virtual world

1. Creating a few 3D objects

Before creating 3D objects you must import the visual module:

from visual import *

Now you you can create 3D objects like

  • spheres

  • cylinders

  • boxes

Try this and play with parameters like position, size and colors. Try what happens if press the second or third mouse button and you move the mouse.

2. Create a scene with just a cylinder and a sphere

  • Create a scene with just a cylinder with default options.

  • Move the cylinder left and change its radius and length

  • Add a sphere with default options

  • Change the sphere size and color

3. Create a scene that corresponds to our setup

Create a scene that represents our hardware setup:

  • The distance sensor

  • the color sensor

  • the paper

4. Connect the virtual world to the real world

Read the paper color from the color sensor and modify the color of the thin box representing the paper sheet.

Read the distance between the paper and the distance sensor and make sure this distance is reflected in your virtual world model.

-- Uli Raich - 2018-04-25

Comments

Topic attachments
I Attachment History ActionSorted ascending Size Date Who Comment
Texttxt TCS3200.py.txt r1 manage 10.8 K 2018-04-25 - 11:56 UliRaich  
Unknown file formatpyc TCS3200.pyc r1 manage 11.0 K 2018-04-25 - 11:56 UliRaich  
Texttxt cylinder1.py.txt r1 manage 0.2 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder2.py.txt r1 manage 0.2 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder3.py.txt r1 manage 0.2 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder4.py.txt r1 manage 0.3 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder5.py.txt r1 manage 0.6 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder6.py.txt r1 manage 0.9 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder7.py.txt r1 manage 0.7 K 2018-04-25 - 11:55 UliRaich  
Texttxt cylinder8.py.txt r1 manage 0.7 K 2018-04-25 - 11:55 UliRaich  
Texttxt scene-1.py.txt r1 manage 4.6 K 2018-04-25 - 11:56 UliRaich  
Texttxt scene.py.txt r1 manage 4.2 K 2018-04-25 - 11:55 UliRaich  
Texttxt sceneBak.py.txt r1 manage 3.5 K 2018-04-25 - 11:56 UliRaich  
Texttxt scenePC.py.txt r1 manage 4.3 K 2018-04-25 - 11:56 UliRaich  
Texttxt virtualWorld.py.txt r1 manage 4.0 K 2018-04-25 - 11:56 UliRaich  
Topic revision: r1 - 2018-04-25 - UliRaich
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback