15th November 2017

Univeral Plus Raspberry Pi HAT GPIO & PWM basics

GPIO Configuration.

Universal Plus HATs have 29 ports (except UZP Servo which is only 17 ports). All of them can be configured as OUTPUTs or INPUTs (default power on configuration).  You can change the port configuration by simple Python method call:

mode  : port type – input or output
type  : push pull (default) or open drain (this mode requires the external or internal pull-up or pull resistor)
popd  : sets the internal pull-up or pull down register
speed : speed of the GPIO port – slowing the port saves the power consumption.
state : initial state of the port (if configured as output)

To show how to configure GPIO ports I will use 8 LEDs connected to the GPIO pins via the 150Ω resistor. The anodes are connected to the GPIO ports, cathodes to the GND. GPIO ports used: 3, 4, 5, 6, 7, 9, 10 & 11. Any ports can be used but in the second part of this post I will show how to configure the PWM ports, so I have chosen the pins with the PWM functionality to do not rewire it.

The code:

And the the effect:

PWM:

 The same configuration is used as in the GPIO demo

 

LED GPIO PWM

Leave a Reply

Your email address will not be published. Required fields are marked *