TouchPhat

Hello
I was wondering if someone could help me. I have a unicorn hat hd and a touchPhat attached together on my pi.

I can program the unicorn to turn on and off at the touch of a button or on release. I am trying to get it to increase the brightness as you push a button and I can not seem to managed it.

I am not sure where exactly to start.

Any pointers welcome.

Thanks

I would think it could be done with the set brightness command, from here,
http://docs.pimoroni.com/unicornhathd/

unicornhathd. brightness ( b )[source]

Set the display brightness between 0.0 and 1.0.

Parameters: b – Brightness from 0.0 to 1.0 (default 0.5)

Yes that is correct.

But I want to move the b parameter up and down incrementally on the touch of a touchPhat button.

Which is alluding me at the moment.

Ok I’d set it to half brightness to start with.
b = 0.5

Then in the while true part of you code do something like
b = b + 0.1
if b >= 1
b = 1
unicornhathd. brightness ( b )
for one button and
b = b - 0.1
if b <= 0
b = 0
unicornhathd. brightness ( b )
for another button.

Something like that.