I build several Raspberry Pi robots over the last years. All of them are using a L298N H-Bridge as motor controller. To generate a perfect PWM signal for the motor controller I decided to generate the PWM signal outside the Raspberry Pi. With a special controller which only generates the PWM signal. With such a controller I will get an extremely accurate signal then the Raspberry Pi could generate it. The best solution would be a chip on a board with an I2C bus. I searched for such a solution and found a servo controller board with a PCA9685 chip. The PCA9685 chip is perfect for this kind of job. Besides controlling the speed of DC motors with a L298N H-Bridge my setup should be able to set the brightness of a LED strip as well.

I connected a short LED strip to the out connector of the L298N H-Bridge. It is a 12V LED strip with white LEDs. It is not an RGB LED strip.

The picture below shows my setup with a PCA9685 servo controller and a L298N H-Bridge as LED driver.

Raspberry Pi - LED dimmer

Raspberry Pi – LED dimmer

The picture below shows the LED dimmer active. The Python program I developed is available for free in the download section.

Raspberry Pi - LED dimmer active

Raspberry Pi – LED dimmer active

List of Components:

Raspberry Pi 3 Model B

Vilros Raspberry Pi 3 Ultimate Starter Kit
Preis: EUR 79,99
1 neu von EUR 79,990 gebraucht
Get Your First Taste Of raspberry Pi with this Ultimate Starter Kit from Vilors.

This Is the Raspberry Pi 3 Model B Ultimate Starter Kit From Vilros
It includes the new Raspberry Pi 3 Model B (Latest Version Released on 02/29/2016)

Raspberry Pi 3 Model B Technical Specifications:
• Broadcom BCM2837 64bit ARMv8 Quad Core Processor powered SingleBoard Computer running at 1.2GHz
• 1GB RAM
• BCM43143 WiFi on board
• Bluetooth Low Energy (BLE) on board
• 40pin extended GPIO
• 4 x USB2 ports
• 4 pole Stereo output and Composite video port
• Full size HDMI
• CSI camera port for connecting the Raspberry Pi camera
• DSI display port for connecting the Raspberry Pi touch screen display
• MicroSD port for loading your operating system and storing data
• Upgraded switched Micro USB power source (now supports up to 2.4 Amps)

Kit Content
Raspberry Pi 3- Model B 1GB
Raspberry Pi Enclosure Case (Clear)
32GB Micro SD Card pre-loaded with NOOB
SD Card Adapter
5-Foot EU Micro USB Power Supply 2500 mA
High Quality HDMI Cable
400-Tie-point breadboard (white)
65 Jumper Wires -- 45 pcs--100mm, 10 pcs--150mm, 5 pcs--200mm, 5 pcs--250mm
GPIO Ribbon Cable with Breakout board
45 X 330 Resistors
45X 10K Resistors
2X Big 12mm Buttons
Heatsink for Raspberry Pi - Set of 2 Heat Sinks
10X Yellow LED
10X Red LED

NOTE: The SD Card may appear to be a smaller capacity when you test it on your computer due to partitions placed on the card once the software is installed.

WEEE-Reg.-Nr. DE 29056374

I2C Level Converter from Adafruit

ADAFRUIT INDUSTRIES 757 LOGIC LEVEL CONVERTER, 4CH, ARM DEVELOPMENT BOARD (1 piece)
Price: $7.33
10 new from $6.990 used
ADAFRUIT INDUSTRIES 757 LOGIC LEVEL CONVERTER, 4CH, ARM DEVELOPMENT BOARD

L298N H-Bridge as motor driver or LED driver

L298N DC and Stepper Motor Dual Drive H-Bridge Module - 6V to 35V by Make Nation
Preis: EUR 8,80
1 neu von EUR 8,800 gebraucht
2 DC motor/ 4 coil dual phrase stepper motor output;4 pull up resistor switch;Power selection switch;Heavy load Heat sink;FWD protection

PCA9685 servo Controller

Adafruit 16-Kanal 12-Bit PWM/Servo-Treiber - I2C-Schnittstelle - PCA9685
Preis: EUR 19,89
1 neu von EUR 19,890 gebraucht
Sie möchten einem coolen Roboter vielleicht ein hexapod Walker, oder vielleicht auch nur ein Kunstwerk mit vielen beweglichen Teilen. Oder vielleicht wollen Sie fahren viele LEDs mit präzise PWM-Ausgang. Dann erkennt man, dass Ihre Mikrocontroller eine begrenzte Anzahl von PWM Ausgänge hat! Was nun? Sie könnte aufgeben oder bekommst du nur diese handliche PWM und Servo-Treiber-Ausbruch.
Als wir sahen, dass dieser Chip, erkannten wir schnell was ein ausgezeichnetes Add-on dies wäre. Mit nur zwei Pins, Steuern Sie 16 freilaufenden PWM Ausgänge! You can even chain up 62 breakouts to control up to 992 PWM outputs (which we would really like to see since it would be glorious)
Es handelt sich um eine i2c-gesteuerte PWM-Treiber mit einer eingebauten Uhr. Dass bedeutet, dass im Gegensatz zu der Familie der TLC5940 Sie nicht benötigen ständig senden binden Ihre Mikrocontroller, die völlig frei laufen Signal!
Es ist 5V konform, das heißt, Sie können steuern, wie es von einem 3,3V Microcontroller und noch sicher fahren bis 6V Ausgänge (das ist gut für wann Sie steuern weiß möchten oder blaue LEDs mit 3.4 + weiterleiten Spannungen)
6-Adresse wählen Sie Stifte, damit können Sie bis zu 62 davon bei einem einzigen i2c-Bus insgesamt 992 Ausgänge - Draht, die ist eine Menge von Servos oder LEDs
Einstellbare Frequenz bis zu ca. 1,6 KHz PWM
Auflösung von 12 Bit für jeden Ausgang - für Servos, das heißt über 4us Auflösung bei 60Hz Aktualisierungsrate
Konfigurierbare Push-Pull- oder Open-Drain Ausgang
Ausgang aktivieren Pin zu schnell deaktivieren alle tEr gibt
Wir dieser schönen Chip in einem Breakout-Board mit ein paar netten Extras eingewickelt
Anschlussblock für Power-Eingang (oder die 0,1" Ausbrüche können Sie auf der Seite)
Verpolungsschutz am Eingang terminal block
Grüne Energie-gut-LED
3-Pin-Anschlüsse in Gruppen von 4, so dass Sie auf einmal 16 Servos anschließen können (Servo Stecker sind leicht

Software PCA9685

First you need to install the Adafruit library to control the PCA9685 servo controller. This servo controller will generate the PWM signal to dim the LED strip.

Adafruit PCA9685 library

To install the Adafruit library for the servo controller you have to execute some commands in the terminal window. For more details visit the GitHub page from Adafruit or just execute the following commands each after the other. I was connected via SSH with a terminal window on my Raspberry Pi for the installation process. I used for my setup the Raspbian Jessie.

Adafruit GitHub URL: https://github.com/adafruit/Adafruit_Python_PCA9685

Commands to install the Adafruit PCA9685 library:

Command: sudo apt-get install git build-essential python-dev

Command: cd ~

Command: git clone https://github.com/adafruit/Adafruit_Python_PCA9685.git

Command: cd Adafruit_Python_PCA9685

The next command has to be executed in the “Adafruit_Python_PCA9685” folder.

Command: sudo python setup.py install

After installing the library and wiring everything up you could check if the servo controller is available on the I2C bus. Execute the following command and you should see the PCA9685 servo controller with the address 40 or a different address.

Command: sudo i2cdetect -y 1

Now you schould see the servo controller with the address 40 on your I2C bus.

i2c detect bus result

i2c detect bus result

I wrote a small Python program to control the brightness of the LED strip with a PCA9685 and a L298N H-Bridge as LED driver.

Download: Raspberry Pi – LED dimmer

Video:

The video shows a short LED strip which is connected to the L298N H-Bridge. The PCA9685 generates the PWM signal and controls the H-Bridge.

(Visited 228 times, 1 visits today)