Digital Inputs. More...
Functions | |
void | digital_init (void) |
uint8_t | digital_read_8 () |
uint8_t | digital_read (uint8_t port) |
void | digital_write (uint8_t port, uint8_t on) |
void | digital_write_pwm (uint8_t port, uint8_t val) |
The Happyboard has 8 digital inputs.
The digital inputs on the Happyboard are unfiltered and as such there is "switch bounce" when they are connected to bump-sensors. To compensate for this users should read digital inputs a few times with short delays between readings to ensure accurate sensing.
void digital_init | ( | void | ) |
Initialize digital ports. Should not be called by user.
uint8_t digital_read | ( | uint8_t | port | ) |
Return the value of a specific digital port. If the port specified is an analog port (8-23), digital_read() returns the equivalent digital reading - <2.5V: FALSE >=2.5V: TRUE.
port | port to read (0-23) |
uint8_t digital_read_8 | ( | ) |
Return the value of all of the digital ports as a single packed byte. The least significant bit is port 0, the most significant is port 7.
void digital_write | ( | uint8_t | port, |
uint8_t | on | ||
) |
Set the output of a specific digital port on or off
port | port to write (0-7) |
on | 0=off, 1=on |
void digital_write_pwm | ( | uint8_t | port, |
uint8_t | val | ||
) |
Output PWM on a digital port
port | port to write (0-7) |
val | PWM duty cycle [0-255]: 0=full off, 127=50% duty cycle, 255=full on |