Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
33 views45 pages

Arm Lab Manual Student

The document is a lab manual for ARM/Arduino based programming prepared for Electronics & Communication Engineering students at Aditya College of Engineering & Technology. It includes various experiments related to Arduino, such as measuring analog signals from temperature sensors, generating PWM outputs, and establishing full duplex links using HyperTerminal. The manual provides detailed descriptions, circuit diagrams, and programming examples for each experiment.

Uploaded by

divya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views45 pages

Arm Lab Manual Student

The document is a lab manual for ARM/Arduino based programming prepared for Electronics & Communication Engineering students at Aditya College of Engineering & Technology. It includes various experiments related to Arduino, such as measuring analog signals from temperature sensors, generating PWM outputs, and establishing full duplex links using HyperTerminal. The manual provides detailed descriptions, circuit diagrams, and programming examples for each experiment.

Uploaded by

divya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

ADITYA COLLEGE OF ENGINEERING

&
TECHNOLOGY

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

ARM/ARDUINO BASED PROGRAMMING


LAB MANUAL
Prepared
by
M.KAIVALYA
(R-20)
III-B.Tech : II-Sem
(ELECTRONICS & COMMUNICATION ENGINEERING)
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY
Permanently Affiliated to JNTUK, Kakinada, Approved by AICTE, New Delhi, Accredited by NAAC
Recognized by UGC under Section 2(f) of UGC Act 1956
AdityaNagar,ADB Road, Surampalem-533437,E.G.Dt.,PH: 0884-2326212,99591 76665
CONTENTS

Exp.
Page.
No EXPERIMENT NAME
No
INTRODUCTION TO ARDUINO
1.

2.
MEASURE ANALOG SIGNAL FROM TEMPERATURE SENSOR

GENERATE PWM OUTPUT


3.

4.
DRIVE SINGLE CHARACTER GENERATION ON HYPER TERMINAL

5.
DRIVE A GIVEN STRING ON HYPER TERMINAL

6. GENERATE ASCII TABLE FOR DIFFERENT CHARACTERS

FULL DUPLEX LINK ESTABLISHMENT USING HYPER TERMINAL


7.

8.
DRIVE A GIVEN VALUE ON A 8 BIT DAC

DRIVE STEPPER MOTOR USING ANALOG GPIOS

9.
1. INTRODUCTION TO ARDUINO

AIM: Study of Arduino,

DESCRIPTION:

ARDUINO UNO

Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital


input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz
crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything
needed to support the microcontroller, simply connect it to a computer with a USB cable or power
it with a AC-to-DC adapter or battery to get started. You can tinker with your UNO without
worrying too much about doing something wrong, worst case scenario you can replace the chip
for a few dollars and start over again.
“Uno” means one in Italian and was chosen to mark the release of Arduino Software (IDE) 1.0.
The Uno board and version 1.0 of Arduino Software (IDE) were the reference versions of Arduino,
now evolved to newer releases. The Uno board is the first in a series of USB Arduino boards, and
the reference model for the Arduino platform. (IDE = integrated development
The basic working of CPU of ATmega328

1. The data is uploaded in serial via the port (being uploaded from the computer’s Arduino IDE).
The data is decoded and then the instructions are sent to instruction register and it decodes the
instructions on the same clock pulse.

2. On the next clock pulse the next set of instructions are loaded in instruction register.

3. In general purpose registers the registers are of 8-bit but there are 3 16-bit registers also.

a. 8-bit registers are used to store data for normal calculations and results.
b. 16-bit registers are used to store data of timer counter in 2 different register.
Eg. X-low & X-high. They are fast, and are used to store specific hardware functions.

4. EEPROM stores data permanently even if the power is cut out. Programming inside a
EEPROM is slow.

5. Interrupt Unit checks whether there is an interrupt for the execution of instruction to be
executed in ISR (Interrupt Service Routine).

6. Serial Peripheral Interface (SPI) is an interface bus commonly used to send data between
microcontrollers and small peripherals such as Camera, Display, SD cards, etc. It uses separate
clock and data lines, along with a select line to choose the device you wish to talk to.

7. Watchdog timer is used to detect and recover from MCU malfunctioning.

8. Analog comparator compares the input values on the positive and negative pin, when the value
of positive pin is higher the output is set.

9. Status and control is used to control the flow of execution of commands by checking other
blocks inside the CPU at regular intervals.
10. ALU (Arithmetic and Logical unit) The high performance AVR ALU operates in direct
connection with all the 32 general purpose working registers. Within a single clock cycle,
arithmetic operations b/w general purpose registers are executed. The ALU operations aredivided
into 3 main categories – arithmetic, logical and bit-function.

11. I/O pins The digital inputs and outputs (digital I/O) on the Arduino are what allow you to
connect the Arduino sensors, actuators, and other ICs. Learning how to use them will allow you
to use the Arduino to do some really useful things, such as reading switch inputs, lighting
indicators, and controlling relay outputs.
ARDUINO - INSTALLATION

After learning about the main parts of the Arduino UNO board, we are ready to learn
how to set up the Arduino IDE. Once we learn this, we will be ready to upload our program on the
Arduino board. Here, 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.

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 softwar, 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 A Arduino Nano
automatically draw power from either, the USB connection to the computer computer or an external
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 (labeled PWR) should glow.

Step 4 − Launch Arduino IDE. After your Arduino IDE software software is downloaded,
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 turnsthe 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 connectedto your computer.
Go to Tools → Board and select your board.
Here, we have selected Arduino Uno board according to our tutorial, 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). 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 serialdata to the board.

Now, simply click the "Upload" "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
2. MEASURE ANALOG SIGNAL FROM TEMPERATURE SENSOR

AIM: To Interface temperature sensor interfacing with Arduino Arduino Uno/Duemilanove


board
APPARATUS:
1. Development Board
2. Arduino Uno/Duemilanove board
3. LM35 temperature sensor
4. 12V Adaptor
5. Power jack
6. USB Cable
7. Jumper Wires

CIRCUIT DIAGRAM:

THEORY:
The LM35 Analog Temperature Sensor is a popular option for temperature sensing over the
range of -55 to 150°C.

 Provides analog output directly readable in degrees Celsius


 Output voltage corresponds to 10.0mV/°C
 -55 to 150°C measurement range with ±0.5°C accuracy°
 5V compatible. 3.3V uC compatible if the sensor is run off separate 4 to 20V supply.
If you have a microcontroller like an Arduino and you want to measure temperature, the LM35
is one of the more popular temperature measurement ICs to use. The LM35 is a 3-pin analog
thermometer packaged in a TO-92 package. The output is a linear voltage that corresponds to
10.0mV/°C, so the output is directly readable in degrees Celsius using an analog port on a
microcontroller. Accuracy is typically within 0.5°C. Since the voltage output range of the sensor is
limited to 1.5V, if a greater resolution is desired, the analog reference voltage on the uC can be
changed from the default 5V to something closer to 1.5V which will decrease the voltage step size
on the analog readings.

HARDWARE PROCEDURE:
 NTC in Development Board connected to A0 pin of Arduino duemilanove board
 Power jack is connected to the Arduino Uno/Duemilanove .
 USB connector is connected to Arduino Uno/Duemilanove and CPU.
 Connect the 12V power supply to development board.
 Upload corresponding program into Arduino Uno/Duemilanove.
 Switch ON Power supply.

SOFTWARE PROCEDURE:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on tools select Arduino Uno/Duemilanove and select port.
8. Click on Upload the code into Arduino Uno/Duemilanove by using USB cable.
9. Go to tools click on serial plotter verify the output in graph format.
PROGRAM :

// Define the analog pin, the LM35's Vout pin is connected to


#define sensorPin A0

void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Get the voltage reading from the LM35
int reading = analogRead(sensorPin);
// Convert that reading into voltage
float voltage = reading * (5.0 / 1024.0);
// Convert the voltage into the temperature in Celsius
float temperatureC = voltage * 100;
// Print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.print("\xC2\xB0"); // shows degree symbol
Serial.print("C | ");
// Print the temperature in Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF);
Serial.print("\xC2\xB0"); // shows degree symbol
Serial.println("F");

delay(1000); // wait a second between readings


}

RESULT:
b. TEMPERATURE MEASUREMENT USING 10K NTC THERMISTER

AIM: To measure the analog signal from temperature sensor

APPARATUS:
1. Arduino uno board
2. Thermistor 10K NTC
3. 5V Adaptor
4. Bread board
5. USB Cable
6. Jumper Wires

CIRCUIT DIAGRAM:

THEORY:

Thermistors (thermal resistors) are temperature dependent variable resistors. There are two
types of thermistors, Positive Temperature Coefficient (PTC) and Negative Temperature
Coefficient (NTC). When the temperature increases, PTC thermistor resistance will increase and
NTC thermistor resistance will decrease. They exhibit the opposite response when the
temperature decreases.
Both types of thermistors are used in a variety of application areas. However, here the focus will
be on using NTC thermistors to measure temperature in microcontroller based applications.
A common way for microcontrollers to capture analog data is via an analog to digital converter(ADC). You
can't directly read the thermistors resistance with an ADC. The series thermistor resistor combination,
shown in figure , provides a simple solution in the form of a voltage divider.

To convert ADC data to temperature you first find the thermistor resistance and then use it to
find the temperature.

You can rearrange the above voltage divider equation to solve for the thermistor resistance Rt:
Rt = R0 * (( Vs / Vo ) - 1)
If the ADC reference voltage (Vref) and voltage divider source voltage (Vs) are the same then
the following is true:

adcMax / adcVal = Vs / Vo

That is, the ratio of voltage divider input voltage to output voltage is the same as the ratio of the
ADC full range value (adcMax) to the value returned by the ADC (adcVal). If you are using a 10
bit ADC then adcMax is 1023.

Now you can replace the ratio of voltages with the ratio of ADC values in the equation to solve
for Rt:

Rt = R0 * ((adcMax / adcVal) - 1)

For example, assume a thermistor with a resistance of 10K ohms at 25°C, a 10 bit ADC, and
adcVal = 366.
Rt = 10,000 * ((1023 / 366) – 1)
= 10,000 * (2.03)
= 17,951 ohms

Once you calculate the value for Rt, you can use a look-up table containing temperature- resistance
data for your thermistor to find the corresponding temperature. The calculated resistance for the
thermistor in the above example corresponds to a temperature of approximately

10°C.
9 18,670
10 17,926
11 17,214

Alternatively, you can use an equation that approximates the thermistors temperature
response curve to calculate the temperature. For example, the widely used Steinhart-Hart
equation shown below. It is not as exact as the manufacturer's resistance-temperature data.
However, compared to other methods, it provides a much closer approximation of the
thermistor's response curve over its operational range.

1/T = A + B*ln(R) + C*(ln(R))^


PROGRAM 1:

void setup() {
Serial.begin(9600); /* Define baud rate for serial communication */
}

void loop() {
int thermistor_adc_val;
double output_voltage, thermistor_resistance, therm_res_ln, temperature;
thermistor_adc_val = analogRead(thermistor_output);
output_voltage = ( (thermistor_adc_val * 5.0) / 1023.0 );
thermistor_resistance = ( ( 5 * ( 10.0 / output_voltage ) ) - 10 ); /* Resistance in kilo ohms */
thermistor_resistance = thermistor_resistance * 1000 ; /* Resistance in ohms */
therm_res_ln = log(thermistor_resistance);
/* Steinhart-Hart Thermistor Equation: */
/* Temperature in Kelvin = 1 / (A + B[ln(R)] + C[ln(R)]^3) */
/* where A = 0.001129148, B = 0.000234125 and C = 8.76741*10^-8 */
temperature = ( 1 / ( 0.001129148 + ( 0.000234125 * therm_res_ln ) +
( 0.0000000876741 * therm_res_ln * therm_res_ln * therm_res_ln ) ) ); /* Temperature in Kelvin */
temperature = temperature - 273.15; /* Temperature in degree Celsius */
Serial.print("Temperature in degree Celsius = ");
Serial.print(temperature);
Serial.print("\t\t");
Serial.print("Resistance in ohms = ");
Serial.print(thermistor_resistance);
PROGRAM 2:

void setup() {
Serial.begin(115200);
}
void loop() {
int ntc_data = analogRead(A0);
Serial.println(ntc_data);
delay(100);
}

RESULT:
3. GENERATE PWM OUTPUT

AIM: To generate PWM Wave output using Arduino Uno/arduino duemilanove board

APPARATUS:
1. Development Board.
2. Arduino Uno/duemilanovo board.
3. 50/100 MHz DSO/CRO
4. 12V Adaptor.
5. Power jack.
6. USB Cable.
7. Jumper Wires.

THEORY:

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital
means. Digital control is used to create a square wave, a signal switched between on and off. This
on- off pattern can simulate voltages in between the full Vcc of the board (e.g., 5 V on UNO, 3.3
V on a MKR board) and off (0 Volts) by changing the portion of the time the signal spends on
versus the time that the signal spends off. The duration of "on time" is called the pulse width. To
get varying analog values, you change, or modulate, that pulse width. If you repeat this on- off
pattern fast enough with an LED for example, the result is as if the signal is a steady voltage
between 0 and Vcc controlling the brightness of the LED.
HARDWARE PROCEDURE:
 Select PWM pin from Arduino Uno/Duemilanove board.
 Connect PWM Pin from Arduino Uno/Duemilanove to Development Board.
 Connect PWM output pin from development board to DSO input.
 Power jack is connected to the Arduino Uno/Duemilanove
 USB connector is connected to Arduino Uno/Duemilanove and CPU.
 Connect the 12V power supply to development board.
 Upload corresponding program into Arduino Uno/Duemilanove board.
 Switch ON Power supply.
 Verify PWM wave output on DSO Screen.

SOFTWARE PROCEDURE:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on tools select Arduino Uno/Duemilanove and select port.
8. Click on Upload the code into Arduino Uno/Duemilanove by using USB cable.
PROGRAM:

void setup() {
// initialize digital pin 13 as an output.
pinMode(9, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
analogWrite(9,64); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
analogWrite(9,127); // turn the LED off by making the voltage LOW // wait for a second
delay(1000);
analogWrite(9,191); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
analogWrite(9,255); // turn the LED off by making the voltage LOW // wait for a second
delay(1000);
analogWrite(9,0); // turn the LED off by making the voltage LOW // wait for a second
delay(1000);

RESULT:
4.DRIVE SINGLE CHARACTER GENERATION ON HYPERTERMINAL

AIM: To drive single character on Hyper Terminal using Arduino Uno/Duemilanove board.

APPARATUS:
1. Development Board
2. Arduino duemilanove board
3. USB to Serial Converter sensor
4. 12V Adaptor
5. Power jack
6. USB Cable
7. Jumper Wires

PROCEDURE:

1. Click on Arduino IDE software.

2. Click on file
3.Click on New
4. Write a Program as per circuit Pin connections

5. Click on Save
6.Click on Verify
7. Click on Upload the code into Arduino Uno by using USB cable.

8. Connect the Circuit as per circuit diagram .

9. Connect arduino board to USB through RS232 cable and select comport on hyper terminal

10. observe output value On hyperterminal


PROGRAM:

char my_str[1]; // an array big enough for a 5 character string


void setup() {

Serial.begin(9600);

my_str[0] = 'H'; // the string consists of 5 characters

}
void loop() {
Serial.println(my_str);
}

RESULT:
5. DRIVE A GIVEN STRING ON HYPER TERMINAL

AIM: To drive a given string on hyper terminal

APPARATUS:
1. Arduino uno board-1
2. RS232 to TTL connector
3. RS232 to USB cable
4. 5V Adaptor
5. Bread board
6. USB Cable
7. Jumper Wires

THEORY:

Strings are used to store text. They can be used to display text on an LCD or in the Arduino
IDESerial Monitor window. A string is a special array that has one extra element at the end of the
string which always has the value of 0 (zero). This is known as a "null terminated string".

The string can be printed out to the Arduino IDE Serial Monitor window by
using Serial.println() and passing it the name of the string.

PROCEDURE:

1. Click on Arduino IDE software.

2. Click on file
3.Click on New
4. Write a Program as per circuit Pin connections

5. Click on Save
6.Click on Verify
7. Click on Upload the code into Arduino Uno by using USB cable.

8. Connect the Circuit as per circuit diagram .

9. Connect arduino board to USB through RS232 cable and select comport on hyper terminal

10. Observe output value On hyperterminal.

PROGRAM-1

void setup() {
char my_str[6]; // an array big enough for a 5 character string

Serial.begin(9600);

my_str[0] = 'H'; // the string consists of 5 characters


my_str[1] = 'e';
my_str[2] = 'l';
my_str[3] = 'l';
my_str[4] = 'o';
my_str[5] = 0; // 6th array element is a null terminator

Serial.println(my_str);
}

void loop() {

PROGRAM-2
void setup() {
char my_str[] = "Hello";
Serial.begin(9600);

Serial.println(my_str);
}

void loop() {
}

RESULT:
6. GENERATE ASCII TABLE USING ARDUINO

AIM: To generate ASCII table using arduino

APPARATUS:
1. Arduino uno board-1
2. 5V Adaptor
3. Bread board
4. USB Cable
5. Jumper Wires

THEORY:

It contains the character, followed by its ASCII code in decimal, hexadecimal, and
sometimes, even octal and binary representations. In this program, we will print out all these
representations for printable ASCII characters. Remember that the first printable ASCII character
starts from number 33, and the printable characters go on up to number 126. Since we will print
out the ASCII table on the Serial Monitor, we will concern ourselves with only printable
characters. Let us begin the walkthrough of this code. As you can see, we begin with the
initialization of Serial in the setup and then wait for the Serial port to connect. After that, we just
print the title of the sketch. Within the loop, we print the value of this Byte as a character (using
Serial.write()), then we print its decimal value (using Serial.print()), and then we print its
hexadecimal, octal and binary representations, using format specifiers in Serial.print().

We later increment the value of this Byte, until we reach the value of 126, after which we enter an
infinite loop, and essentially do nothing.

PROCEDURE:

1. Click on Arduino IDE software.

2. Click on file

3. Click on New

4. Write a Program as per circuit Pin connections


5. Click on Save

6. Click on Verify

7. Click on Upload the code into Arduino Uno by using USB cable.

8. Connect the Circuit as per circuit diagram.

9. Observe output value on serial monitor.

PROGRAM:

void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("ASCII Table ~ Character Map");
}

// first visible ASCIIcharacter '!' is number 33:


int thisByte = 33;
void loop() {
// prints value unaltered, i.e. the raw binary version of the byte.
// The Serial Monitor interprets all bytes as ASCII, so 33, the first number,
Serial.write(thisByte);

Serial.print(", dec: ");


// prints value as string as an ASCII-encoded decimal (base 10).
// Decimal is the default format for Serial.print() and Serial.println(),
// so no modifier is needed:
Serial.print(thisByte);
// But you can declare the modifier for decimal if you want to.
// this also works if you uncomment it:
// Serial.print(thisByte, DEC);
Serial.print(", hex: ");
// prints value as string in hexadecimal (base 16):
Serial.print(thisByte, HEX);

Serial.print(", oct: ");


// prints value as string in octal (base 8);
Serial.print(thisByte, OCT);

Serial.print(", bin: ");


// prints value as string in binary (base 2) also prints ending line break:
Serial.println(thisByte, BIN);

// if printed last visible character '~' or 126, stop:


if (thisByte == 126) { // you could also use if (thisByte == '~') {
// This loop loops forever and does nothing
while (true) {
continue;
}
}
// go on to the next character
thisByte++;
delay(500);
}

RESULT:
5.Full Duplex Link Establishment Using HyperTerminal

AIM: To drive single character on Hyper Terminal using arduino Uno/duemilanove board.
APPARATUS:
8. Development Board
9. Arduino duemilanove board
10. USB to Serial Converter sensor
11. 12V Adaptor
12. Power jack
13. USB Cable
14. Jumper Wires

THEORY:

Communication is of two types, simplex, where the role of the sender and receiver are fixed
(one way) and duplex, where either side is capable of sending and receiving (both ways). Duplex
communication is further divided into half-duplex, where only one side can send data at a given
moment (the other side recieves and waits for their turn) and full-duplex, where both sides can
simultaneously transmit and receive data. The communication between your PC and Arduino is
full-duplex

A PC has a USB port, which the operating system (like Windows) presents as a virtual
COM (communication) port for the Arduino IDE to use. The Arduino board, on the other end, has
a built-in Serial port along with a USB-UART converter. The converter on the Arduino, allows
outgoing data to be converted to USB, and incoming data to be converted to UART.
The hardware is then abstracted upon via software on both ends. On the Arduino’s side,
the running program uses the Serial library (a collection of functions) to read/write data. The
program you write will use the Serial library’s functions and methods to be able to use the port.

On the PC, the user can see the data received from Arduino or send back data usingthe Serial
monitor built in to the Arduino IDE. The Serial monitor is a program that ships with the Arduino
IDE and allows you to view the data (and also send some back) which is being sent on the virtual
Serial port which your Arduino connects to. It can be opened by going to Tools>Serial monitor

PROCEDURE:

1. Click on Arduino IDE software.

2. Click on file

3. Click on New

4. Write a Program as per circuit Pin connections

5. Click on Save

6. Click on Verify

7.Click on Upload the code into Arduino Uno by using USB cable.

Connect arduino board to USB through RS232 cable and select comport on HyperTerminal

8. Observe the data which prints on HyperTerminal.

9. Enter your text and observe the same on HyperTerminal


PROGRAM 1:

#include <LiquidCrystal.h>

const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

char rx_byte = 0;
String rx_str = "";

void setup() {
Serial.begin(9600);
lcd.begin(16,2);
//Serial.println("Enter your Data");
lcd.setCursor(0,0);
lcd.print("Enter Your Data");
}
void loop() {
if (Serial.available() > 0) {
rx_byte = Serial.read();

if (rx_byte != '\n') {
rx_str += rx_byte;
}
else {
// end of string
Serial.println(rx_str);
lcd.setCursor(0,1);
lcd.print(rx_str);
rx_str = "";
Serial.println("");
Serial.println("Enter Your Data");
}
}
PROGRAM 2:

int led = 6;
int buzzer = 7;

char data = 0;

void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
}

void loop() {
if(Serial.available()) {
data = Serial.read();
//Serial.println(data);
Serial.print("\n");
if(data == 'a')
digitalWrite(led, HIGH);
else if(data == 'b')
digitalWrite(led, LOW);
if(data == 'c')
digitalWrite(buzzer, HIGH);
else if(data == 'd')
digitalWrite(buzzer, LOW);
else if(data == 'e')
Serial.println("STT-MANI");
}
}

RESULT:
8. DRIVE A GIVEN VALUE ON A 8 BIT DAC

AIM: To convert given digital data in to analog data using R-2R ladder circuit

APPARATUS:
1. Arduino uno board-1
2. 5V Adaptor
3. Bread board
4. Resistors 10k-8 NO
5. Resistors 22k-8 NO
6. USB Cable
7. Jumper Wires

CIRCUIT DIAGRAM:
USING R-2R LADDER:
THEORY:

Digital to Analog Converter (DAC) is a system that converts digital signal to its corresponding
analog signal. The R-2R Ladder is one of the most popular DAC converters because of its
simplicity. It utilizes only two values of resistors and it can be extended to any number of bits.
The number of levels are equal to two power the number of bits. In this project, 8 bits means there

will be 256 levels. We can calculate the maximum voltage output by this equation.

and the voltage output equation for R-2R DAC itself is this :

As you can see in the circuit, there are 8 digital input from b0 to b7 that represent each bit.
It’s inthe format of LSB. I used R = 1k ohm resistors because It’s the one that I already have so
many and I can get 2R by series 1k ohm resistor to be 2k ohm easily.

From the simulation, we know that the highest logic 11111111 (or 255 in decimal) is giving
4.96V at the output voltage and the 00000000 (or 0 in decimal) logic gives 0V. And 10000000
(128 in decimal) gives exactly 2.5V. This result proves that the Voltage output of the R-2R Ladder
DAC Equation is right.

PROCEDURE:
1. Click on Arduino IDE software.

2. Click on file

3. Click on New

4. Write a Program as per circuit Pin connections

5. Click on Save

6.Click on Verify

7. Click on Upload the code into Arduino Uno by using USB cable.
8. Connect the Circuit as per circuit diagram .

9. Observe output value On serial plotter

SINE WAVE:

PROGRAM:
int valSin;
void setup()
{
Serial.begin(9600);
DDRD = B11111111; // Port D at Arduino Uno (pin 0-7)
}
void loop() {
for (int i = 0; i < 360; i++) { //looping the value of i from 0 to 360 degree
valSin = ((sin(i * DEG_TO_RAD) + 1) * 255) / 2; // creating the sinwave from i, 255 is the
highest value in 8 bit (0-255)
PORTD = valSin; // assign the sinwave to
portDdelay(10); // set the delay of the
analog value
Serial.println(analogRead(A0));
}
}
RAMP SIGNAL

PROGRAM:

void setup()
{
Serial.begin(9600);
DDRD = B11111111; // Port D at Arduino Uno (pin 0-7)
}
void loop()
{
for ( int i = 0; i < 256; i++) { //looping the value of i from 0 to 255, creating a ramp wave from
0 to 255, it's more like stairs wave
PORTD = i; // the integer value of i is automatically translated to binary and assign to port D,
ex 3 is automatically transformed into 00000011 which means only pin 0 and pin 1 is high (1)
and the other pin is low (0)
delay(10); // set the delay of the analog
value Serial.println(analogRead(A0));
}
}

RESULT:
9. STEPPER MOTOR INTERFACING WITH ARDUINO
DUEMILANOVE

AIM: To interface Stepper motor with arduino duemilanove board.

APPARATUS:
1. Development Board.
2. Arduino duemilanove board.
3. Stepper Motor.
4. 12V Adaptor.
5. Power jack.
6. USB Cable.
7. Jumper Wires.

THEORY:

DRV8825
The DRV8825 stepper motor driver carrier is a breakout board for TI’s DRV8825 micro-
stepping bipolar stepper motor driver. The DRV8825 features adjustable current limiting,
over-current and over temperature protection, and six microstep resolutions (down to 1/32-step).
It operates from 8.2 – 45 V and can deliver up to approximately 1.5 A per phase without a heat
sink or forced air flow (rated for up to 2.2 A per coil with sufficient additional cooling).

8. 28BYJ-48 stepper
The 28BYJ-48 stepper motor is a commonly used stepper motor. which converts electrical
pulses into discrete mechanical rotation. When electrical signals are applied, the stepper motor
rotates in precise and fixed angle increments known as steps. The motor consists of 4 coils that
make a ring around the rotor. These coils are known as the stator, as they are stationary and static.
Each coil is rated at +5V, making it easy to control with any microcontroller, such as an Arduino.
HARDWARE PROCEDURE:
 Insert Stepper motor into Stepper motor Jack.
 Connect Analog pins [A0,A1,A2,A3] to ULN2004 input to drive Stepper motor,
 Power jack is connected to the Arduino Uno/Arduino duemilanove.
 USB connector is connected to Arduino Uno/Arduino duemilanove and CPU.
 Connect the 12V power supply to development board.
 Upload corresponding program into Arduino Uno/arduino duemilanove.
 Switch ON Power supply of development kit.

SOFTWARE PROCEDURE:
ARDUINO IDE:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on tools select Arduino Uno/Aduino duemilanove and select port.
8. Click on Upload the code into Arduino Uno/Arduino duemilanove by using USB cable.
9. Verify Output.
PROGRAM:
#include <Stepper.h>

#define STEPS 2038 // the number of steps in one revolution of your motor (28BYJ-48)

Stepper stepper(STEPS, A0, A1, A2, A3);

void setup() {
// nothing to do
}

void loop() {
stepper.setSpeed(13); // 1 rpm
stepper.step(2038); // do 2038 steps – corresponds to one revolution in one minute
delay(1000); // wait for one second
stepper.setSpeed(13); // 6 rpm
stepper.step(-2038); // do 2038 steps in the other direction with faster speed – corresponds to one
revolution in 10 seconds
delay(1000);
}

RESULT:
10.ACCELEROMETER SENSOR (ADXL335) INTERFACING WITH
ARDUINO UNO/ARDUINO DUEMILANOVE

AIM: To Display X,Y,Z angles on Hyper Terminal using Arduino Uno/arduino duemilanove board and
ADXL335.
APPARATUS:
9. Development Board.
10. Arduino Uno/Arduino duemilanove board.
11. Accelerometer Sensor (ADXL335).
12. 12V Adaptor.
13. Power jack.
14. USB Cable.
15. Jumper Wires.

THEORY:

Accelerometers are widely used in low-power, low-cost motion and tilt sensing applications
such as mobile devices, gaming systems, disk drive protection, image stabilization, and sports and
health devices.
At the core of the module is a small, low-power, low-noise triple axis MEMS accelerometer
from Analog Devices – ADXL335. It can measure not only static acceleration caused by gravity, but
also dynamic acceleration caused by motion, shock, or vibration. This breadboard-friendly module
breaks out every pin of the ADXL335 to a 6-pin, 0.1′′ pitch header, including 3 analog outputs for
X, Y, and Z axis measurements, 2 supply pins, and a self-test pin.

The ADXL335 operates on 1.8V to 3.6VDC (typically 3.3V). However, the on-board 3.3V
regulator makes it ideal for interfacing with 5V microcontrollers like the Arduino.

The ADXL335 has a full sensing range of ±3g. Meaning the maximum amount of acceleration
that the ADXL335 can accurately measure and represent as an output is ±3g. If it is accelerated at
4g, for example, the accelerometer will not break, but the output may rail.
HARDWARE PROCEDURE:
 Insert ADXL Sensor to Sensor Jack.
 Connect Analog pins [A1,A2,A3] to ADXL335 input to read X,Y,Z Axes,
 Power jack is connected to the Arduino Uno/Arduino duemilanove.
 USB connector is connected to Arduino Uno/Arduino duemilanove and CPU.
 Connect the 12V power supply to development board.
 Upload corresponding program into Arduino Uno/arduino duemilanove.
 Switch ON Power supply of development kit.

SOFTWARE PROCEDURE:
ARDUINO IDE:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on tools select Arduino Uno/Aduino duemilanove and select port.
8. Click on Upload the code into Arduino Uno/Arduino duemilanove by using USB cable.
9. Verify OUTPUT.
HYPER TERMINAL SOFTWARE:
 Install Hyper Terminal Software.
 Open Hyper terminal.
 Select Port.
 Select Buard rate, Start bit and Stop bit.
 Check X,Y,Z, Angles data on HyperTerminal.
PROGRAM:
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("X = : ");
Serial.print(analogRead(xpin));
Serial.print("\t");
Serial.print("\t");
Serial.print("Y = : ");
Serial.print(analogRead(ypin));

Serial.print("\t");
Serial.print("\t");
Serial.print("Z = : ");
Serial.print(analogRead(zpin));

Serial.println();
delay(500);
}

RESULT:

You might also like