Tcl Raspberry Pi I/O


The piio command


piio subcommand ?arg ...?


The piio command lets you manipulate the Raspberry Pi gpio pins. The legal values of subcommand are listed below. Note that you can abbreviate the subcommands.

piio event gpiopin edge ?script?
Arrange for the Tcl script script to be called whenever the level change specified by edge (rising or falling) is detected on the input port. If script is the empty string, the current handler is deleted. If script is omitted, the currently installed script is returned (or an empty string if no such handler is installed).
piio function ?gpiopin? ?function?
Obtain or configure the function of a gpiopin. When both gpiopin and function are specified, the function of the gpio pin is configured. When only a gpiopin is specified, the current function of the pin is returned. Without arguments a list of all pin functions is returned. The gpiopin must be specified as a number between 0 and 53. Valid functions are: input, output, altfunc0, altfunc1, altfunc2, altfunc3, altfunc4, or altfunc5. Check the BCM2835 documentation for the available alternate functions for each pin.
piio input gpiopin
Reads the current state of the gpio pin. Returns 0 for low and 1 for a high logical level.
piio output gpiopin state
Set the state of a gpio output pin. The state must be specified as an integer, where 0 sets the output low and any other value sets it high.
piio pull direction gpiopin ?gpiopin ...?
Control weak pull-up or -down for an input port. Valid values for direction are: up, down, none.
piio usleep usec
When dealing with hardware it may be useful to be able to delay short amounts of time. This command will block for the specified number of microseconds.