Che Assignment (2)
Che Assignment (2)
PROGRAM:
#include <Keypad.h>
#include <LiquidCrystal.h>
};
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()
{
switch (key)
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
PROGRAM:
#define sensorPin = A0
void setup()
{
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(11,OUTPUT);
}
void loop()
{
int reading = analogRead(A0);
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