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.

Posted on

Wiring Guide for the 3.5″ GearBest Screen with 5V Mod

I get a lot of wiring inquiries about the 3.5″ GearBest Screen so I decided to make one.

Most of these 3.5″ screens are intended for 12v power supply. The 12V input goes to a chip called XL1509 and converts that to 5V. Like any DC to DC converter there’s always going to be wasted power as a result of the conversion. This is the reason why I highly recommend that you do the 5v mod eventhough the screen works if you feed it with 5v without the need for any modification.

To make the connections more reliable let’s remove the Female JST connector..

..just be careful not to lift the contact pads which I’ve mistakenly done here. Luckily the board has two video connections which are AV1 and AV2. I will be using the AV1.

Cut the cable that came with it and solder the wires directly to the board. In order to do the 5V mod, you just solder the RED wire directly to the XL1509’s Pin 2 or to the SS24’s cathode pin which is easier to solder to. The other end of the RED wire goes to your 5v power supply of course (PowerBoost 5v output). Since the Raspberry Pi only requires just one video connection, solder the YELLOW wire to the Pi’s TV connection. Join the WHITE and BLACK wire and solder them directly to the GND pad on the screen board. The WHITE(GNDTV) wire goes to the GND beside the TV pin on the Pi while the BLACK wire goes to your normal powerboost’s GND output.

Yep, That’s it!

Posted on

RetroPie: Disable Builtin Sound Card and Enable USB Audio Only

Edit the file /boot/config.txt and comment the line:

#dtparam=audio=on

Now edit the file /etc/modprobe.d/alsa-blacklist.conf and add:

blacklist snd_bcm2835

Finally edit the file /lib/modprobe.d/aliases.conf and comment the line:

#options snd-usb-audio index=-2

Or if you just want the USB Audio to be your primary sound device.

Posted on

Raspberry Pi: Downmixing From Stereo to Mono Sound Output

First, let’s choose which device to use. Enter the command cat /proc/asound/modules to list all available sound devices whether it’s a PWM audio or USB sound device.

The command you just entered should output something like:

0 snd_bcm2835 << this is the PWM audio I configured on GPIO18 & GPIO13.
1 snd_usb_audio << this is my USB sound device.

Enter the command sudo nano /etc/asound.conf and paste the following code:

Change the N on the line slave.pcm "hw:N" to  the number that corresponds to the audio device you want to use. I will be using my USB audio device so mine should read slave.pcm "hw:1".

The above code uses both left and right audio input to output to LEFT channel. If you want the output to the RIGHT then you can just edit the line 8 – 14 to:

# Copy both input channels to output channel 1 (Right).
0.1 1
1.1 1
# Send nothing to output channel 0 (Left).
0.0 0
1.0 0

Restart ALSA by sudo /etc/init.d/alsa-utils restart or you can reboot your Raspberry Pi using sudo reboot.

Posted on

Raspberry Pi: Test Sound Output

If you’re wondering how to test the left and right audio channel of your Raspberry Pi whether using an external USB sound device or the builtin audio you’ve come to the right place.

Connect to your Raspberry Pi via SSH or open the Terminal application. The simplest way to test the sound is to use the speaker-test command. Enter the following to test sound from your default configured audio device.

You should hear an alternating sound coming from your left and right speakers.

If you’re using a USB sound device you first need to check its device id/number.

Enter:

Output:

Then use speaker-test -c2 -twav -l7 -D plughw:N,0 replacing N with the number before snd_usb_audio. Like this:

Output should the same as the picture above and alternating sound from left and right audio from your speakers.

Using omxplayer to test mp3 or wav sound file

The above command will auto-detect or use any default configured audio device. Otherwise, if you want to test your USB Sound device enter the following command with 1 as the device number: