Eiot Record
Eiot Record
AIM:
ALGORITHM:
PROGRAM :
To blink led
$MOD51
start: mov p1,#00
lcall delay
mov p1,#ffH
lcall delay
sjmp start
delay: mov R7,#05H
CNTUE: mov R6,#0AH
L1: djnz R6 L1
djnz R7 CNTUE
ret
RESULT:
The assembly language experiment using simulator has been done successfully.
KGiSL Institution of Technology 711722104115
EXP NO : 02 Data transfer between registers and memory
DATE :
AIM:
ALGORITHM:
PROGRAM:
$MOD51
MOV A, #02
MOVX @DPTR, A
OBSERVATION:
A= 02
RESULT:
The data transfer between registers and memory has been performed.
AIM:
To implement and perform ALU Operations using 8051 Micro controller.
ALGORITHM:
1. Move the first number to A register
2. Add the second number with A register
3. Initiate data pointer
4. Store the result
ALGORITHM:
1. Move the first number to A register
2. Subtract the second number from A register
3. Initiate data pointer
4. Store the result
ALGORITHM:
1. Move the first number to A register
2. Move the second number to B register
3. Subtract the A and B
4. Initiate data pointer
5. Store the result
ALGORITHM:
1. Move the first number to A register
2. Perform logical OR with the second number
3. Initiate data pointer
4. Store the result
ALGORITHM:
1. Move the first number to A register
2. Perform logical AND with the second number
3. Initiate data pointer
4. Store the result
ALGORITHM:
1. Move the first number to A register
2. Perform logical XOR with the second number
3. Initiate data pointer
4. Store the result
OUTPUT:
OBSERVATION:
#data1= 03
#data2= 02
MEMORY DATA
LOCATION
4500 01
OUTPUT:
OBSERVATION:
#data1= 03
#data2= 02
MEMORY DATA
LOCATION
4500 (LSB) 01
4501 (MSB) 00
OUTPUT:
OBSERVATION:
#data1=
2F
#data2=
4E
MEMORY DATA
LOCATION
4500 6F
OUTPUT:
OBSERVATION:
#data1= 87
#data2=7E
MEMORY DATA
LOCATION
4500 06
OUTPUT:
OBSERVATION:
#data1 = 87
#data2 = 7E
MEMORY DATA
LOCATION
4500 F9
OUTPUT:
RESULT:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM : 1
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello World!");
}
ALGORITHM:
LM 35 ARDUINO UNO
GND GND
VCC 5V
OUT A0
ALGORITHM:
GND GND
VCC 5V
OUT A0
void setup()
{
//pinMode(LEDpin, OUTPUT);
pinMode(obstaclePin, INPUT);
Serial.begin(9600);
}
void loop() {
hasObstacle = digitalRead(obstaclePin);
if (hasObstacle == HIGH) {
Serial.println("Stop something is ahead!!");
//digitalWrite(LEDpin, HIGH);
}
else
if (hasObstacle == LOW){
Serial.println("Path is clear");
//digitalWrite(LEDpin, LOW);
}
delay(2000);
}
ALGORITHM:
void loop()
{
Serial.println();
int chk = DHT11.read(DHT11PIN);
Serial.print("Humidity (%): ");
Serial.println((float)DHT11.humidity, 2);
Serial.print("Temperature (C): ");
Serial.println((float)DHT11.temperature, 2);
delay(2000);
OUTPUT:
PROGRAM 5:
Serial.begin(9600);
void loop()
input_val = analogRead(LDR);
Serial.println(input_val);
delay(1000);
}
RESULT:
AIM:
To implement the RP2040 carrier board with python programming.
COMPONENDS RECQUIRED:
ALGORITHM:
4. Turn on LED3.
7. Repeat steps 3-6 indefinitely to create a blinking pattern between the two LEDs.
PROGRAM:
led2=Pin(2,Pin.OUT)
while True:
led2.value(1)
sleep_ms(200)
led3.value(1)
led2.value(0)
sleep_ms(200)
led3.value(0)
OUTPUT:
1. Initialize an LCD display with GPIO pins for control signals and data lines.
4. Print "my count :" on the second line of the LCD display.
PROGRAM
1. Print text
import time
count=0
enable_pin = Pin(9),
d4_pin = Pin(10),
d5_pin = Pin(11),
d6_pin = Pin(12),
d7_pin = Pin(13))
lcd.move_to(0,0)
lcd.putstr("Hi hello")
KGiSL Institution of Technology 711722104115
lcd.move_to(0,1)
while True:
count=count+1
lcd.move_to(13,1)
lcd.putstr(str(count))
time.sleep(1)
OUTPUT:
ALGORITHM:
PROGRAM BUZZER
import time
while True:
Buzzer.value(1)
time.sleep(0.2)
Buzzer.value(0)
time.sleep(1)
OUTPUT:
2. Define the memory address for the Serial I/O (SIO) module.
4. Write the value 0x0200000c to the SIO register offset 0x014 to turn on LED1.
6. Write the value 0x0200000c to the SIO register offset 0x018 to turn off LED1 and
turn on LED2.
8. Repeat steps 4-7 indefinitely to create a blinking pattern between LED1 and LED2.
PROGRAM SIO_LED
led1=Pin(2,mode=Pin.OUT)
led2=Pin(3,mode=Pin.OUT)
led3=Pin(6,mode=Pin.OUT)
addrSIO = 0xd0000000
while True:
sleep_ms(500)
sleep_ms(500)
RESULT:
Thus experiments to implement the RP2040 carrier board with python programming is
conducted successfully.
AIM:
To implement the basic arithmetic program using Embedded C.
APPARATUS REQUIRED:
PC, RIDE Software
ALGORITHM:
1. Set variable a to the hexadecimal value 0x10 (16 in decimal).
2. Set variable b to the hexadecimal value 0x04 (4 in decimal).
3. Subtract the value of b from a and store the result in Port 0 (P0).
4. Add the values of a and b together and store the result in Port 1 (P1).
5. Multiply the values of a and b together and store the result in Port 2 (P2).
6. Divide the value of a by b and store the result in Port 3 (P3).
PROGRAM:
#include <reg51.h>
unsigned char a, b;
unsigned int c;
void main() {
a = 0x10;
b = 0x04;
P0 = a - b;
P1 = a + b;
P2 = a * b;
P3 = a / b;
while(1);
RESULT:
The basic arithmetic program using Embedded C is performed.
AIM
APPARATUS RECQUIRED:
ALGORITHM:
while True:
val2 = adc2.read_u16()
temp = (val2 * conversion_factor)*100
print("===============================")
print("temperature:
",temp) time.sleep(0.8)
KGiSL Institution of Technology 711722104115
OUTPUT:
ALGORITHM:
PROGRAM:
Potentiometer
from machine import Pin
import utime
POT_Value =
machine.ADC(28)
conversion_factor =
KGiSL Institution of Technology 711722104115
3.3/(65535)
while True:
#print(POT_Value.read_u1
6() )
OUTPUT:
ALGORITHM:
OUTPUT:
RESULT:
AIM:
To implement the different communications with IOT Device like Zigbee, GSM,
Bluetooth.
APPARATUS REQUIRED:
Arduino UNO Kit, Bluetooth Interface, Zigbee Interface -2, Connecting wires
ALGORITHM:
Bluetooth:
bluetooth
/* Arduino Bluetooth
10 Tx
11 Rx
gnd gnd
5v vcc */
#include<SoftwareSerial.h>
void setup() {
bt.begin(9600); /* Define baud rate for software serial communication */
Serial.begin(9600); /* Define baud rate for serial communication */
bt.write("garbage");
}
void loop()
{
bt.write(Serial.read());
ALGORITHM:
1. Initialize communication with SIM900A and Serial Monitor.
2. Print "SIM900A Ready" and "Type s to send message".
3. Check for input from Serial Monitor.
4. If 's' is received, call SendMessage() function.
5. Check for input from SIM900A.
6. If data available, send it to Serial Monitor.
7. Set GSM Module in Text Mode.
8. Set SMS Number and Content.
9. Send message and print confirmation.
OUTPUT:
ALGORITHM:
1. Initialize communication with SIM900A and Serial Monitor.
2. Print "SIM900A Ready" and "Type r to receive message".
3. Check for input from Serial Monitor.
4. If 'r' is received, call ReceiveMessage() function.
5. Check for input from SIM900A.
6. If data available, send it to Serial Monitor.
7. Print "SIM900A Membaca SMS".
8. Set up SIM900A to receive live SMS.
9. Print "Unread Message done".
OUTPUT:
Verified.
ZIGBEE:
1. Click Discover radio modules from the toolbar.
2. In the Discover radio modules dialog, select the serial port(s) in which you want
to look for radio modules. If you do not know the serial ports where your modules
are attached, select all ports. Click Next.
3. In the Set port parameters window, maintain the default values and click Finish.
4. As XCTU locates radio modules, they appear in the Discovering radio modules…
dialog box. Once the discovery process has finished, click Add selected devices.
5. At this point, assuming you have three modules connected to your computer, you
should see something like this in the Radio Modules section on the left
6. Communicate between Coordinator and Enduser.
RESULT:
The programs for Bluetooth, GSM and Zigbee has been performed.
AIM
APPARATUS:
PROCEDURE:
ALGORITHM:
1. Import necessary libraries: time, network, Pin from machine, and BlynkLib.
2. Set up the Wi-Fi connection.
3. Define the Blynk authentication token (BLYNK_AUTH).
4. Connect to the Blynk server.
5. Initialize the pins connected to the relays.
6. Define virtual pin handlers for controlling relays.
7. Continuously run the Blynk service and update a virtual pin every 2 seconds.
PROGRAM:
import time
import network
from machine import Pin
import BlynkLib
wlan =
KGiSL Institution of Technology 711722104115
network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("ArNet","12345678")
BLYNK_AUTH =
network connection
wait = 10
while wait > 0:
if wlan.status() < 0 or wlan.status() >=
3: break
wait -= 1
print('waiting for connection...')
time.sleep(1)
# Handle connection
error if wlan.status()
!= 3:
raise RuntimeError('network connection
failed') else:
print('connected')
ip = wlan.ifconfig()[0]
print('IP: ', ip)
# Connect to Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
OUTPUT:
RESULT:
AIM:
APPARATUS:
ALGORITHM:
PROGRAM:
import
utime import
network
from machine import
Pin import BlynkLib
wlan =
network.WLAN(network.STA_IF)
wlan.active(True)
KGiSL Institution of Technology 711722104115
wlan.connect("ArNet","12345678")
BLYNK_AUTH =
'yMsd4X4WnSiZQ9pZsXiOuJTy5nopIz4i' #
# Handle
connection error if
wlan.status() != 3:
raise RuntimeError('network
connection failed') else:
print('connected')
ip =
wlan.ifconfig()[0]
print('IP: ', ip)
# Connect to Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Initialize the
ultrasonic pins trigger
= Pin(15, Pin.OUT)
echo = Pin(14, Pin.IN)
OUTPUT:
RESULT:
The program to Log Data using Raspberry PI and upload to the cloud platform has been
performed successfully.
AIM
To write and execute the program to Communicate between Arduino and
Raspberry PI using any wireless medium (Bluetooth)
APPARATUS REQUIRED
ALGORITHM
1. Set up a software serial communication with pins 2 and 3.
2. In the setup() function, initialize the software serial communication at a baud rate
of 9600.
3. Send the character 'A', then wait for 1 second.
4. Send the character 'B', then wait for 1 second. Repeat indefinitely.
ALGORITHM:
PROGRAM:
MASTER ARDUINO :
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
//rx,tx void setup() {
mySerial.begin(9600);
}
void loop() {
mySerial.write('
A');
delay(1000);
mySerial.write('
B');
delay(1000);
}
CONNECTIONS IN RASPBERRY PI
OUTPUT:
RESULT:
AIM:
APPARATUS RECQUIRED:
ALGORITHM:
PROGRAM:
// WiFi Credentials
const char* ssid = "Home";
const char* password = "Password123";
// device names
String Device_1_Name =
"device one"; String
Device_2_Name = "device
two"; String Device_3_Name
KGiSL Institution of Technology 711722104115
= "device three"; String
Device_4_Name = "device
four";
#include <WiFi.h>
#include
<Espalexa.h>
#include
<Preferences.h>
#include
<IRremote.h>
Preferences
pref; Espalexa
espalexa;
#define wifiLed 2
//D2 #define RX2Pin
16 //
RX2 #define TX2Pin
17 //
TX2
// Relay State
bool toggleState_1 = LOW; //Define integer to remember
the toggle state for relay 1 bool toggleState_2 = LOW;
//Define integer to remember the toggle state for relay 2
bool toggleState_3 = LOW; //Define integer to remember
the toggle state for relay 3 bool toggleState_4 = LOW;
//Define integer to remember the toggle state for relay 4
KGiSL Institution of Technology 711722104115
String bt_data = ""; // variable for storing
bluetooth data int currSpeed = 0;
bool first_run =
true; int
wifiFlag = 0;
decode_results
results;
// prototypes
boolean connectWifi();
//callback functions
void firstLightChanged(uint8_t
brightness); void
secondLightChanged(uint8_t
brightness); void
thirdLightChanged(uint8_t
brightness); void
fourthLightChanged(uint8_t
brightness)
Serial.println("Device2
OFF"); toggleState_2 = 0;
}
pref.putBool("Relay2", toggleState_2);
}
// Wait for
connection
Serial.print("Connec
ting...");
while (WiFi.status() !=
WL_CONNECTED) {
delay(500);
Serial.print(
"."); if (i >
20) {
state = false; break;
}
i+
+;
}
Serial.println
(""); if
(state) {
Serial.print("Connecte
d to ");
Serial.println(ssid);
Serial.print("IP
address: ");
Serial.println(WiFi.loc
alIP());
}
else {
Serial.println("Connection failed.");
}
return state;
}
void addDevices(){
// Define your devices here.
espalexa.addDevice(Device_1_Name, firstLightChanged); //simplest
definition, default state off espalexa.addDevice(Device_2_Name,
KGiSL Institution of Technology 711722104115
secondLightChanged); espalexa.addDevice(Device_3_Name,
thirdLightChanged); espalexa.addDevice(Device_4_Name,
fourthLightChanged);
espalexa.begin();
}
void all_SwitchOn(){
toggleState_1 = 1; digitalWrite(RelayPin1, LOW); pref.putBool("Relay1",
toggleState_1); sendFeedback(0, 100); delay(100);
toggleState_2 = 1; digitalWrite(RelayPin2, LOW); pref.putBool("Relay2",
toggleState_2); sendFeedback(1, 100); delay(100);
toggleState_3 = 1; digitalWrite(RelayPin3, LOW); pref.putBool("Relay3",
toggleState_3); sendFeedback(2, 100); delay(100);
toggleState_4 = 1; digitalWrite(RelayPin4, LOW); pref.putBool("Relay4",
toggleState_4); sendFeedback(3, 100); delay(100);
}
void all_SwitchOff(){
toggleState_1 = 0; digitalWrite(RelayPin1, HIGH); pref.putBool("Relay1", toggleState_1);
sendFeedback(0, 0); delay(100);
void getRelayState()
{
//Serial.println("reading data
from NVS"); toggleState_1 =
pref.getBool("Relay1", 0);
digitalWrite(RelayPin1,
!toggleState_1);
(toggleState_1 == false) ? sendFeedback(0, 0) :
sendFeedback(0, 100); delay(200);
toggleState_2 = pref.getBool("Relay2", 0);
digitalWrite(RelayPin2, !toggleState_2);
(toggleState_2 == false) ? sendFeedback(1, 0) :
KGiSL Institution of Technology 711722104115
sendFeedback(1, 100); delay(200);
toggleState_3 = pref.getBool("Relay3", 0);
digitalWrite(RelayPin3, !toggleState_3);
(toggleState_3 == false) ? sendFeedback(2, 0) :
sendFeedback(2, 100); delay(200);
toggleState_4 = pref.getBool("Relay4", 0);
digitalWrite(RelayPin4, !toggleState_4);
(toggleState_4 == false) ? sendFeedback(3, 0) :
sendFeedback(3, 100); delay(200);
}
void setup()
{
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, RX2Pin, TX2Pin);
//Open namespace in read-
write mode
pref.begin("Relay_State",
false);
pinMode(RelayPin1,
OUTPUT);
pinMode(RelayPin2,
OUTPUT);
pinMode(RelayPin3,
OUTPUT);
pinMode(RelayPin4,
OUTPUT);
pinMode(wifiLed, OUTPUT);
//During Starting all Relays should TURN
OFF digitalWrite(RelayPin1,
!toggleState_1); digitalWrite(RelayPin2,
!toggleState_2); digitalWrite(RelayPin3,
!toggleState_3); digitalWrite(RelayPin4,
!toggleState_4);
digitalWrite(wifiLed, LOW);
{
addDevices();
}
else
{
Serial.println("Cannot connect to WiFi. So in Manual Mode");
}
delay(1000);
getRelayState(); //fetch data from NVS Flash Memory
// delay(1000);
}
void loop()
{
if (WiFi.status() != WL_CONNECTED)
{
//Serial.print("WiFi Not Connected
"); digitalWrite(wifiLed, LOW);
//Turn off WiFi LED
}
else
{
//Serial.print("WiFi
Connected ");
digitalWrite(wifiLed,
HIGH);
//WiFi Control
if
(wifiConnect
ed){
espalexa.loop
(); delay(1);
}
else {
wifiConnected = connectWifi(); // Initialise wifi
connection if(wifiConnected){
addDevices();
KGiSL Institution of Technology 711722104115
}
}
}
OUTPUT:
RESULT:
The WiFi and Bluetooth controlled relay system implemented on Raspberry Pi for home
automation is done successfully.