Demonstration of the new optical sensor capabilities
Ability to measure both colors and levels of light and darkness
Plugging in the optical sensor
Connecting to Port 2 and ensuring a proper connection with an audible click
Accessing the menu and selecting the optical sensor from Port 2
Viewing RGB values for colors in front of the sensor
Ability to detect proximity (near/distant) and brightness of light/UV light
Writing a simple program to utilize the sensor
Selection of the "on" mode, with options for color mode and gesture mode (gesture mode may not function well)
Implementation of a control structure with a forever loop
Creating an if statement to detect colors
Example actions based on color detection:
If green is detected:
Set motor velocity to 100%
Spin motor forward
Print "green" on the LED screen with background fill color
If yellow is detected:
Set motor velocity to 50%
Change print color and fill color to yellow
If red is detected:
Stop the motor
Change print color to red and statement to "red"
Running the program to detect colors:
Starts with no color detection until a color is introduced
Results for various colors:
Green detected correctly, motor spins at 100%
Sensor defaults to yellow due to ambient lighting
Red marker detection stops the motor
Ability to switch between colors effectively
Accessing various device features through the menu
Checking readings from the optical sensor for educational purposes
Emphasizing the importance of validating color values for programming tasks
Highlights potential applications for the optical sensor in different projects
Encourages students to experiment and utilize the sensor in various contexts.
Introduction to the Optical Sensor Demonstration of the new optical sensor capabilities Ability to measure both colors and levels of light and darkness
Setting Up the Sensor
Plugging in the optical sensor
Connecting to Port 2 and ensuring a proper connection with an audible click
Accessing the menu and selecting the optical sensor from Port 2
Viewing RGB values for colors in front of the sensor
Ability to detect proximity (near/distant) and brightness of light/UV light
Programming the Optical Sensor
Writing a simple program to utilize the sensor:
# Example program to use the optical sensor
while True:
color = get_color_from_sensor()
if color == 'green':
set_motor_velocity(100)
spin_motor_forward()
print('green') # with background fill color
elif color == 'yellow':
set_motor_velocity(50)
change_print_color('yellow')
elif color == 'red':
stop_motor()
change_print_color('red')
print('red')
Selection of the "on" mode, with options for color mode and gesture mode (gesture mode may not function well)
Implementation of a control structure with a forever loop
Creating an if statement to detect colors
Testing the Program
Running the program to detect colors:
Starts with no color detection until a color is introduced
Results for various colors:
Green detected correctly, motor spins at 100%
Sensor defaults to yellow due to ambient lighting
Red marker detection stops the motor
Ability to switch between colors effectively
Using the Device Menu
Accessing various device features through the menu
Checking readings from the optical sensor for educational purposes
Emphasizing the importance of validating color values for programming tasks
Conclusion Highlights potential applications for the optical sensor in different projects Encourages students to experiment and utilize the sensor in various contexts.