Skip to content
Discussion options

You must be logged in to vote

You just want to read the state of an input pin, right? If yes, then take a look at the Digital Input methods that pins provide. The equivalent of

#define CLK 2
#define SW 4

pinMode(CLK,INPUT);
pinMode(SW, INPUT_PULLUP);

lastStateCLK = digitalRead(CLK);

would be this:

let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);

let clk = pins.d2.into_floating_input();  // or just `pins.d2` as it will be a floating input by default
let sw = pins.d4.into_pull_up_input();

let last_state_clk = clk.is_high();

Not sure if it helps, but there is also this example: uno-pin-change-interrupt.rs

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Guelakais
Comment options

Answer selected by Rahix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants