Req 4d1 — Write the Code
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:
- Read inputs from sensors or controls
- Decide what should happen next
- Command motors or mechanisms
- 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:
- starting conditions
- movement commands
- sensor checks
- if/then decisions
- stop conditions or safety limits
- comments or labels that explain key sections
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%5CWhat 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:
- the whole short program, if it fits clearly on the page
- the main loop
- the function that reacts to sensor input
- an autonomous routine
You can also add brief notes such as:
- what each sensor does
- what counts as a trigger
- why you chose a threshold value
- what bug you had to fix
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.