I'm just having fun with Raspberry Pi and testing some components.
In this little project I've joint a low-cost RGB LED strip, 3 Keyes MOSFET modules 140c07 and a HC-SR04 ultrasonic sensor. The idea is to change the color temperature of the LED strip from blue to red based on the distance measured by the sonar. If you're near to the sensor, the LED strip will become totally red, but if you go away, the LED strip will incrementally become more and more blue, turning off red consequently.
I developed the Colordistance project using Node.js, because it's a computer language I want to learn. So I used this project as a playground to increase my Node.js skills. Don't hate me.
WiringsI've wired the sonar HC-SR04 using this good guide that show us how to implement the voltage divider on a circuit.
The IRF520 MOSFET module does have the advantage of providing more power which may be why you want to use it. Anyhow connect V+ and V- to your LED strip. Connect VIN to the LED strip power supply +Ve. Connect GND to the LED strip power supply -Ve. (12V)
Connect VCC to a Pi 3V3 pin (pins 1 or 17). Connect GND to a Pi ground (say pin 6) and connect STG to a Pi GPIO (say 4 on pin 7). To turn on the LED strip (full luminosity), set GPIO 4 high. To turn off the LED strip, set GPIO 4 low. To control the luminosity of LED strip, send PWM pulses on GPIO 4.
A PWM pulse just means switching the GPIO rapidly on and off, varying the ratio of on to off to control the intensity.
Comments