0% found this document useful (0 votes)
10 views3 pages

6 - 7 - 8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

6 - 7 - 8

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

-----------------------------exp 8--LCD

1----------------------------------------------------------------------------------
---------------------

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on

// Print a message on both lines of the LCD.


lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("Hello world!");

void loop() {
}

--------------------------------------LCD
2----------------------------------------------------------------------------------
-----------------------

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20, 16, 2);

void setup()
{
lcd.init();
lcd.backlight();
}

void loop()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Hello");
lcd.setCursor(0,1);
lcd.print("Geek");

delay(100);
}

-----------------------------------------------exp7--------
servo------------------------------------------------------------------------------
----------------------

#include <Servo.h>
Servo myservo;

int pos = 0;
void setup() {
myservo.attach(9);
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) {
myservo.write(pos);
delay(15);
}

for (pos 180; pos >= 0; pos -= 1) {


myservo.write(pos);
delay(15);
}
}

------------------------------------------------------
DC---------------------------------------------------------------------------------
-----------------------

int motorPin = 9;
void setup() {
pinMode (motorPin, OUTPUT);
Serial.begin(9600);
while (! Serial);
Serial.println("Speed 0 to 255");
}
void loop() {
if (Serial.available()) {
int speed = Serial.parseInt();
if (speed >= 0 && speed <= 255) {
analogWrite(motorPin, speed);
}
}
}

-------------------------------------------------exp6-
LDR--------------------------------------------------------------------------------
-----------------------------------

const int ledPin = 12;


const int buzzerPin = 13;
const int ldrPin = A0;
void setup () {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ldrPin, INPUT);
}

void loop() {
int IdrStatus analogRead(ldrPin);

if (ldrStatus >= 400) {


tone(buzzerPin, 100);
digitalWrite(ledPin, HIGH);
delay(100);
no Tone (buzzerPin);
digitalWrite(ledPin, LOW);
delay(100);

Serial.println("ALARM ACTIVATED");
}
else {
noTone (buzzerPin);
digitalWrite(ledPin, LOW);
Serial.println("ALARM DEACTIVATED");
}
}

You might also like