Cs3691-Eiot Lab Exp 3,4,5
Cs3691-Eiot Lab Exp 3,4,5
Cs3691-Eiot Lab Exp 3,4,5
LAB EXPERIMENTS
DATE:
1. Addition
2. Multiplication
3. Subtraction
4. Division
Addition:
ORG 0000h
Add A, 00H // addA value with R0 value and stores the result inA//
END
Multiplication:
ORG 0000h
END
Subtraction:
ORG 0000h
END
Division:
ORG 0000h
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;
c = a - b;
c = a *b;
c = a / b;
c = a % b;
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 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
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.
Or
Open the URL https://www.arduino.cc/en/Main/Software
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:
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.
14. Now, we have to accept the security for the installation. We are required to accept the
security Installation three times.
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:
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.
We can view the port of the attached hardware Arduino IDE to our computer.
( 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.
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.
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.
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.
Here, we have selected Arduino Uno board according to our tutorial, but you must select the
name matching the board that you are using.
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.
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. }