OUTPUT DEVICES

An output device is any peripheral that receives data from a computer, usually for display, projection, or physical reproduction.


CHECK LIST

Group assignment

  • Measure the power consumption of an output device
  • Document your work (in a group or individually)

Individual assignment

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

GROUP ASSIGNMENT

Find out the details of our common work al ZOI Here.


previous attempts using arduino

In order to progressively understand the development of the code, the connections and other steps for this subject, I started doing some tests with Arduino.

Humidity and temperature sensor on a LCD

I started with some practice on the Arduino. The LCD I used is a 16×2 which means that the LCD has 2 lines, and can display 16 characters per line. Therefore, a 16×2 LCD screen can display up to 32 characters at once. It is possible to display more than 32 characters with scrolling. The data sheet of this component can be found in the next link:
LCD 16x2 data sheet
*Also, the pictures and further information was taken from Circuit basics
The pinout used for this is:

The connections needed for the arduino are:

I had no headers to try this at home so I decided to solder the lcd pins, it looks messy and took a time to do it by finally I managed to se the data on the screen which was what I was looking for.

The resistor used sets the backlight brightness. A typical value is 220 Ohms, but other values will work too. Smaller resistors will make the backlight brighter. The potentiometer is used to adjust the screen contrast.

Then the fun part, send text to the screen, for this I used the following code to try.


#include 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
lcd.begin(16, 2);
lcd.print("hello, world!");
}

void loop() {
}

What you can see on the screen:

The code to show the results of the humidity and temperature sensor:


                                    
#include 
#include 
                                       
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
                                       
dht DHT;
                                        
#define DHT11_PIN 7
                                        
void setup(){
lcd.begin(16, 2);
}
                                        
void loop(){
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(0,0); 
lcd.print("Temp: ");
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(DHT.humidity);
lcd.print("%");
delay(1000);
}

You can see the results on the next video:


TESTING MY BOARD - version 1.0

Decided to try my inputs board with output components. More details about this board can be found on my week 10 site.

LCD

Connect the pins from the sensor to the board, remember to be aware that the pins of the Arduino are different than the ones on the micro.

*This image was taken from Geek factory
First have to download and install the LCD I2C library avaliable on the next link:
Liquid Crystal I2C
I used the code from the following site, and this is the result after a few modifications:
Hello World from John Rickman


//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include 

LiquidCrystal_I2C lcd(0x27,A4,A5);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
    lcd.init();                      // initialize the lcd 
    // Print a message to the LCD.
    lcd.backlight();
    lcd.setCursor(3,0);
    lcd.print("Hi Daniela!");
    lcd.setCursor(2,1);
    lcd.print("Rainy  Saturday!");
    lcd.setCursor(0,2);
    lcd.print("saturday");
    lcd.setCursor(2,3);
    lcd.print("Daniela");
}


void loop()
{
}
                        

RGB Led

To start make sure about the module pinout, I found this picture to show this, because the wrong connections could cause color confusions in te result :

Connect the pins to the board:

  • GND - GND
  • Red - Pin 11
  • Green - Pin 9
  • Blue - Pin 10

*Previous diagram and information was taken from: Arduino modules info
Used the following code to turn on the LED, which I found interesting and fun to watch.
RGB Leds Arduino

/*
Adafruit Arduino - Lesson 3. RGB LED
*/
    
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
    
//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE
    
void setup()
{
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(bluePin, OUTPUT);  
}
    
void loop()
{
    setColor(255, 0, 0);  // red
    delay(1000);
    setColor(0, 255, 0);  // green
    delay(1000);
    setColor(0, 0, 255);  // blue
    delay(1000);
    setColor(255, 255, 0);  // yellow
    delay(1000);  
    setColor(80, 0, 80);  // purple
    delay(1000);
    setColor(0, 255, 255);  // aqua
    delay(1000);
}
    
void setColor(int red, int green, int blue)
{
    #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
    #endif
    analogWrite(redPin, red);
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);  
}
                                

                         

You can find a lot of examples to work with, here is another one I tryed and found interesting.
RGB Leds Arduino


/*

THREE COLOUR (FULL COLOUR) LED

Revised: 20th October 2018
By Seb Jensen

RED GOES TO D11
GREEN GOES TO D9
BLUE GOES TO D10
GROUND GOES TO GROUND

*/

int redpin = 11; //select the pin for the red LED
int bluepin =10; // select the pin for the  blue LED
int greenpin =9;// select the pin for the green LED
    
int val;
    
void setup() {
    pinMode(redpin, OUTPUT);
    pinMode(bluepin, OUTPUT);
    pinMode(greenpin, OUTPUT);
    Serial.begin(9600);
}
    
void loop() 
{
for(val=255; val>0; val--)
    {
    analogWrite(11, 255);
    analogWrite(10, 0-val);
    analogWrite(9, 0-val);
    delay(1); 
    }
for(val=0; val<255; val++)
    {
    analogWrite(11, 255);
    analogWrite(10, 0-val);
    analogWrite(9, 0-val);
    delay(1); 
    }
    Serial.println(val, DEC);
}
                        


DESIGNING MY OUTPUTS BOARD

Based on the inputs week, I simplified the design and planned it work with the following components:

  • RGB
  • Fan
Worked on the schematic and board design and this is the result:

This are the components I used:
  • Button - x1
  • ATMEGA328P-AU - x1
  • Terminal block - x1
  • Pinheads - x24
  • C 100nF - x2
  • R 10k - x1
  • C 1uF - x1
  • C 10uF - x1
  • C 22pF - x2
  • R 499 - x1
  • Green led - x1
  • 16MHZ crystal - x1
  • Fan - x1
  • LED RGB - x1
Added some text to try it for my final project. And generated 3 files to produce the board, one for the traces, one for the text and a final one to cut out the board. For the traces I used ULP directly from Eagle, you can download the tap file
Here:

For the contour and text I used mods with the following parameters, first image for the text, second one for the contour:

Once the code is ready I used Gcode simmulator to make sure everything is right.

Some pictures of the milling process:

Used a dremel to make the holes, checked the contiunity, and welded the components.

Files

board, schematic - Eagle
traces png
contour png
text png
Gcode

Programming

The first step is to burn the bootloader. Details about this process can be found on my Input devices week but here I leave some pictures of the process:

The first test was with the rgb led, this was the code I used:


/*
Adafruit Arduino - Lesson 3. RGB LED
*/
    
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
    
//uncomment this line if using a Common Anode LED
//#define COMMON_ANODE
    
void setup()
{
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(bluePin, OUTPUT);  
}
    
void loop()
{
    setColor(255, 0, 0);  // red
    delay(1000);
    setColor(0, 255, 0);  // green
    delay(1000);
    setColor(0, 0, 255);  // blue
    delay(1000);
    setColor(255, 255, 0);  // yellow
    delay(1000);  
    setColor(80, 0, 80);  // purple
    delay(1000);
    setColor(0, 255, 255);  // aqua
    delay(1000);
}
    
void setColor(int red, int green, int blue)
{
    #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
    #endif
    analogWrite(redPin, red);
    analogWrite(greenPin, green);
    analogWrite(bluePin, blue);  
}
                        

This video shows the result:

Next thing we tryed is to connect the fan, to do this it was necessary and external power supply and a relay, the following picture shows the connections we made (Diego helped my throughout this process).


We used an external relay, this video shows the result:

This is the code we used:


// constants won't change
const int RELAY_PIN = 3;  // the Arduino pin, which connects to the IN pin of relay

// the setup function runs once when you press reset or power the board
void setup() {
    // initialize digital pin A5 as an output.
    pinMode(RELAY_PIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    digitalWrite(RELAY_PIN, HIGH); // turn on fan 5 seconds
    delay(5000);
    digitalWrite(RELAY_PIN, LOW);  // turn off fan 5 seconds
    delay(5000);
}

                        
Also, this web site was usefull to generate the code and to follow the connections instructions Arduino get started
This Arduino file can be found Here


PROGRAMMING WITH THE ISP PROGRAMMER

For this board I tryed connecting an rgb leb and programmed it using the USBtinyISP. First make all the connections from the programmer to the board, then connected the led and uploaded the code using Arduino IDE.
In Arduino IDE remember: Tools> Programmer >USBtinyISP. Then in Sketch > Upload using programmer.

At first try something was not working, I received this message that indicates to double check the connections. So I realized that it was better to connect MISO directly from the first pin (removing the bridges on the back), and same for the reset, as shown bellow.


Another important thing to notice is that the RGB led used for red the same pin used as MOSI, so I first made to connections just to upload the code and then connected the led.
Tryed again to upload the code and this is the result:

Here you can Download the code I used.
And I encourage you to visit this very helpufull sites which help me to go though with the code:

I also tried sending some text to an LCD, with my board from inputs week, same process in the Arduino IDE, and this is the result:

Here you can Download the code I used.
This site was very helpufull to go though with the code:
surtr technologysimple use write from serial monitor.


UNDERSTANDING ICSP (in circuit serial pprogramming)

By having a new microcontroller (in the case of my board, the ATMega 328), it comes "factory clean", that is, it does not have any program loaded, for this reason it is necessary to burn the Bootloader, which is a boot manager so that the different sketches can be programmed using the Arduino software (Arduino IDE)

UNDERSTANDING ICSP PROGRAMMING (in circuit serial pprogramming)

ICSP programming is the ability of some devices to be programmed while installed in a complete system rather than requiring a chip that has been pre-programmed before being installed in the system. Generally the chips that support ISP allow to generate the programming from the conventional power line and communicate through a serial protocol , which means that data is sent in series.
ICSP is a direct programming method for the microcontrollers of AVR, PIC and others. As they are soldered to the board, is necessary an ICSP connector and and a programmer to program them, that's when our USBtinyISP comes into the picture.

To upload any sketch it is necesarry to be aware of the pins required, in the case of the ATMega328P used in my boards, this is the detail:
The pins required in the case of the ATMega328P are the following:

* This information and images were taken from:
Aprendiendo Arduino, ICSP.
Circuit digest, serial communication protocols.


Final thoughts about this week

This is still very challenging for me, I still have to try other sensors and keep working on my final project. So far, Im trying to imporve my understanding on programming and coding, but is still a long road to go. Diego has been really helpfull with this assignment and has guided me through this process. At this point I can understand the code that others have created but it is still very difficult for me to generate a new one.