-
Notifications
You must be signed in to change notification settings - Fork 7
Timer predicates
The arguments passed to a predicate can take three forms - Input, Output or Both, and are denoted by symbols +, - and ? respect
AgPi also provides Timer based predicates which allow for accurate delay and timing functionalities:
-
delay(+T)
: Used to apply a delay of t milliseconds.- t: Time in milliseconds.
-
delayMicroseconds(+T)
: Used to apply a delay of t microseconds.- t: Time in microseconds.
-
millis(-T)
: It returns a number (T) representing the number of milliseconds since the program called one of the AgPi functions. It returns an unsigned 32-bit number which wraps after 49 days.- T: Time in milliseconds returned by the function.
-
micros(-T)
: It returns a number representing the number of microseconds since the program called one of the AgPi functions. It returns an unsigned 32-bit number which wraps after approximately 71 minutes.- T: Time in microseconds returned by the function.
Example for LED blinking:
- Commect a LED to Raspberry Pi at GPIO pins 1 (HIGH) and 0 (LOW).
- Write the following code in a prolog file(in the working directory).
Blink_Led - Now start prolog with sudo permission(very important):
$ sudo swipl
- Consult the
platform_pi.pl
using:?- consult('platform_pi.pl').
This will load all of the Tartarus predicates. - Execute the command:
?- start_peripherals.
- Execute the following command to see the LED blink and the output of millis command on terminal.
?- start.