Skip to content

Event: When digital pin () changes at ()

Jaume Olivé Petrus edited this page Oct 30, 2017 · 2 revisions

This block is an Input / Output block and an Event block that is activated when the logical level of a specified pin changes. When the block is activated its script is executed. The change condition can be either:

  • Positive edge: this is a low to high transition.
  • Negative edge: this is a high to low transition.
  • Low level: this is when level is low.
  • High level: this is when level is high.
  • Any edge: this is a low to high transition, or a high to low transition.

Shape

Example

In this example a switch and a led are attached to 2 GPIO. When the switch is pushed the led is turned on, and when the switch is released the led is turned off.

In this example it is assumed that the switch is pulled-up by hardware, so when the switch is pressed the logic level of the GPIO is "low" and when is released is "high".

Instructions:

  • Connect a switch to GPIO25.
  • Connect a led to GPIO 25.

Run this example in The Whitecat IDE.

Clone this wiki locally