Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views24 pages

Cs3691-Eiot Lab Exp 3,4,5

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 24

CS3691-EMBEDDED SYSTEMS AND IOT

LAB EXPERIMENTS

EXP NO 3: PERFORM ALU OPERATIONS.

DATE:

The arithmetic instructions perform the basic operations such as:

1. Addition
2. Multiplication
3. Subtraction
4. Division

Addition:

ORG 0000h

MOV R0, #03H // move the value 3 to the register R0//

MOV A, #05H // move the value 5 to accumulator A//

Add A, 00H // addA value with R0 value and stores the result inA//

END

Multiplication:

ORG 0000h

MOV R0, #03H // move the value 3 to the register R0//

MOV A, #05H // move the value 5 to accumulator A//

MUL A, 03H // Multiplied result is stored in the Accumulator A //

END
Subtraction:

ORG 0000h

MOV R0, #03H // move the value 3 to register R0//

MOV A, #05H // move the value 5 to accumulator A//

SUBB A, 03H // Result value is stored in the Accumulator A //

END

Division:

ORG 0000h

MOV R0, #03H // move the value 3 to register R0//

MOV A, #15H // move the value 5 to accumulator A//

DIV A, 03H // final value is stored in the Accumulator A //

END
EXP NO 4: WRITE BASIC AND ARITHMETIC PROGRAMS USING EMBEDDED C

DATE:

#include <stdio.h>

int main()

int a = 16, b = 4, c;

c = a + b;

printf("Addition of a+b = %d \n", c);

c = a - b;

printf("Subtraction of a-b = %d \n", c);

c = a *b;

printf("Multiplication of a*b = %d \n", c);

c = a / b;

printf("Division of a/b = %d \n", c);

c = a % b;

printf("Remainder of a divided by b = %d \n", c);

return 0;

}
EXP NO 5 :INTRODUCTION TO ARDUINO PLATFORM AND PROGRAMMING

DATE:

Arduino Tutorial

Arduino is a project, open-source hardware, and software platform used to design and build
electronic devices. It designs and manufactures microcontroller kits and single-board interfaces
for building electronics projects.

The Arduino boards were initially created to help the students with the non-technical
background.

The designs of Arduino boards use a variety of controllers and microprocessors.

The Arduino board consists of sets of analog and digital I/O (Input / Output) pins, which are
further interfaced to breadboard, expansion boards, and other circuits. Such boards feature the
model, Universal Serial Bus (USB), and serial communication interfaces, which are used for
loading programs from the computers.

Features

The features of Arduino are listed below:

o Arduino programming is a simplified version of C++, which makes the learning process
easy.
o The Arduino IDE is used to control the functions of boards. It further sends the set of
specifications to the microcontroller.
o Arduino does not need an extra board or piece to load new code.
o Arduino can read analog and digital input signals.
o The hardware and software platform is easy to use and implement.
PICTORIAL REPRESENTATION OF ARDUINO

Arduino Download

The Arduino software (IDE) is open-source software. We are required to write the code and
upload the code to the board to perform some task.

The Arduino IDE software can be used with any type of Arduino boards. The software is
available for various operating system such as, Windows, Linux, and Mac OS X.

The steps to download the Arduino software are listed below:

1. Go to the official website of Arduino (https://www.arduino.cc/) > Click on SOFTWARE <


click on DOWNLOADS, as shown below:

Or
Open the URL https://www.arduino.cc/en/Main/Software

2. A page will appear, as shown below:

3. Scroll the screen a little, as shown below:


4. Click on the 'Windows Installer' as we are operating with the Windows. We can select
the Linux or Mac OS X, accordingly.

5. A contribution window will appear. We can contribute according to our choice and click on
the 'CONTRIBUTE &DOWNLOAD' option. Otherwise, click on the 'JUST
DOWNLOAD' option, as shown below:
6. The downloading process will start. The downloading file will look like the below image:

7. Wait for few seconds for the downloading process to complete.

8. Open the downloaded file.

9. Grant permission to the Arduino Software on your computer.

10. Accept the license by clicking on 'I Agree' button, as shown below:
11. Click on the 'Next' button. It is shown below:

12. The window specifying the location of the installed folder will appear.

Click on the 'Install' button. It is shown below:


If you want to change the location, click on the 'Browse' button.

13. The installing process of Arduino will start, as shown below:

Wait for the installation process to complete.

14. Now, we have to accept the security for the installation. We are required to accept the
security Installation three times.

Click on the 'Install' button. The image is shown below:


15. Again, click on the 'Install' button. It is shown below:

16. Again, click on the 'Install' button. It is shown below:

17. The installation process is now completed. The window will now appear as:
18. Click on the 'Close' button at the bottom.

The Arduino IDE software will appear on your desktop, as shown below:

19. Now, open the Arduino software.

20. The Arduino IDE environment is written in the programming language named as Java. So,
we need to allow access to the Java Platform.

As soon we open the Arduino software, a license window will appear, as shown below:
Accept the license by clicking on the 'Allow access' button.

21. The Arduino window will appear as:


Visibility of the connected Hardware port

We can view the port of the attached hardware Arduino IDE to our computer.

The steps are listed below:


1. Go to the File Manager and right-click on the This PC option, as shown below:

2. Click on the Manage


3. First, we need to connect the Arduino board to our computer.
4. A window will appear, as shown below:

5. Click on the Device Manager


6. Under the PORT option, we can see the ports of the connected hardware.

( OR )

we will learn in easy steps, how to set up the Arduino IDE on our computer and prepare the
board to receive the program via USB cable.
Step 1 − First you must have your Arduino board (you can choose your favorite board) and a
USB cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560,
or Diecimila, you will need a standard USB cable (A plug to B plug), the kind you would
connect to a USB printer as shown in the following image.

In case you use Arduino Nano, you will need an A to Mini-B cable instead as shown in the
following image.

Step 2 − Download Arduino IDE Software.

You can get different versions of Arduino IDE from the Download page on the Arduino Official
website. You must select your software, which is compatible with your operating system
(Windows, IOS, or Linux). After your file download is complete, unzip the file.
Step 3 − Power up your board.

The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from
either, the USB connection to the computer or an external power supply. If you are using an
Arduino Diecimila, you have to make sure that the board is configured to draw power from the
USB connection. The power source is selected with a jumper, a small piece of plastic that fits
onto two of the three pins between the USB and power jacks. Check that it is on the two pins
closest to the USB port.

Connect the Arduino board to your computer using the USB cable. The green power LED
(labeled PWR) should glow.

Step 4 − Launch Arduino IDE.

After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the folder,
you can find the application icon with an infinity label (application.exe). Double-click the icon to
start the IDE.
Step 5 − Open your first project.

Once the software starts, you have two options −

 Create a new project.


 Open an existing project example.

To create a new project, select File → New.


To open an existing project example, select File → Example → Basics → Blink.

Here, we are selecting just one of the examples with the name Blink. It turns the LED on and off
with some time delay. You can select any other example from the list.
Step 6 − Select your Arduino board.

To avoid any error while uploading your program to the board, you must select the correct
Arduino board name, which matches with the board connected to your computer.

Go to Tools → Board and select your board.

Here, we have selected Arduino Uno board according to our tutorial, but you must select the
name matching the board that you are using.

Step 7 − Select your serial port.

Select the serial device of the Arduino board. Go to 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, you can disconnect your Arduino board and re-open the menu, the entry that disappears
should be of the Arduino board. Reconnect the board and select that serial port.
Step 8 − Upload the program to your board.

Before explaining how we can upload our program to the board, we must demonstrate the
function of each symbol appearing in the Arduino IDE toolbar.

A − Used to check if there is any compilation error.


B − Used to upload a program to the Arduino board.

C − Shortcut used to create a new sketch.

D − Used to directly open one of the example sketch.

E − Used to save your sketch.

F − Serial monitor used to receive serial data from the board and send the serial data to the
board.

Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see the
RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done
uploading" will appear in the status bar.

Note − If you have an Arduino Mini, NG, or other board, you need to press the reset button
physically on the board, immediately before clicking the upload button on the Arduino Software.

SIMPLE PROGRAM:

Structure
Arduino programs can be divided in three main parts: Structure, Values (variables and
constants), and Functions. In this tutorial, we will learn about the Arduino software program,
step by step, and how we can write the program without any syntax or compilation error.
Let us start with the Structure. Software structure consist of two main functions −

 Setup( ) function
 Loop( ) function
Void setup ( ) {

}
 PURPOSE − The setup() function is called when a sketch starts. Use it to initialize the
variables, pin modes, start using libraries, etc. The setup function will only run once, after
each power up or reset of the Arduino board.
 INPUT − -
 OUTPUT − -
 RETURN − -

Void Loop ( ) {

}
 PURPOSE − After creating a setup() function, which initializes and sets the initial
values, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to actively control
the Arduino board.
 INPUT − -
 OUTPUT − -
 RETURN − -
Example: To light the LED connected to pin number 13. We want to ON the LED for 4 seconds
and OFF the LED for 1.5 seconds.

Code:

void setup ()

1. {
2. pinMode ( 13, OUTPUT); // to set the OUTPUT mode of pin number 13.
3. }
4. void loop ()
5. {
6. digitalWrite (13, HIGH);
7. delay (4000); // 4 seconds = 4 x 1000 milliseconds
8. digitalWrite (13, LOW);
9. delay (1500); // 1.5 seconds = 1.5 x 1000 milliseconds
10. }

You might also like