libkipr  1.0.0
Digitals

Functions

int digital (int port)
 
void set_digital_value (int port, int value)
 
int get_digital_value (int port)
 
void set_digital_output (int port, int out)
 
int get_digital_output (int port)
 
int get_digital_pullup (int port)
 
void set_digital_pullup (int port, int pullup)
 

Detailed Description

The functions here allow for reading the values of digital sensors.

example_digital_touch

Assuming that there is a touch sensor plugged into digital port 0, then the following code would move forward until the touch sensor was clicked.

#include <kipr/wombat.h>
int main(){
int touch_port_number = 0;
while (digital(touch_port_number) != 1){
// move
motor(0, 100);
motor(1, -100);
}
// stop moving
ao();
return 0;
}
int digital(int port)
void motor(int motor, int percent)
Moves a motor at a percent velocity.
void ao()
Turns all motors off.

Function Documentation

◆ digital()

int digital ( int  port)

◆ get_digital_output()

int get_digital_output ( int  port)

Gets the current digital mode

Returns
1 for output mode, 0 for input mode
See also
set_digital_value

◆ get_digital_pullup()

int get_digital_pullup ( int  port)

Gets the current digital pullup state

Returns
1 for active, 0 for inactive
Deprecated:
not applicable on the Wallaby

◆ get_digital_value()

int get_digital_value ( int  port)

Gets the current value of the digital port.

Returns
1 if the switch is closed, 0 if the switch is open
See also
set_digital_value

◆ set_digital_output()

void set_digital_output ( int  port,
int  out 
)

Sets the digital mode.

Parameters
[in]portThe port to modify.
[in]out1 for output mode, 0 for input mode.

◆ set_digital_pullup()

void set_digital_pullup ( int  port,
int  pullup 
)

Sets the current digital pullup state

Parameters
[in]portThe port to modify
[in]pullupThe pullup state 1: active 0: inactive
Deprecated:
not applicable on the Wallaby

◆ set_digital_value()

void set_digital_value ( int  port,
int  value 
)

Sets the value of the digital port in output mode.

See also
get_digital_value