next up previous contents
Next: int analog(int p) Up: 9.2 Sensor Input Previous: 9.2 Sensor Input

int digital(int p)


Returns the value of the sensor in sensor port p, as a true/false value (1 for true and 0 for false).

Sensors are expected to be active low, meaning that they are valued at zero volts in the active, or true, state. Thus the library function returns the inverse of the actual reading from the digital hardware: if the reading is zero volts or logic zero, the

digital() function will return true.

If the digital() function is applied to port that is implemented in hardware as an analog input, the result is true if the analog measurement is less than 127, and false if the reading is greater than or equal to 127.

Ports are numbered as marked on the Handy Board.



Fred G. Martin
Fri Mar 29 17:44:15 EST 1996