Skip to content

9. Output devices

At the begining, we have done the group assignement here. My part is the LED part.

Hero shot

1. Design

At first, I didn’t understand how we could do this week and what the expected results were. My aim was to make an LED light up in RGB, controllable by diode type, and to be able to turn a DC motor for a fan.

I used KiCad and with the help of Luc Hanneuse and the documentation from agrilab I managed to make this circuit:

The lower right-hand section is dedicated to the LEDs and the left-hand section is dedicated to the motor. I’ve had a few problems with the LEDs, because of their basic design: the LEDs can either have 3 12V inputs and a GND, or 3 GNDs and one 12V input. Depending on the type of LED, I have to use N-type transistors (3 GND) or P-type transistors (3 12V supply). It’s with these transistors that I’m going to control the lighting of the LEDs.

For the motor, the circuit is simpler, with a transistor to control the current, and a capacitor and a diode to manage the flux when the motor stops.

As my circuit is powered by 12V, I also need to transform this 12V into 3.3V to power my microcontroller. Information on the voltage can be found in the datasheet. It says that the power must be supplied via the VIN and GND ports, but these ports are on the underside of the board, which makes them impractical. To overcome this problem, we tested using a power supply to power the microcontroller via the 3V3 and GND ports on the pins. This solution seems to work, so we’re going to stick with it.

To ensure good connectivity and power transmission without frying the tracks, I’ve widened them to 0.8mm. Initially, I had put them at 1mm but this size didn’t allow me to make bridges with 0h resistors.

2. Tests and results

There are a few problems on my board that cause it not to work:

  • The capacitors before and after the transformer should not be on the circuit but in shunt. So I had to add O ohm resistors and move them so that they were between 12v and GND.
  • My diode was in the wrong way

Despite this improvement, I can only get the vent to work because of a poor choice of transistor. I chose the P transistor when I only had N-compatible LEDs (I’ll find out at the end). So here’s the vent working:

And this is the code I use :

const int motorPin = 26; 
const uint transistorPin = 27;

void setup() {
  pinMode(motorPin, OUTPUT);
  gpio_init(transistorPin);
  gpio_set_dir(transistorPin, GPIO_OUT);
}

void loop() {
  analogWrite(motorPin, 255);
  gpio_put(transistorPin, 1);
  delay(4000);
  gpio_put(transistorPin, 0);
  delay(4000);
}

The files

Here you can find the KiCad board file

Here you can find the KiCad scematic file

Here you can find the INO file