Digital Outputs

A digital output is the most elementary feature in a microcontroller. A pin that is a digital output is set either high or low. The high value is the microcontroller's operating voltage Vcc and the low value is .

Basic Operation

In the basic operation of a digital output pin the output is either high or low.

Load the package.
Turn on the LED at pin .
Any value greater than is considered as a high value.
Turn off the LED.
Toggle the LED on or off every second.

The specification "pin"->"Digital" is equivalent to "pin"-><|"Type"->"Digital"|>.

Pulse Generation

In the basic operation, the output remained high or low for the entire duration of the sampling period. However, by specifying the output type to be a "Pulse", pulses of varying widths can be generated.

The complete specification is "pin"-><|"Type"->"Pulse",spec1->val1,|>. The following specs can be given:

SamplingPeriodthe sampling period τp
"Timer"the timer to use

Pulse specifications.

By default τp is assumed to be the same as τ which is the sampling period of sys. An explicit timer can also be specified. Otherwise it will be automatically chosen.

The output signal has the following form:

4.gif

If τp is greater than τ then it effectively is τ. If Δ is greater than τp then it effectively is τp.

A pulse of width second occurs once every seconds.
The one-second pulse occurs twice every five seconds.
Use the timer to generate the pulses.
All the following cause the LED on pin to toggle every second.