Skip to content

maxinbjohn/zephyrproject-rtos-relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.. zephyr:code-sample:: relay
   :name: Relay
   :relevant-api: gpio_interface

   Control a Relay using the GPIO API.

Overview

A relay is an electromagnetic switch operated by a relatively small electric current that can turn on or off a much larger electric current.

This Relay sample turns a relay on and off forever using the :ref:`GPIO API <gpio_api>`.

The source code shows how to:

  1. Get a pin specification from the :ref:`devicetree <dt-guide>` as a :c:struct:`gpio_dt_spec`
  2. Configure the GPIO pin as an output
  3. Toggle the pin forever

Requirements

Your board must:

  1. Have a Relay connected via a GPIO pin

Building and Running

Build and flash Relay as follows, changing longan_nano for your board:

.. zephyr-app-commands::
   :zephyr-app: samples/basic/relay
   :board: longan_nano
   :goals: build flash
   :compact:

After flashing, the Relay will switch on and off in 5 seconds. If a runtime error occurs, the sample exits without printing to the console.

About

Relay module support in zephyr

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published