0% found this document useful (0 votes)
8 views

Che Assignment (2)

Uploaded by

Nishitha P
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Che Assignment (2)

Uploaded by

Nishitha P
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

CHE-ASSIGNMENT

NAME : Nishitha penagaluru


ROLL NUMBER : CH.SC.U4CSE24031
TASK-1
KEYPAD
AIM: displaying of odd or even numbers and fruits using lcd and keypad

MATERIALS REQUIRED: Rasberry pi , lcd,resistors,keypad,connecting


wires

PROGRAM:
#include <Keypad.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd (28, 27, 26, 22, 21, 20);


const uint8_t ROWS = 4;
const uint8_t COLS = 4;

char keys[ROWS][COLS] = { { '1', '2', '3', 'A' },


{ '4', '5', '6', 'B' },

{ '7', '8', '9', 'C' },


{ '*', '0', '#', 'D' },

};
uint8_t rowPins[ROWS] = { 13, 12, 11, 10 }; // Pins connected to R1, R2, R3, R4
uint8_t colPins[COLS] = { 9, 8, 7, 6 }; // Pins connected to C1, C2, C3, C4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS,
COLS);

void setup()
{

lcd.begin(16, 2);
}

void one()
{

lcd.clear();
lcd.setCursor(4,0);

lcd.print("1-odd");
delay(1000);

}
void two()

{
lcd.clear();
lcd.setCursor(4,0);
lcd.print("2-even");
delay(1000);

}
void three()

{
lcd.clear();
lcd.setCursor(4,0);
lcd.print("3-odd");

delay(1000); }
void four()

{
lcd.clear();

lcd.setCursor(4,0);
lcd.print("4-even");

delay(1000);
}

void five()
{

lcd.clear();
lcd.setCursor(4,0);

lcd.print("5-odd");
delay(1000);
}
void six()
{

lcd.clear();
lcd.setCursor(4,0);

lcd.print("6-even");
delay(1000);
}
void seven()

{
lcd.clear();

lcd.setCursor(4,0);
lcd.print("7-odd");

delay(1000);
}

void eight()
{

lcd.clear();
lcd.setCursor(4,0);

lcd.print("8-even");
delay(1000);

}
void nine()
{
lcd.clear();
lcd.setCursor(4,0);

lcd.print("9-odd");
delay(1000);

}
void zero()
{
lcd.clear();

lcd.setCursor(4,0);
lcd.print("0-even");

delay(1000); }
void star()

{
lcd.clear();

lcd.setCursor(0,0);
lcd.print("star/multilication");

delay(1000);
}

void hash()
{

lcd.clear();
lcd.setCursor(4,0);
lcd.print("hashtag");
delay(1000);
}

void A()
{

lcd.clear();
lcd.setCursor(0,0);
lcd.scrollDisplayLeft();
lcd.print("A- fist alphabet-apple");

delay(1000);
}

void B()
{ lcd.clear();

lcd.setCursor(0,0);
lcd.print("B- Second alphabet-banana");

lcd.scrollDisplayLeft();
delay(1000);

}
void C()

{
lcd.clear();

lcd.setCursor(0,0);
lcd.print("C-third alphabet-cherry");
lcd.scrollDisplayLeft();
delay(1000);
}

void D()
{

lcd.clear();
lcd.setCursor(0,0);
lcd.print("D- Fourth alphabet-dragon fruit");
lcd.scrollDisplayLeft();

delay(1000);

}
void loop()

{ char key = keypad.getKey();


if (key != NO_KEY)

{
switch (key)

{ case '1': one(); break;


case '2': two(); break;

case '3': three(); break;


case '4': four(); break;

case '5': five(); break;


case '6': six(); break;
case '7': seven(); break;
case '8': eight(); break;
case '9': nine(); break;

case '0': zero(); break;


case 'A': A(); break;

case 'B': B(); break;


case 'C': C(); break;
case 'D': D(); break;
case '*': star(); break;

case '#': hash(); break;


default: // Handle unexpected inputs

break;

CIRCUIT:
RESULTS: the numbers are displayed in the lcd along with its type (odd or even) and
alphabets have their fruit displayed

TASK 2:
RELAY SWITCH

AIM: To turn on or off an LED using a relay switch


connected to a temperature sensor
MATERIALS REQUIRED: Aurdino , temp sensor ,resistors, relay
switch , connecting wires

PROGRAM:
#define sensorPin = A0

void setup()
{

Serial.begin(9600);
pinMode(A0,INPUT);

pinMode(11,OUTPUT);
}
void loop()

{
int reading = analogRead(A0);

float voltage = reading*(5.0/1024.0);


float temperatureC = (voltage - 0.5)*100;

float temperatureF = (temperatureC*9.0/5.0) +32.0;


Serial.print(temperatureC);

Serial.println("degree CELCIUS");
Serial.print(temperatureF);

Serial.println("degree FARENHEIT");
delay(1000) ;//wait for 1000 millisecond(s)

if(30< temperatureC);
{

digitalWrite(11,LOW);
delay(2000);
}
if(temperatureC>30)
{

digitalWrite(11,HIGH);
delay(2000);

}}

CIRCUIT:
RESULTS: The LED turns on of the temperature is above 30 degrees

You might also like