--- title: Antarctic Mission - Prompt blocks format: html: code-line-numbers: true css: Arduino_prompts.css execute: enabled: false --- The scaffold is generated by the [calibration website](https://lunarnotes.ch/serve/4.%20Semester/PDP2/IR%20sensor/threshold_calibration.html). # Prompt blocks ## Block A - Constants / Globals ```{text} You are editing an Arduino Uno `.ino` sketch step by step. # RULES - Keep the code very similar to the provided sketch in structure, naming style, and general style. - Do not redesign the project architecture. - Keep the section order: 1. includes 2. constants / globals 3. helper functions 4. setup 5. loop - Keep the sketch compilable after this step. - Return the full updated sketch. - Modify only what is needed for this step. - Do not invent final calibration values. # TASK FOR THIS STEP Review and refine only the CONSTANTS / GLOBALS section. ## REQUIREMENTS - preserve the current coding style - keep: - float ambientTempC = AMBIENT_TEMP_C; - float boardSideCm = BOARD_SIDE_CM; - add a new calibration variable for the rotation angle of the motor in degrees - calculate SWEEP_STEPS dynamically based on this rotation angle and stepsPerDegree - keep motor configuration simple - keep: - const int START_OFFSET_STEPS = 0; - int currentMotorPosition = 0; - keep stepsPerDegree as a simple approximate conversion - keep TOTAL_PIXELS = 64 - do not implement loop logic yet - do not modify any other sections except the constants / globals section ## SECTION TO REVIEW // ===================== CONSTANTS / GLOBALS ===================== # CURRENT FULL CODE [PASTE THE INITIAL SCAFFOLD HERE] ``` ## Block B - Motor / Angle helpers ```{text} You are editing the next step of the same Arduino Uno sketch. # RULES - Keep the code very similar to the current version. - Return the full updated sketch. - Work mainly on the motor / angle helper section. - Make only minimal necessary edits elsewhere. - Do not invent or replace final calibration values. # TASK FOR THIS STEP Complete the motor / angle helper logic. ## REQUIREMENTS - keep the original style simple - keep SWEEP_STEPS as the sweep span already defined in the globals - add simple helpers to convert motor position to angle in degrees - keep 0° -> X° -> 0° sweep behavior conceptually - keep currentMotorPosition logic similar to the scaffold - do not redesign the whole project - do not implement the full loop logic yet - do not modify any other sections except the motor / angle helpers section # SECTION TO REVIEW // --- MOTOR / ANGLE HELPERS --- ``` ## Block C - Ultrasonic helpers ```{text} You are editing the next step of the same Arduino Uno sketch. # RULES - Keep the code very similar to the current version. - Return the full updated sketch. - Work mainly on the ultrasonic helper section. - Make only minimal necessary edits elsewhere. - Keep the code simple and suitable for Arduino Uno. # TASK FOR THIS STEP Complete the ultrasonic helper logic. ## REQUIREMENTS - keep the existing style and structure if possible - keep: - readUltrasonicDuration() - microsecondsToCentimeters() - return distance in cm from pulse duration - you may add a helper to average multiple readings - valid distance rule is exactly: 5 < x < d - use boardSideCm as d - out-of-range values must not count as valid later - keep the code simple and readable - do not implement full detection/reporting logic here unless minimally necessary - do not modify any other sections except the ultrasonic helpers section # SECTION TO REVIEW // --- ULTRASONIC HELPERS --- ``` ## Block D - Infrared sensor helpers ```{text} You are editing the next step of the same Arduino Uno sketch. # RULES - Keep the code very similar to the current version. - Return the full updated sketch. - Work mainly on the thermal helper section. - Make only minimal necessary edits elsewhere. # TASK FOR THIS STEP Complete the thermal helper logic. ## REQUIREMENTS - read the full 8x8 AMG8833 temperature matrix - compute the maximum temperature across all 64 pixels - do not use only middle columns - keep the code simple and readable - keep memory usage suitable for Arduino Uno - avoid unnecessary buffers if possible - do not implement detection/reporting logic here unless minimally necessary - do not modify any other sections except the thermal helpers section # SECTION TO REVIEW // --- THERMAL HELPERS --- ``` ## Block E - Detection / Reporting helpers ```{text} You are editing the next step of the same Arduino Uno sketch. # RULES - Keep the code very similar to the current version. - Return the full updated sketch. - Work mainly on the detection / reporting helper section. - Make only minimal necessary edits elsewhere. - Do not redesign the project. # TASK FOR THIS STEP Complete the detection and reporting logic. ## REQUIREMENTS - target is detected only if both are true: - distance is valid - maximum temperature > getHotThreshold(distanceCm, boardSideCm, ambientTempC) - use the already existing threshold function exactly as it is - serial output must show: - current distance - current motor angle - maximum temperature - detection status - keep the style similar to the scaffold - avoid String and dynamic memory - keep helper logic separate and simple - do not modify any other sections except the detection / reporting helpers section # SECTION TO REVIEW // --- DETECTION / REPORTING HELPERS --- ``` ## Block F - Setup ```{text} You are editing the next step of the same Arduino Uno sketch. # RULES - Keep the code very similar to the current version. - Return the full updated sketch. - Work mainly on setup(). - Make only minimal necessary edits elsewhere. - Do not invent or replace final calibration values. # TASK FOR THIS STEP Complete setup() consistently with the helper logic already created. ## REQUIREMENTS - initialize Serial - initialize Wire - initialize motor driver - initialize AMG8833 sensor - keep optional start offset behavior - keep sweep configuration generic - do not redesign the structure - do not modify any other sections except the setup section # SECTION TO REVIEW // ===================== SETUP ===================== ``` ## Block G - Main Loop ```{text} You are editing the next step of the same Arduino Uno sketch. # RULES - Keep the code very similar to the current version. - Return the full updated sketch. - Work mainly on loop(). - Make only minimal necessary edits elsewhere. - Do not invent or replace final calibration values. - Do not redesign the project. # TASK FOR THIS STEP Complete the logic inside the main loop. ## REQUIREMENTS - preserve the current forward / backward sweep structure - forward sweep must go from 0° to X° - backward sweep must go from X° to 0° - use SWEEP_STEPS as the current configured sweep span - read sensors at each motor step - use the already defined ultrasonic, thermal, and detection/reporting helpers - keep angle tracking consistent in both directions - keep serial reporting active - do not modify any other sections except the main loop section # SECTION TO REVIEW // ===================== MAIN LOOP ===================== ```