Development (Advanced)

Make a Complicated Piston

User Story: As a user, when my door opens and I am at home, I want my bulb to be turned on with green color. When my door opens and I am away, then turn on the alarm switch. When my door closes and I am away, Turn off the bulb.

  • IF
    • Contact Sensor is OPEN
  • THEN
    • IF
      Location Mode is Away
    • THEN
      Turn alarm Switch 1 ON
    • ELSE
      • IF
        Bulb 1 is OFF
      • THEN
        Turn Bulb 1 ON
        Set Bulb 1 Color to Green
  • ELSE
    • IF
      Location Mode is Away and
      Bulb 1 is ON
    • THEN
      Turn Bulb 1 OFF

  1. Create a New Piston.

  2. Add a new statement in webCoRE editor.

  3. Add the first If condition.

  4. Add the first nested If condition.

  5. Add the first nested condition.

  6. Add the second level nested If condition inside the Else.

  7. Add a second level nested command.

  8. Add a nested If statement inside first Else.

  9. Add one more condition.

  10. Add a nested command for Else.

  1. Click Save, you can see the newly created piston on the dashboard.


You're done!

Congratulations! You have successfully achieved the goal of this Code Lab activity. Now, you can create both basic and complicated piston on webCoRE by yourself!