libkipr  1.0.0
Analogs

Functions

int analog (int port)
 
int analog8 (int port)
 
int analog10 (int port)
 
int analog12 (int port)
 
int analog_et (int port)
 
void set_analog_pullup (int port, int pullup)
 
int get_analog_pullup (int port)
 

Detailed Description

The functions defined here allow for reading the values in analog sensors.

Example

For example, if there was a distance sensor in analog port 0, then you could use the following code block to move until close to an object or wall

#include <kipr/wombat.h>
#include <stdio.h>
int main(){
// arbitrary number that represents how close to get to the wall/object
// larger numbers mean closer to the wall/object
int stopping_distance = 1200;
while (analog(0) < stopping_distance){
// move
}
}
int analog(int port)

Function Documentation

◆ analog()

int analog ( int  port)

Gets the 12-bit analog value of a port.

Parameters
[in]portA value between 0 and 5 specifying the sensor to read from.
Returns
The latest 12-bit value of the port (a value in the range 0 to 4095).
See also
analog12

◆ analog10()

int analog10 ( int  port)

Gets the 10-bit analog value of a port.

Parameters
[in]portA value between 0 and 5 specifying the sensor to read from.
Returns
The latest 10-bit value of the port (a value in the range 0 to 1023).
See also
analog

◆ analog12()

int analog12 ( int  port)

Gets the 12-bit analog value of a port.

Parameters
[in]portA value between 0 and 5 specifying the sensor to read from.
Returns
The latest 12-bit value of the port (a value in the range 0 to 4095).
See also
analog

◆ analog8()

int analog8 ( int  port)

Gets the 8-bit analog value of a port.

Parameters
[in]portA value between 0 and 5 specifying the sensor to read from.
Returns
The latest 8-bit value of the port (a value in the range 0 to 255).
See also
analog

◆ analog_et()

int analog_et ( int  port)

Gets the 10-bit analog value of an ET sensor on the given port.

Parameters
[in]portA value between 0 and 7 specifying the ET sensor to read from.
Returns
The latest 10-bit value of the port (a value in the range 0 to 1023).
See also
analog
Deprecated:
defaulting to analog() on the Wallaby

◆ get_analog_pullup()

int get_analog_pullup ( int  port)

Gets the analog pullup status for one portt.

Parameters
[in]portA value between 0 and 7 specifying the analog sensor to read from.
Returns
The status of the analog pullup on the specified port
See also
analog
Deprecated:
no effect on the Wallaby

◆ set_analog_pullup()

void set_analog_pullup ( int  port,
int  pullup 
)

Sets analog pullup status for one port.

Parameters
[in]portA value between 0 and 5 specifying the analog sensor to read from.
[in]pullupA value of 0 (inactive) or 1 (active).
See also
analog
Deprecated:
no effect on the Wallaby