Week 11: Output devices

Assignment

In this assignment we have to add an output device to a microcontroller board and program it to do something.

For this work I worked with LCD display as an output device and I want to controll it.

I designed a circuit to use in controlling the LCD display.

controller circuit

Then made a PCB trace for the circuit.

PCB design

Finally this is the 3D view of the circuit made.

3D view

I moved on to create RML file for the designed circuit.

RML traces

And this is the outline cuts for the board.

RML outline

Here I milled the board and soldered components on it.

milling board

This is the LCD I will be using.

milled board

Here I tested the board by programming it and it worked perfectly.

soldered board

Above I used a different programmer from the one I made in the past weeks, however the are all the same its just different design.

The program I used to program the board is the following.

#include <LiquidCrystal.h>

LiquidCrystal lcd(5, 4, 3, 2, 1, 0);

int hallSensor_pin = 7;
int magnetValue;

void setup(){
    pinMode(PA1, OUTPUT);
    pinMode(PA3, OUTPUT);

     lcd.begin(16, 2);

     lcd.setCursor(1, 0);
     lcd.print("Reading Magnet");
     lcd.setCursor(0, 1);
     lcd.print("N");
     lcd.setCursor(15, 1);
     lcd.print("S");
}

void loop(){
     magnetValue = analogRead(hallSensor_pin);

     if ((magnetValue < 515 ) && (magnetValue >= 500)){
          lcd.setCursor(6, 1);
          lcd.print(" ||      ");
     }
     reading_N(magnetValue);
     reading_S(magnetValue);
}    

void reading_N(int magValue){
    if ((magValue < 500) && (magValue >= 424)){
        lcd.setCursor(1, 1);
        lcd.print("     |");
    }
    if ((magValue < 424) && (magValue >= 339)){
        lcd.setCursor(1, 1);    
        lcd.print("    |");
    }
    if ((magValue < 339) && (magValue >= 255)){
        lcd.setCursor(1, 1);
        lcd.print("   |");
    }
    if ((magValue < 255) && (magValue >= 171)){
        lcd.setCursor(1, 1);
        lcd.print("  |");
    }
    if ((magValue < 171) && (magValue >= 87)){
        lcd.setCursor(1, 1);
        lcd.print(" |");
    }
    if ((magValue < 87) && (magValue >= 0)){
        lcd.setCursor(1, 1);
        lcd.print("|");
    }
}

void reading_S(int magValue){
    if ((magValue > 516) && (magValue <= 585)){
        lcd.setCursor(9, 1);
        lcd.print("|     ");
    }
    if ((magValue > 586) && (magValue <= 658)){
        lcd.setCursor(10, 1);
        lcd.print("|    ");
    }
    if ((magValue > 659) && (magValue <= 731)){
        lcd.setCursor(11, 1);
        lcd.print("|   ");
    }
    if ((magValue > 732) && (magValue <= 804)){
        lcd.setCursor(12, 1);
        lcd.print("|  ");
    }
    if ((magValue > 805) && (magValue <= 950)){
        lcd.setCursor(13, 1);
        lcd.print("| ");
    }
    if ((magValue > 951) && (magValue <= 1023)){
        lcd.setCursor(14, 1);
        lcd.print("|");
    }
}    

The above program is for sensing the magnetic field of a permanent magnet and plot it for on the attached LCD by showing the pole is being measured.

below it is the video of the project working

Files used in designing and programming the board are found here.