All exercises

Sandwich Maker

Run a sandwich-assembly sequence in rungs.dev driven by bread and ingredient sensors — count slices on rising edges and start the conveyor and assemble motors.

intermediate

Parameters

NameTypeUsageDescription
In_BreadFeederBOOLInput1 when bread is detected.
In_Ingredient1BOOLInput1 when ingredient 1 is present.
In_Ingredient2BOOLInput1 when ingredient 2 is present.
In_Ingredient3BOOLInput1 when ingredient 3 is present.
In_Condiment1BOOLInput1 when condiment 1 is present.
In_Condiment2BOOLInput1 when condiment 2 is present.
Out_ConveyorMotorBOOLOutput1 when conveyor motor is active.
Out_AssembleMotorBOOLOutput1 when assembly motor is active.

Behavior

  1. On the rising edge of In_BreadFeeder, the internal SliceCount is incremented by 1.
  2. Out_ConveyorMotor is set to 1 while In_BreadFeeder is 1.
  3. Out_AssembleMotor is set to 1 if SliceCount is greater than or equal to 2 AND In_Ingredient1 is 1 AND In_Ingredient2 is 1 AND In_Ingredient3 is 1 AND In_Condiment1 is 1 AND In_Condiment2 is 1; otherwise, it is 0.
  4. SliceCount initializes at 0, persists across scans, and only increments on a rising edge so a continuously true In_BreadFeeder does not add extra slices.

Ready to start?

Open this exercise in Rungs Studio, write your solution, then click Test in the toolbar to verify your work against the built-in test cases.