Hi. I'm working on an FM radio project with an Arduino Mega 2560.
I have a btn
variable that I'd like to pass to a function, but I can't figure out how to do it.
let mut adc = arduino_hal::Adc::new(dp.ADC, Default::default());
let btn = pins.a0.into_analog_input(&mut adc);
fn do_something<T>(adc: &arduino_hal::Adc, pin: &arduino_hal::port::Pin<arduino_hal::port::mode::Analog, T>)
where T: arduino_hal::port::PinOps {
pin.analog_read(&mut adc);
todo!();
}
I'm getting the following error, which makes sense:
error[E0277]: the trait bound
avr_hal_generic::port::Pin<Analog, T>: AdcChannel<_, _> is not satisfied
Instead of Pin<Analog, T>
I should use something like Pin<Analog, PF0>
but I don't know how to access PF0
.