RIGHT ) # Show how many colored objects we have already scanned. while len ( color_list ) < 8 : # Show an arrow that points to the color sensor. This is done by repeating the loop # while the length of the list is still less than 8. It repeats until 8 objects # are scanned and placed in the chute. color_list = # This loop scans the colors of the objects. reset_angle ( 0 ) # When we scan the objects, we store all the color numbers in a list. This means that when it rotates backward to zero later # on, it returns to this starting position. Then the motor stops, and the the angle is # reset to zero. # This is done by first running the belt motor backward until the # touch sensor becomes pressed. run_angle ( 450, - 200 ) # Get the conveyor belt motor in the correct starting position. run_until_stalled ( 120, duty_limit = 50 ) feed_motor. From this end point, the motor # rotates backward by 180 degrees. This # means that it cannot move any further. # This is done by running the motor forward until it stalls. while True : # Get the feed motor in the correct starting position. Then the process starts over and you can scan # and insert the next set of colored objects. It waits for you to scan and insert 8 colored objects. It is used to detect the color of the objects. It is used to detect when the belt motor has # moved the sorter module all the way to the left. ev3 = EV3Brick () # Initialize the motors that drive the conveyor belt and eject the objects. POSSIBLE_COLORS = # Initialize the EV3 brick. Download: Building instructions can be found at: """ from pybricks.hubs import EV3Brick from pybricks.ev3devices import Motor, TouchSensor, ColorSensor from pybricks.parameters import Port, Button, Color, ImageFile, SoundFile from pybricks.tools import wait # The colored objects are either red, green, blue, or yellow. #!/usr/bin/env pybricks-micropython """ Example LEGO® MINDSTORMS® EV3 Color Sorter Program - This program requires LEGO® EV3 MicroPython v2.0.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |