Design and Build Your Robot

Req 4d1 — Write the Code

4d1.
Program your robot to perform the task you chose for your robot in 4(a). Include a sample of your program’s source code in your robot engineering notebook.

This option is about turning your design into behavior. Your code does not have to be huge. It does have to be understandable. When your counselor looks at it, they should be able to see how the program helps the robot sense, decide, and act.

Focus on the core loop

Most robot programs follow the same pattern:

  1. Read inputs from sensors or controls
  2. Decide what should happen next
  3. Command motors or mechanisms
  4. Repeat or move to the next step

If your code can do those jobs clearly, it is doing real robotics work.

What your program should show

A good merit badge program usually includes some combination of:

For example, a simple robot might drive forward until a distance sensor sees an obstacle, then stop and raise an arm. Another robot might follow a line until a color sensor detects a finish marker.

VEXcode VR (website) A browser-based environment for practicing robot logic with sensors, movement, and block or text programming. Link: VEXcode VR (website) — https://www.vexrobotics.com/vexcode/vr?srsltid=AfmBOopvcCE5uFUVB__bxV0UiLP20ZZQwq0WrNHHJWuIQUDXmLAwl8UL%5C

What to include in your notebook

Your notebook should contain a sample of the source code, not just a sentence saying you coded it. Include the part that best shows the robot’s logic. That might be:

You can also add brief notes such as:

Code sample checklist

Before you show it to your counselor
  • Sensor input is visible somewhere in the code.
  • Motor or mechanism output is visible somewhere in the code.
  • The task from Req 4a is clearly connected to the logic.
  • Variable names or comments make the sample readable.
  • The sample matches what the real robot actually does.

In Req 4e, you will test and improve the robot. Save version notes now so you can later explain what changed and why.