Skip to content

11. Output devices

Goal of the week:

  • add an output device to a microcontroller board you’ve designed and program it to do something

Again this week I will be using my UNO R3 Super Starter Kit for my small OUTPUT DEVICE projects.

I decided to use: DC motor to move a fan, LCD STANDARD for temperature and humidity detection and a buzzer with photo-resistor and button.

DC MOTOR

First of all, I tried to learn what is and how to use a DC motor. A DC motor (Direct Current motor) is the most common type of motor. DC motors normally have just two leads, one positive and one negative. If you connect these two leads directly to a battery, the motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.

The first advice I learned was to not drive the motor directly from Arduino board pins. This may damage the board so the advise is to use a driver Circuit or an IC. For this reason I used a Power Supply Module and a 9V battery.

To be more clear, the following are the components I used:

  1. Elegoo UNO R3
  2. Breadboard
  3. Integrate Circuit L293D
  4. Fan and motor (3-6 V)
  5. Jumper wires
  6. Power Supply module
  7. 9V Battery

First of all I read about the IC L293 to understand why I need to use it. The L293D chip is very flexible and allows motor control circuits to be built thanks to the H-bridge integrated inside.

It has 16 pins and can be split into two parts as it can handle more than one motor. I will only use the right side. The center pins (4-5-12-13) are connected to GND. The power supply is connected to pin 8. The motor should be connected to the Arduino’s digital pins. Depending on how the pins are set, the motor will turn in different directions. The Enable1 pin is used to turn the motor on or off and by applying a PWM signal the motor speed can be controlled. The other two pins control the direction (set to LOW or HIGH).

In particular: + M1 PWM –> Connect this to a PWM pin on the Arduino board. (In my case pin 5). The output is an integer value between 0 and 255, 0 will indicate off, 128 half speed and 255 full speed. 128 half speed and 255 full speed. + M1 direction 0/1 and M1 direction 1/0 –> Connect these two to two digital pins on the Arduino. (In my case 4 and 3). One of the pins should be set to HIGH and the other to LOW, so the motor will turn in one direction. direction. Reversing the outputs to LOW first and HIGH second will cause the motor to turn in the opposite direction.

I also connected the motor to the IC pins.

At the end, I wrote the C code on Arduino IDE:

And this was the result:

LCD

The next output device I used was a LCD standard (16x2). I read something on (this tutorial)[https://www.allaboutcircuits.com/projects/interface-an-lcd-with-an-arduino/#:~:text=You%20can%20easily%20interface%20a,to%20provide%20a%20user%20interface.&text=Liquid%20crystal%20displays%20(LCDs)%20are,and%20many%20other%20electronic%20devices]. My goal was to watch the temperature and humidity values on the screen. So to clarify we use an LCD to provide a user interface.
First of all I learn something about the screen itself and how to connect it on the breadboard. It’s easy but you need to stay really concentrate because you need lots of wires.

This display has LED backlighting and can show two lines of 16 characters each. On the display you can see a small rectangle for each character and the pixels that form each character. The display is blue and white and is designed to display text only. Eight of the pins are data lines (pins 7-14), two are for power and ground (pins 1 and 16), three are used to control the operation of LCD (pins 4-6), and one is used to adjust the LCD screen brightness (pin 3, in my case connected to a 10K potentiometer). The remaining two pins (15 and 16) power the backlight.

In my fist attempt I use a simple “hello word” code to see if everything was well connect, and this was the result:

After that I tried to use the LCD to measure some values thanks to a DHT11 sensor (see (week 10)[http://fabacademy.org/2021/labs/santachiara/students/paola-delcastello/assignments/week10/] for more explanation).

This time I needed:

  1. Elegoo UNO R3
  2. Breadboard
  3. LCD 1602 Module
  4. DHT11 sensor
  5. Jumper wires
  6. Potentiometer 10K

I used this code:

And this was the result:

BUZZER

At the end I tried to replicate a project I did one year before for a university exam. We didn’t have an Arduino so I wrote the code on Tinkercad. The goal of the assignment was to use a buzzer, a button and a sensor (photoresistor). Based on the average of the sum of the values perceived by the photoresistor and received on the LCD screen, the buzzer repeated two different melodies.

What I needed:

  1. Elegoo UNO R3
  2. Breadboard
  3. LCD 1602 Module
  4. Active Buzzer
  5. Jumper wires
  6. Photoresistor
  7. Button
  8. Resistors

The code was the following:

And this was the result:

DESIGN THE BOARD

The next step was design with Eagle the board with the DC MOTOR

MILLING AND SOLDERING

I milling the board, prepared my Bill of materials and soldered my PCB.

For programming the sensors, check out the final project page, section “programming”, where I used the DC Motor to get my BiOven fans moving.


Last update: June 28, 2021