Posted on

How To Add Brightness Control For The 3.5″ GearBest Screen

This guide might also work on any screen that we use for building our Game Boy Zero as long it uses the CL6201 LED driver IC with the “7001” label on it.

I will be using a Raspberry Pi Zero for this tutorial but any Arduino/Atmel chips with PWM pins can also be programmed to do the job. I have actually tested it with an attiny13a and it works just fine.

Hardware

Before we start, follow the Wiring Guide for the 3.5″ GearBest Screen with 5V Mod. Then start by soldering a wire from the CL6201’s EN pin 4 to the Pi Zero’s GPIO19 pin. The CL6201 Datasheet says that the EN pin can be used to adjust the brightness by connecting it with a PWM square wave signal between 100Hz and 100KHz. That means with the Raspberry Pi’s capability to produce PWM signal we can control the brightness with it.

For the control buttons let’s use two tactile buttons for increasing and decreasing the brightness. Wire the buttons like this:

Software

You can write a program in Python or C to do the PWM routine but let’s keep it simple by using a progam called pigpio and write a simple python to just call it. Login to your Raspberry Pi and install the program by following the instruction at abyz.me.uk/rpi/pigpio/download.html.

Testing

We are now ready to test the program. Type the command sudo pigpiod to load the pigpio daemon. Now we can test it with the following command format:

pigs p GPIO DUTYCYCLE(0-255)

GPIO is the gpio pin we want to use which is GPIO19 and DUTYCYCLE is what controls the brightness.

Example:

pigs p 19 50

The above code should dim the screen. Try experimenting with other DUTYCYCLE values from 0-255.

Now for the actual buttons to control the brightness I wrote a simple python to call the pigpio program. Copy the code below and paste to a new file with .py extension. You can just name it as brightness_controller.py if you want.

Run it by typing the command  python brightness_controller.py. Press each of the buttons and it should increase or decrease the brightness on the screen.

Here’s a demo:

That’s it! Let me know in the comment below if this works for you.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.