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.
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:
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.
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
DUTYCYCLE is what controls the brightness.
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.
import RPi.GPIO as GPIO import subprocess import time dutycycle = 255 GPIO.setmode(GPIO.BCM) BTTN_DIM = 15 BTTN_BRIGHT = 16 PWM_PIN = 19 GPIO.setwarnings(False) GPIO.setup(BTTN_DIM, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(BTTN_BRIGHT, GPIO.IN, pull_up_down=GPIO.PUD_UP) cmd = "pigs p 19 " + str(dutycycle) subprocess.call(cmd, shell=True) def btn_func(a): global dutycycle global cmd if a == 1: dutycycle = dutycycle + 25 else: dutycycle = dutycycle - 25 cmd = "pigs p 19 " + str(dutycycle) subprocess.call(cmd, shell=True) GPIO.add_event_detect(BTTN_DIM, GPIO.FALLING, callback=lambda x: btn_func(0), bouncetime=300) GPIO.add_event_detect(BTTN_BRIGHT, GPIO.FALLING, callback=lambda x: btn_func(1), bouncetime=300) while 1: time.sleep(10)
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.