Table of Contents

Analog


These functions provide access to analog pins.


Analog Write

This feature uses software-generated PWM to control the "Analog" level of a pin. It has a fixed frequency of 50Hz.

Analog.Write( pin, dutyCycle)
pin: Pin number
dutyCycle: 0 to 100

This example code will swing the analog output value up and down in a loop.

while True:
	for i in range(0, 100, 10):
		duelink.Analog.Write('L', i)
		time.sleep(0.1)

	for i in range(90, -1, -10):
		duelink.Analog.Write('L', i)
		time.sleep(0.1)

This feature works on all pins.


Analog Read

Use this function to read the analog level on a specific pin.

Analog.Read(pin)
pin: Pin number
Returns: The analog value (0-100) of the pin

This is an example code to read the analog level on pin 0 and print out to the console 10 times per second.

while True:
	x = duelink.Analog.Read(0)
	print(x)
	time.sleep(0.1)

Some pins may not support analog read. Check the hardware page for a list of supported pins.