Output device

For this weeks assignment I had to add a output device to my own designed board and make it do something.

I wanted to add a liquid crystal display to my board to use it as a hud for my final project. The board I designed has a atmega328p chip which is the same as the arduino uno, so I mostly used schmeatics of arduinos to connect the display. I have connected the display after following table. Note: If you dont have a potentiometer just connect pin3 of the display to ground otherwise the display won't work.

My board design looks like this.

I will display the authentication process on the using the rfid scanner as an input. You can check the input in my input devices assignment. The display works as following, I set the cursor on a place I want to write by defining the x and then the y axis (setCursor(x,y)). Here I can simply start printing an string using the ld.print() function. Overwriting this print with another one will hide the first print. Also it is possible to use the clear() function which will delete everything displayed.


		
		#include                                      //required to use lcd
#include 

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;   //setting the pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);                    //setting display up
bool auth;
int value=70;
const int flexPin = A0;
const int motor=10;
void setup() {
  lcd.begin(20,4);                                            //begin display with size (lenghtxheight)
  Wire.begin(11);
  Wire.onReceive(receiveEvent);
  // put your setup code here, to run once:
  
  
  Serial.begin(115200);
  pinMode(motor,OUTPUT);
}

void loop() {
  //delay(100);

  value = analogRead(flexPin);									//read value of flex sensor
  
  value = map(value, 150, 254, 300, 150);						//map value of flex sensor from 150 to 300
  if(auth == true){
    Serial.println("Successfully Authenticated!");
    lcd.setCursor(2,0);                                        //cursor on the second pixel of first line
    lcd.print("Successfully  ");                                 //display string
    lcd.setCursor(2,1);                                        //cursor on the second pixel of second line
    lcd.print("Authenticated!");                               //dsiplay string
  gas();
  }
  else if(auth == false){
    Serial.println("Authentication required!");                //do the same thing again to replace the first lcd print
    lcd.setCursor(2,0);
    lcd.print("Authentication");
    lcd.setCursor(2,1);
    lcd.print("required!     ");
    
    }
}

void receiveEvent() {
  while (0 < Wire.available()) {
    auth = Wire.read();
  }
  Serial.println(auth);
  
  //Serial.println(value);
  // put your main code here, to run repeatedly:
 
}

void gas(){
  analogWrite(motor, value);
  }
	

The display will change from "Authentication required" to "Sucessfully authenticated!"

YOUTUBE LINK

I have also designed another board to attach a pressure sensor to an brushless motor. I have used an brushless motor as an output device which is controlled with an analoig pressure sensor. You are welcome to check my input device assignment, it contains an input and an output device together.