#pin #dummy #gpio-pin #io #gpio #hal

no-std dummy-pin

Dummy implementations of the input/output pin embedded-hal traits

4 releases (1 stable)

1.0.0 Jan 19, 2024
0.2.0-alpha.1 Aug 11, 2022
0.1.1 Apr 22, 2021
0.1.0 Mar 10, 2021

#1706 in Embedded development

Download history 54/week @ 2024-01-17 5/week @ 2024-02-14 22/week @ 2024-02-21 17/week @ 2024-02-28 3/week @ 2024-03-06 2/week @ 2024-03-13 20/week @ 2024-03-27 31/week @ 2024-04-03 8/week @ 2024-04-10 27/week @ 2024-04-17 16/week @ 2024-04-24 48/week @ 2024-05-01

99 downloads per month
Used in 4 crates


118 lines

Dummy Input/Output Pin Implementations

crates.io Docs MSRV Build Status Coverage Status

This provides dummy implementations of the input/output pin embedded-hal traits. This is useful when dealing with setups where a certain pin is handled by hardware in a way that the software does not need to know about, for example.

In addition to the no-op, zero-cost DummyPin, this crate provides an implementation of LastStateDummyPin, which stores the last state set at runtime and returns it when read.


This example demonstrates how the same driver can operate with either a real or a dummy output pin.

use dummy_pin::DummyPin;
use embedded_hal::digital::OutputPin;
use linux_embedded_hal::SysfsPin;

struct Driver<P> {
    output: P,

impl<P, E> Driver<P>
    P: OutputPin<Error = E>,
    fn new(pin: P) -> Self {
        Driver { output: pin }

    fn do_something(&mut self) -> Result<(), E> {
        // ...

fn main() {
    // The same driver can operate with either a real or a dummy pin.
    let real_pin = SysfsPin::new(25);
    let mut driver_with_real_pin = Driver::new(real_pin);

    let dummy_pin = DummyPin::new_low();
    let mut driver_with_dummy_pin = Driver::new(dummy_pin);


For questions, issues, feature requests, and other changes, please file an issue in the github project.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.