6 - 7 - 8
6 - 7 - 8
1----------------------------------------------------------------------------------
---------------------
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on
void loop() {
}
--------------------------------------LCD
2----------------------------------------------------------------------------------
-----------------------
#include <LiquidCrystal_I2C.h>
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);
}
------------------------------------------------------
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--------------------------------------------------------------------------------
-----------------------------------
void loop() {
int IdrStatus analogRead(ldrPin);
Serial.println("ALARM ACTIVATED");
}
else {
noTone (buzzerPin);
digitalWrite(ledPin, LOW);
Serial.println("ALARM DEACTIVATED");
}
}