OBSERVATION:
Before Execution:
After Execution:
RESULT:
Thus the program for 8-bit data transfer between the register and memory are performed
using 8051 was executed and verified successfully.
Select Keil_v5 present in Local Disk (C:)
OBSERVATION:
RESULT:
Thus the basic arithmetic operation using keil embedded C is performed.
Open sketch
Open the LED blink example sketch: File > Examples >01.Basics > Blink.
Select board type and port
Select the entry in the Tools > Board menu that corresponds to your Arduino
board.
Select the serial device of the board from the Tools | Serial Port menu. This is
likely to be COM3 or higher (COM1 and COM2 are usually reserved for
hardware serial ports). To find out, disconnect the board and re-open the menu;
the entry that disappears should be the Arduino board. Reconnect the board and
select that serial port.
Upload the program
Now, simply click the "Upload" button in the environment. Wait a few seconds -
the RX and TX leds on the board flashing. If the upload is successful, the message
"Done uploading." will appear in the status bar.
I2C Communication
I2C is short for Inter-IC. And it is a type of BUS. This is designed by Philips
semiconductors. I2C is a synchronous, multi slave, multi master packet switched,
single-ended serial bus. ie. multiple chips can be connect to the same bus.I2C uses
only two bidirectional open collector or open drain lines, Serial Data Line (SDA)
and Serial Clock Line (SCL), pulled up with resistors. Typical voltages used are
+5 V or +3.3 V, although systems with other voltages are permitted.
I2C Serial Interface Adapter
It is also known as I2C Module. It has total of 20 male pins. 16 pins are faced to
rear side and 4 pins faced towards front side. The 16 pins for connect to 16x2
LCD and the 2 pins out of 4 pins are SDA and SCL. SDA is the serial data pin and
SCL is the clock pin. The rest 2 pins for power supply (Vcc and ground).There is
a POT on the I2C Module. We can control the contrast of the LCD display by
rotating this POT. And there is a jumber fixed on the module. When we remove
the jumber, the backlight of the LCD display will go OFF.
Connection
First solder the I2C Module. There is no label on the I2C Module for connecting to
16x2 LCD. So solder it with the help of the image given below
I2C Module on 16x2 LCD
After connect the I2C Module to Arduino Uno.
Arduino Uno I2C module
Analog Pin 4 - SDA
Analog pin 5 - SCL
5V - Vcc
GND - GND
Connect the Arduino to computer.
Add library
Schematics
Interface I2C 16x2 LCD with Arduino Uno
PROGRAM
#include <Arduino.h>
#include <Wire.h>
#include
<LiquidCrystal_PCF8574.
h> int show = -1; void
setup() { int error;
Serial.begin(11520
0);
Serial.println("LCD
..."); while (!
Serial) ;
Serial.println("Probing for PCF8574 on address 0x27...");
Wire.begin();
Wire.beginTransmission(
0x27); error =
Wire.endTransmission();
Serial.prin
t("Error: ");
Serial.print
(error); if
(error == 0)
{
Serial.println(": LCD
found."); show = 0;
lcd.begin(16, 2); //
initialize the lcd
} else {
Serial.println(": LCD not found.");
} // if
} // setup()
void loop()
{ if (show ==
0)
{ lcd.setBac
klight(255);
lcd.home();
lcd.clear();
lcd.print("Hell
o LCD");
delay(1000);
}
OUTPUT:
LCD found in Serial Monitor.
LCD not found in Serial Monitor.
Hello LCD in LCD Display.
RESULT:
Thus the Program to Display in LCD is executed successfully using Arduino
Platform & IDE
.
EX.NO:6 EXPLORE DIFFERENT COMMUNICATION METHODS
WITH IOT DEVICES(ZIGBEE,GSM,BLUETOOTH)
AIM: To Explore different communication methods with IoT devices (Zigbee,
GSM, Bluetooth)
HARWARE REQUIRED:
Different communication modules
Connecting wires
Add library Mesh network
Open code from Example→painless mesh→basic
Connection diagram
PROGRAM
#include "painlessMesh.h"
#define MESH_PREFIX "whateverYouLike"
#define MESH_PASSWORD "somethingSneaky"
#define MESH_PORT 5555
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars
and 2 line display String datar; int show = -1;
Scheduler userScheduler; // to control your personal task
painlessMesh mesh;
// User stub void sendMessage() ; // Prototype so
PlatformIO doesn't complain
Task taskSendMessage( TASK_SECOND * 1 , TASK_FOREVER,
&sendMessage );
void sendMessage() { String msg = "engineering"; msg +=
mesh.getNodeId(); mesh.sendBroadcast( msg );
taskSendMessage.setInterval( random( TASK_SECOND * 1,
TASK_SECOND * 2 ));
}
// Needed for painless library void
receivedCallback( uint32_t from, String
&msg ) { Serial.printf(" msg=%s\
n",msg.c_str()); datar=msg.c_str();
}
void newConnectionCallback(uint32_t nodeId) {
Serial.printf("--> startHere: New Connection, nodeId = %u\
n", nodeId); }
void changedConnectionCallback() {
Serial.printf("Changed connections\n");
void nodeTimeAdjustedCallback(int32_t offset) {
Serial.printf("Adjusted time %u. Offset = %d\n",
mesh.getNodeTime(),offset); }
void setup() {
Serial.begi
n(9600); int
error;
Wire.begin();
Wire.beginTransmission(0x27);
error = Wire.endTransmission();
Serial.print("Error: ");
Serial.print(error);
if (error == 0) {
Serial.println(": LCD
found."); show = 0;
lcd.begin(16, 2); //
initialize the lcd
} else {
Serial.println(": LCD not found.");
}
lcd.setBacklight(255);
lcd.home();
mesh.setDebugMsgTypes( ERROR | STARTUP ); // set before init() so that you
can see startup messages
mesh.init( MESH_PREFIX, MESH_PASSWORD, &userScheduler,
MESH_PORT ); mesh.onReceive(&receivedCallback);
mesh.onNewConnection(&newConnectionCallback);
mesh.onChangedConnections(&changedConnectionCallback);
mesh.onNodeTimeAdjusted(&nodeTimeAdjustedCallback);
userScheduler.addTask( taskSendMessage );
taskSendMessage.enable();
void loop() {
mesh.update();
lcd.clear();
lcd.print("data:"
);
lcd.setCursor(0,
1);
lcd.print(datar);
delay(1000);
}
BLUETOOTH:
Bluetooth (IEEE 802.15 STANDARD) is a wireless LAN technology
designed to connect devices of different functions such as telephones,
notebooks, computers (desktop and laptop), cameras, printers when
they are at a short distance from each other.
HC-05 is a Bluetooth device used for wireless communication with
Bluetooth enabled devices (like smartphone). It communicates with
microcontrollers using serial communication (USART) –RX & TX Pins.
BLUE TOOTH communication Wiring diagram
PROGRAM
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27);
int show = -1;
String data;
String inputString = ""; // a String to hold
incoming data bool stringComplete = false; // whether
the string is complete void setup() {
Serial.begi
n(9600); int
error;
Serial.println("welcome!");
Serial.println("Hello, world?");
if (error == 0) {
Serial.println(": LCD
found."); show = 0;
lcd.begin(16, 2); //
initialize the lcd
} else {
Serial.println(": LCD not found.");
}
lcd.setBackli
ght(255);
lcd.home();
void loop() { // run over
and over lcd.clear();
lcd.print("Bluetooth");
delay(2000);
Serial.println("Bluetooth OK");
delay(3000);
Serial.println((char)26);// ASCII code of CTRL+Z
delay(3000);}
GSM MODULE
Global System for Mobile communication (GSM) is digital
cellular system used for mobile devices. It is an international
standard for mobile which is widely used for long distance
communication.
There are various GSM modules available in market like SIM900,
SIM700. SIM900A module allows users to send/receive data over GPRS,
send/receive SMS and make/receive voice calls.
The GSM/GPRS module uses USART communication to communicate
with microcontroller or PC terminal. AT commands are used to
configure the module in different modes and to perform various
functions like calling, posting data to a site.
AT COMMAND: BASIC
Command Description Response
AT Checking communication OK
CALL COMMAND:
Command Description Response
ATD<Mob. Dial / call a OK (if successful), BUSY (if busy), NO
No.>; number CARRIER (if no connection)
ATA Answer a call OK
ATH Hang up call OK
SMS COMMAND:
Command Description Response
> ”Type message here”
AT+CMGS=”9881xxxxxx” Send message
Connection diagram
GSM PROGRAM
#include <Wire.h>
#include
<LiquidCrystal_PCF8574.
h>
LiquidCrystal_PCF8574
lcd(0x27); int show = -1;
void setup() {
Serial.b
egin(960
0); int
error; if
(error
== 0) {
Serial.println(": LCD
found."); show = 0;
lcd.begin(16, 2); //
initialize the lcd
} else {
Serial.println(": LCD not found.");
}
lcd.setBackli
ght(255);
lcd.home();
lcd.clear();
lcd.print("GSM INTERFACE CONTROLLER");
lcd.setCursor
(0, 1);
lcd.print(data);
delay(10000);
lcd.clear();
lcd.print("CHE
CK GSM
STATUS");
lcd.setCursor(0, 1);
} void loop() { // run
over and over
{
lc
d.
cl
e
a
r(
);
lcd.print("CHECK GSM STATUS");
delay(5000);
lcd.clear();
lcd.print("sms
mode");
Serial.println("AT"); //Sets the GSM Module
in Text Mode delay(2000); // Delay of 1000
milli seconds or 1 second
Serial.println("AT+CMGF=1"); delay(2000);
Serial.println("AT+CMGS=\"7708954811\"\r"); // Replace x with mobile number
delay(2000);
Serial.println("WELCOME TO CALIBER VIRTUAL TECHNOLOGIES");
delay(1000);
Serial.println((char)26);// ASCII code of CTRL+Z
delay(3000);
RESULT: Thus the different methods of communication with IoT devices were explored
successfully.
Set up Thonny
Hold the BOOTSEL button on your Pico, and connect your Pico to your computer
via USB.
Go to Run > Select interpreter and choose MicroPython (Raspberry Pi Pico).
It's also a good idea to install or update firmware. This will update Pico with the
latest version of MicroPython, or install MicroPython if it wasn't already.
REPL interface (Shell)
We can immediately start executing code in the REPL - Enter this code in the shell
tab: print("Hello, World!")
The command will be sent to the Pico, which will execute the command and display
back the message.
We can also take control of the on-board LED by executing the following code:
from machine
import Pin led =
Pin(25,
Pin.OUT)
led.toggle()
This code will toggle the LED. If you keep executing led.toggle() the LED will
keep changing state.
Writing a Script
Create a new script with File > New and paste in the following code:
from machine
import Pin from
time import
sleep led =
Pin(25,
Pin.OUT) n = 0;
while True:
led.toggle()
print("13 x {} =
{}".format(n,
13*n)) # print
the thirteen-
times table n=
n + 1
sleep(0.5)
Save the script - you will be prompted to save to computer OR the pico. Select save
to Pico and name the file main.py
Return to the REPL and press Ctrl+D (or use the Stop/Restart button) to restart your
Pico. The LED should flash at a steady rate and the shell should begin printing
multiples of thirteen.
Installing a Package
Packages are reusable pieces of code that another programmer has written for a
common task, such as interfacing with a specific piece of hardware. Thonny has
support for installing micropython packages from the Python Package Index -
aka 'PyPI' directly onto the Raspberry Pi Pico.
To install a package, ensure the Pico is plugged in and go to Tools > Manage
Packages, which will show the Manage Packages dialog.
Enter the name of the package, would like to install into the search bar and click
'Search on PyPI'.
In the search results list, click the title of the package would like to install. A title
that's in bold simply indicates a direct search match on the text that entered in the
search bar.
The Manage Packages dialog will show an overview of the package have clicked.
Click Install to install the package on the Pico.
Confirm the package has been installed by checking the 'Raspberry Pi Pico'
section of the File View in Thonny. The view should show a new folder named
'lib', and inside this folder will be one or more folders containing the metadata and
source code of the library you just installed.
RESULT:
Thus the Platform for Raspberry Pi pico is completed successfully.
EX NO 8 INTERFACEING SENSORS WITH RASPBERRY PI
AIM:
To interface sensors with Raspberry Pi
HARDWARE REQUIRED
DHT11
Sensor
16*2
LCD
Display
Raspberry Pi Pico
Wiring diagram
PROGRAM
#if !( defined(ARDUINO_RASPBERRY_PI_PICO_W) )
#error For RASPBERRY_PI_PICO_W only
#endif
#define _RP2040W_AWS_LOGLEVEL_ 1
#include <pico/cyw43_arch.h>
#include <AsyncWebServer_RP2040W.h>
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars
and 2 line display
int show = -1;
#include "DHTStable.h"
DHTStable DHT;
#define DHT11_PIN 3
void setup()
{
// ThingSpeak.begin(client);
Serial.begin(115200);
Wire.begin();
Wire.beginTransmission(0x27);
// error = Wire.endTransmission();
Serial.print("Error: ");
//Serial.print(error);
lcd.begin(16, 2); //
initialize the lcd
lcd.setBacklight(255);
lcd.home(); lcd.clear();
lcd.print("welcome");
delay(1000);
}
void loop()
// check_status();
delay(1000);
Serial.print("DHT11, \
t"); int chk =
DHT.read11(DHT11_PIN
); switch (chk)
{
case DHTLIB_OK:
Serial.print("OK
,\t"); break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum
error,\t"); break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time
out error,\t");
break; default:
Serial.print("Unknown
error,\t"); break;
}
// DISPLAY DATA
Serial.print(DHT.getHumidity(), 1);
Serial.print(",\t");
Serial.println(DHT.getTemperature(), 1);
//ThingSpeak.writeField(myChannelNumber, FieldNumber,
DHT.getTemperature(), myWriteAPIKey);
lcd.clear();
lcd.print("Temperatur
e "); lcd.setCursor(0,
1); lcd.print(" ");
lcd.print(DHT.getTemp
erature());
delay(1000);
}
RESULT:
Thus the sensor is interface with Raspberry pi and verified successfully.