[−][src]Struct teensyduino::gpio::Pin
A container for a pin number that has been verified to exist This method was chosen to limit the use of unsafe when dealing with pins
See Also
Implementations
impl Pin
[src]
pub const unsafe fn new(pin: u8) -> Pin
[src]
Create a new Pin to drive a GPIO
Safety
The caller must verify that the pin provided is a valid pin on the board they are using. Passing an invalid pin number will result in undefined behavior
pub fn mode(&self, mode: PinMode)
[src]
Configures the specified pin to behave either as an input or an output. See the Digital Pins page for details on the functionality of the pins.
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.
Notes and Warnings
The analog input pins can be used as digital pins, referred to as A0, A1, etc.
See Also
pub fn set_high(&self)
[src]
Set the pins output to high. A proxy for digital_write(true)
pub fn set_low(&self)
[src]
Set the pins output to low. A proxy for digital_write(false)
pub fn toggle(&self)
[src]
Set the pins output to the opposite of what it currently is
pub fn digital_write(&self, value: bool)
[src]
Write a HIGH (true) or a LOW (false) value to a digital pin.
If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digital_write()
will enable
(HIGH) or disable (LOW) the internal pullup on the input pin.
It is recommended to set the mode()
to PinMode::InputPullup
to enable
the internal pull-up resistor. See the Digital Pins tutorial for
more information.
If you do not set the mode()
to OUTPUT, and connect an LED to
a pin, when calling digital_write(true)
, the LED may appear dim.
Without explicitly setting mode()
, digital_write()
will have
enabled the internal pull-up resistor, which acts like a large
current-limiting resistor.
See Also
pub fn digital_read(&self) -> bool
[src]
Reads the value from a specified digital pin, either HIGH or LOW.
Notes and Warnings
If the pin isn’t connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly).
The analog input pins can be used as digital pins, referred to as A0, A1, etc. The exception is the Arduino Nano, Pro Mini, and Mini’s A6 and A7 pins, which can only be used as analog inputs.
See Also
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,