Professional Documents
Culture Documents
02 133212 093 11478092851 16122023 105636pm
02 133212 093 11478092851 16122023 105636pm
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>
void setup() {
// Set up the number of columns and rows on the LCD
lcd.begin(16, 2);
void loop() {
// Your continuous loop code (if any)
}
Simulation: