Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

TASK 1

TASK 2
2)
1) Code:
int buttonPin = 13;
int relayPin = 3;
// Variables will change. int buttonState = 0;
void setup( )
{
pinMode(relayPin, OUTPUT); pinMode(buttonPin, INPUT);
}
void loop( )
{
byte buttonState = digitalRead(buttonPin);
// Check if the Push Button is Pressed.
if (buttonState == HIGH)
{
digitalWrite(relayPin, HIGH);
}
else
{
digitalWrite(relayPin, LOW);
}
}

Simulation:
2) Code:
#include <LiquidCrystal.h>

// Define the LCD pin mapping


const int rs = 12;
const int en = 11;
const int d4 = 5;
const int d5 = 4;
const int d6 = 3;
const int d7 = 2;

// Create an LCD object


LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// Set up the number of columns and rows on the LCD
lcd.begin(16, 2);

// Display a welcome message


lcd.setCursor(0, 0);
lcd.print("Embedded Systems");
lcd.setCursor(0, 1);
lcd.print("BEE - 5A/5B");
delay(2000); // Display the message for 2 seconds
lcd.clear(); // Clear the display
}

void loop() {
// Your continuous loop code (if any)
}

Simulation:

You might also like