Color Frequency Counter

24 Feb 2025 - 14:20 | Version 1 |

Objectives

  1. Learn about arrays

Assignment

  1. Create a clean program that will count the number of occurrences of each color and display the result on the screen. The idea is that each "pixel" is a color. Your robot is to go in a line counting the number of pixels of each color and then output the counts of each. Your robot should stop when it touches a "wall".
    1. Each pixel will be about one inch square.
    2. Pixels of the same color may be next to each other.

Suggestions

    1. Start just by counting the number of times you encounter one specific color. This can be done without an array and will get you started.
    2. Then create seven variables (one for each color) and do it for all colors
    3. Then use an array with just one element. Use black (index of 1) and just count the number of times you encounter black.
    4. Then add blue to your colors and two elements in the array
    5. Finally make it so that your array has seven elements (one for each color)
    6. Stop when you touch something
  1. Additional requirements
    1. The final version must use an array to store the counts for each color

Submission instructions

  1. Due date is found on Canvas
  2. Each person should create a pdf document that contains the following information
    1. Your name
    2. Your partner's name
    3. A brief description of what you did
    4. A brief description of what your partner did
    5. How your team improved over any mistakes made last time
    6. Indicate which hints (if any) your team used
    7. How well you achieve each objective.
  3. Submission:
    1. Team member A submits the team's code and his/her pdf document in one zip folder.
    2. Team member B submits his/her pdf document (does not need to be zip'ed)

Hints

  1. Essential when setting up an array
  2. Converting a color to an index

Challenges

  1. Have the robot speak the color and counts
  2. Have the robot speak or display the color with the largest number of occurrences. If there is a tie, just output the first one
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine