0% found this document useful (0 votes)
8 views

ColorSensor

tailieuthamkhao

Uploaded by

Lê Huy Tùng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

ColorSensor

tailieuthamkhao

Uploaded by

Lê Huy Tùng
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

PRIME LESSONS

By the Makers of EV3Lessons

INTRODUCTION TO COLOR SENSOR


BY SANJAY AND ARVIND SESHAN
LESSON OBJECTIVES

¢ Learn how to use the Color Sensor


¢ Learn how to use the Wait Until Block
¢ Note: Although images in this lessons may show a SPIKE Prime, the code blocks are the
same for Robot Inventor

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 2


WHAT IS A COLOR SENSOR?

¢ In the software, the sensor can detect


Detectable Colors
color or reflectivity Black (0)
Violet (1)
¢ Unlike the EV3, reflectivity is with white Blue (3)
light, not a red light. Light Blue (4)
Green (5)
¢ The sensor can detect 8 colors and no Yellow (7)
color (what those colors are vary Red (9)
between SPIKE Prime and Robot White (10)
No Color (-1)
Inventor)
¢ Optimal reading distance according to the Detectable Colors
specs: 16 mm (depending on object size, Black (0)
color, and surface) Violet (1)
Blue (3)
Teal (4)
Green (5)
¢ Note: In Robot Inventor, the light blue Yellow (7)
color is replaced with teal Red (9)
White (10)
No Color (-1)

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 3


NOTE: ADB AND SENSING COLOR

¢ The color sensor on ADB (Advanced Driving Base


in SPIKE Prime) is mounted at about 8mm off the
ground, but the optimal distance for mounting the
sensor according to the specs is 16mm.
¢ When using this robot design, Black does not
read correctly in Color Mode using electrical
tape lines or a FIRST LEGO League challenge
mat.
¢ See the next slide for modifications. The build
16mm
instructions are also provided as a separate
2M (2 LEGO Modules)
file on our site.

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 4


MODIFICATIONS TO ADB

¢ Build instructions for modifying the front bumper of ADB so that the color sensors are
raised one LEGO module up are included on this website

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 5


HOW DO YOU PROGRAM WITH A COLOR SENSOR?

¢ The two modes you can program the color sensor in: Color Mode and Reflected light
mode
¢ We will use color mode in this lesson

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 6


CHALLENGE 1

¢ Program your robot to move straight until the color sensor sees black
¢ You will need to use the Wait For block and the Boolean block of the color sensor

¢ Basic steps:
¢ Set the movement motors for your robot (A and E for Droid Bot IV and ADB robot)
¢ Set the % speed for your robot
¢ Start moving straight
¢ Use the wait until block to detect when the color sensor sees black
¢ Stop moving

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 7


CHALLENGE 1: SOLUTION

In previous lessons, you learnt how to configure your robot. (See Configuring Your Robot
Lesson)

Configure robot

Start moving

Wait until the color sensor sees black

Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 8


CREDITS

¢ This lesson was created by Sanjay Seshan and Arvind Seshan for Prime Lessons
¢ More lessons are available at www.primelessons.org

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International


License.
Copyright © 2020 Prime Lessons (primelessons.org) CC-BY-NC-SA. (Last edit: 1/9/2020) 9

You might also like