Menu
CoddyTech

The One-Button Toggle

Part of the Latches, Edges and Interlocks section of Coddy's PLC Programming journey. Lesson 9 of 20.

A toggle is one button that flips an output: press once, on; press again, off. It needs two things:

  • an edge, so one press is one flip. Without it, the lamp flips on every scan while the button is held
  • a memory bit that holds the edge, so the next rung can read it with a normally open and a normally closed contact

Read rung 2. A pulse with Green off: the top path turns Green on. No pulse with Green on: the bottom path holds it, like a seal-in. A pulse with Green on: neither path passes power, so Green turns off.

challenge icon

Challenge

Medium

Make PB1 toggle Green:

  • create a BOOL memory bit Pulse
  • rung 1: a rising edge on PB1 writes Pulse
  • rung 2: the toggle rung from the theory

Try it yourself

{"v":1,"lang":"ld","tags":[],"rungs":[{"els":[]}]}

All lessons in Latches, Edges and Interlocks

Practice on your own: PLC playground