Coding challenges
Here are some example tasks for working with the FactoryBox.
They start with the basic principles of working with an ESP and Arduino, then progress to more complex sensor integrations and optional challenges.
🟢 Level 0 – Basic Control & Inputs
| Task | Turn on a LED via Button |
|---|---|
| What to do: | Make the LED turn on and off via the push of a button |
| Parts Needed: | LED White (ID: 36) Push Button (ID: 44) |
| Goals: | Connect to an LED on the ESP32 Check for button input |
| Implementation Notes: | Test each part individually before combining them Watch out for key bounce on the push-button Only these two components are not connected via the IO Expander |
| Task | Move a Servo Motor |
|---|---|
| What to do: | Try to move the Servo-Motor. Try to create a smooth turn |
| Parts Needed: | Micro Servo (ID: 50) |
| Goals: | Use PWM to move the servo motor |
| Implementation Notes: | Servos rotate up to 180° Smooth motion can be achieved by adjusting the speed |
| Task | Move the Stepper Motor |
|---|---|
| What to do: | Make the Stepper Motor turn. Try to create a smooth turn speed |
| Parts Needed: | Stepper Motor (ID: 51) |
| Goals: | Rotate the stepper motor |
| Implementation Notes: | Speed and direction can be varied Stepper motors can rotate beyond 360° |
🟡 Level 1 – Intermediate Control & Output
| Task | LED Animation on RGBW Strip |
|---|---|
| What to do: | Create an animation on the LED-Strip. A simple start is a singular LED moving along the strip. |
| Parts Needed: | LED Strip (ID: 40) |
| Goals: | Animate LED flow to match the layout diagram Make smooth color transitions |
| Implementation Notes: | Though listed separately, all strips are connected to the same pin LED orientation may vary |
| Task | Turn On All Hall Lights |
|---|---|
| What to do: | Turn all the white LEDs on/off with the push of the light-button on the control panel |
| Parts Needed: | LED White (ID: 33, 34, 35, 36) Push Button (ID: 42) LDR (ID: 32) IO Expander (ID: 52) |
| Goals: | Connect LEDs via IO Expander Control lights with a push button Automatically turn on lights when it’s dark |
| Implementation Notes: | Not all LEDs are controlled via IO Expander LDR-activated lights should toggle off with next button press |
| Task | Read Distance via I2C and Display as Text |
|---|---|
| What to do: | Get the distance from the distance sensor and display the distance on the LCD-Screen |
| Parts Needed: | Distance Sensor (ID: 54) LCD Display (ID: 53) |
| Goals: | Measure distance Display results with units |
| Implementation Notes: | Handle missing sensor data Warn when distance is too low Test connections separately |
🟠 Level 2 – Smart Interactions & Logic
| Task | Count Incoming Material |
|---|---|
| What to do: | Trigger the light barrier by moving the servo arm between the sensor and out again. Start at a count of 0 on the 7-segment display and count up each time the light barrier is disrupted. |
| Parts Needed: | Micro Servo (ID: 49) Light Barrier (ID: 48) 4-Digit Display (ID: 56) |
| Goals: | Trigger light barrier with servo Count on display when interrupted |
| Implementation Notes: | Avoid triggering the barrier twice Be careful not to damage the servo Optimize speed for precise counting |
| Task | Quality of Life Surveillance |
|---|---|
| What to do: | Create a system that automatically surveils the factory hall. Turn on the fan if it gets too warm/wet/gassy and turn it off again if the situation has improved |
| Parts Needed: | Air Quality Sensor (ID: 58) Temp/Humidity Sensor (ID: 55) Fan (ID: 47) Optional: LED Red (ID: 38) |
| Goals: | Turn on fan if temp, humidity, or air quality is bad Monitor and deactivate when safe Optional: Turn on red LED for poor air quality |
| Implementation Notes: | Define practical sensor thresholds Avoid using delay() – use intervals Use different intervals for checks and alerts Good air doesn’t always mean good temperature – check before turning the fan off |
| Task | Implement Warning System |
|---|---|
| What to do: | Make an alarm sound if someone/something enters the restricted area. Do that by checking the distance sensor. If its distance reduces greatly, activate the buzzer and the red LED to create an alarm. Use the e-stop button to stop/reset the alarm |
| Parts Needed: | LED Red (ID: 37, 38) Push Button (ID: 43) Buzzer (ID: 45) Distance Sensor (ID: 54) |
| Goals: | Detect movement in restricted area Trigger buzzer alarm Reset via push button |
| Implementation Notes: | Use a timed buzzer alert, not just one long sound Don’t allow reset while the threat remains |
🔴 Level 3 – Advanced Systems & Production Cycle
| Task | Full Production Cycle via Button |
|---|---|
| What to do: | Bring the factory to life. Use the factory flow from the Wiki as a reference. Start the process with the start-button and combine the previous challenges. |
| Parts Needed: | Micro Servo (ID: 49, 50) Light Barrier (ID: 48) 4-Digit Display (ID: 56) Stepper Motor (ID: 51) LED Blue (ID: 39) Push Button (ID: 41, 44) IO Expander (ID: 52) LCD Display (ID: 53) LED Bar (ID: 57) LED Strip (ID: 40) Solenoid (ID: 46) |
| Goals: | Start production with a button press Visualize flow via LED strips Count parts and display progress Simulate CNC process and robotic unloading Reset with reset button |
| Implementation Notes: | Decide if everything triggers once or loops Use clear code comments to explain logic |
| Task | Combine Production with Hall Features |
|---|---|
| What to do: | Add on the factory production process through adding the basic hall functionality. Combine the challenges such as the alarm function or the alarm system. If an alarm triggers, all production needs to be paused. If the e-stop button is triggered, all production needs to be halted. |
| Parts Needed: | (All from above) Additional: LED White (ID: 33, 34, 35, 36) LED Red (ID: 37, 38) LDR (ID: 32) Push Button (ID: 42, 43) Buzzer (ID: 45) Distance Sensor (ID: 54) Air Quality Sensor (ID: 58) Temp/Humidity Sensor (ID: 55) Fan (ID: 47) |
| Goals: | Add air quality and lighting features Allow alarms to trigger during CNC/robot operation Pause production if alarms or emergency stop are triggered |
| Implementation Notes: | Use non-blocking code (no delays!) Define clear activation conditions for each system |
🟣 Additional Challenges
| Extra Challenge | Description |
|---|---|
| ISRs and timers | Use Interrupt Service Routines (ISRs) for real-time reactions |
| Combine hall features | Make hall features work alongside production logic |
| Refactor code | Refactor code with reusable functions |
| LED animations | Customize LED animations or CNC machine patterns |
| Startup calibration | Add a startup calibration routine before system operation |
