Professional Documents
Culture Documents
Arm Lab)
Arm Lab)
Expt. No: 1
Date:
Measure Analog signal from Temperature Sensor
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
LM35 SENSOR:
LM35 is a temperature sensor which can measure temperature in the range of -55°C to 150°C. It is a
3-terminal device that provides analog voltage proportional to the temperature. Higher the
temperature, higher is the output voltage. The output analog voltage can be converted to digital form
using ADC so that a microcontroller can process it.
Measuring the temperature of surroundings using LM35 and displaying it on the serial monitor of Arduino.
Here, LM35 output is given to analog pin A0 of Arduino UNO. This analog voltage is converted to its digital
form and processed to get the temperature reading.
1
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
CIRCUIT CONFIGURATION:
PROCEDURE:
Hardware Procedure:
Software Procedure:
2
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Program:
void setup()
Serial.begin(9600);
void loop()
int a = analogRead(A0);
Serial.println(a);
int mv = a * 4.88;
Serial.print(mv);
Serial.println("mv");
delay(1000);
void setup()
Serial.begin(9600);
void loop()
int a = analogRead(A0);
Serial.println(a);
3
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Serial.print("Temperature = ");
Serial.println(temp);
delay(1000);
Precautions:
Output:
LM35 sense the surrounding temperature and that temperature shown by serial monitor using Arduino board.
Result:
4
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 2
Date:
Generate PWM output
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
Arduino Uno has 6 8-bit PWM channels. The pins with symbol ‘~’ represents that it has PWM support.
These PWM pins are shown in below image.
5
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Pulse Width Modulated signals with different duty cycle are shown below
b) Frequency of Signal:
The frequency of a signal determines how fast the PWM completes a cycle which means
how fast it switches between ON (high) and OFF (low) states. By repeating this ON-OFF
pattern at a fast-enough rate, and with a certain duty cycle, the output will appear to
behave like a constant voltage analog signal when providing power to devices.
6
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
CIRCUIT CONFIGURATION:
PROCEDURE:
Hardware Procedure:
Software Procedure:
7
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Program:
int led = 6;
void setup() {
analogWrite(6,50);
int i;
void loop() {
analogWrite(6,i);
delay(20);
delay(1000);
analogWrite(6,i);
delay(20);
delay(1000);
8
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Precautions:
Output:
Generated PWM wave using Arduino board.
Result:
\
Signature of the Faculty
9
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 3
Date:
Drive Single Character Generation on Hyper Terminal
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
HYPER TERMINAL:
HyperTerminal is a communications and terminal emulation program that came with the Windows 98
and Windows XP operating systems.
CIRCUIT CONFIGURATION:
10
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
PROCEDURE:
Hardware Procedure:
Software Procedure:
Program:
void setup() {
11
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
pinMode(2,OUTPUT);
void loop() {
if(Serial.available()){
char s = Serial.read();
Serial.println(s);
if(s=='2'){
digitalWrite(2,HIGH);
Serial.println("LED IS ON");
if(s=='1'){
digitalWrite(2,LOW);
Serial.println("LED IS OFF");
Precautions:
Output:
Single character generation on Hyper Terminal /Tera term using Arduino board.
Result:
12
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
13
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 4
Date:
Drive Given String on Hyper Terminal
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
HYPER TERMINAL:
HyperTerminal is a communications and terminal emulation program that came with the Windows 98
and Windows XP operating systems.
CIRCUIT CONFIGURATION:
14
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
PROCEDURE:
Hardware Procedure:
15
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Software Procedure:
Program:
void setup() {
pinMode(2,OUTPUT);
void loop() {
if(Serial.available()){
Serial.println(mystring);
if(mystring=='2'){
digitalWrite(2,HIGH);
Serial.println("LED IS ON");
if(mystring=='1'){
digitalWrite(2,LOW);
Serial.println("LED IS OFF");
Precautions:
16
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Output:
String generation on Hyper Terminal using Arduino board.
Result:
17
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 5
Date:
Full duplex Link establishment using Hyper terminal
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
One Arduino board act as master and another Arduino board act as slave.
HYPER TERMINAL:
HyperTerminal is a communications and terminal emulation program that came with the Windows 98
and Windows XP operating systems
CIRCUIT CONFIGURATION:
18
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
PROCEDURE:
Hardware Procedure:
Transmitter pin of one Arduino board is connected to another Arduino Uno pin Receiver.
Receiver pin of one Arduino board is connected to another Arduino Uno pin Transmitter.
Power jack is connected to the Arduino.
USB connector is connected to Arduino Uno to monitor.
Connect the 12V power supply to development board.
Check the output from the development board.
Software Procedure:
Click on Arduino IDE
Click on file
Click on New
Write a Program as per circuit Pin connections
Click on Save
Click on Verify
Click on Upload the code into Arduino Uno by using USB cable
19
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Program:
Code for Master:
void setup() {
void loop() {
delay(1000);
void setup() {
void loop() {
Serial.println(" RECEIVER");
delay(1000);
20
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Precautions:
Output:
Full duplex link shown by hyper terminal using Arduino board.
Result:
21
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 6
Date:
Drive A Given Value on A 8 Bit DAC Consisting Of SPI
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
Digital to Analog Converter (DAC) is mostly used to generate analog signals (e.g. sine wave, triangular wave
etc.) from digital values. In Particle Photon there are total 2 On-Board DAC Pins available, ADC6 (DAC1 or
A6) and ADC3 (DAC2 or A3).
analogWrite(DAC_pin, Value)
This function is used to set the analog value between 0-3.3V which corresponds to digital values 0-4095
Circuit Diagram:
22
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
PROCEDURE:
Hardware Procedure:
23
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Software Procedure:
Click on Arduino IDE
Click on file
Click on New
Write a Program as per circuit Pin connections
Click on Save
Click on Verify
Click on Upload the code into Arduino Uno by using USB cable
Program:
(or)
int value;
void setup() {
pinMode(DAC1, OUTPUT); //use DAC1 pin as a output pin
}
void loop(){
value = 0;
while ( value != 4095 ) //increament value till noe equal to 4095
{
analogWrite(DAC1, value);
value++; //increament value by one
24
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Precautions:
Output:
Connect the circuit (Arduino + MCP4911) on abreadboard. Use a multi-meter so see if you
get the correct output signal.
On the Multimeter you should see the output slowly increasing from ~0V to ~5V with
intervals of 1000ms.
You can also connect the output from the DAC to an Analog Input Pin on the Arduino. Write
the value to the Serial Monitor.
Result:
25
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 7
Date:
Drive Stepper motor using Analog GPIOs
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
STEPPER MOTOR:
Stepper motor is a brushless DC motor that divides the full rotation angle of 360° into a number of
equal steps. The motor is rotated by applying a certain sequence of control signals. The speed of
rotation can be changed by changing the rate at which the control signals are applied.
Rotating stepper motor in clockwise and counter clockwise directions alternately. Here, we are using six wire
unipolar stepper motor. Only four wires are required to control this stepper motor. The two centre tap wires of
the stepper motor are connected to 5V supply.
ULN2003 driver is used to drive the stepper motor.
26
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
CIRCUIT CONFIGURATION:
PROCEDURE:
Hardware Procedure:
Driver module pins of IN1,2,3,4 is connected to Arduino Uno digital pins of 7,6,5,4 respectively.
Power jack is connected to the Arduino.
USB connector is connected to Arduino Uno to monitor.
Connect the 12V power supply to development board.
Check the output from the development board.
Software Procedure:
Program:
void setup() {
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
/* Rotation in one direction */
for(int i = 0; i<12; i++)
{
27
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(100);
}
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
28
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
delay(100);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(100);
}
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
delay(100);
}
29
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Precautions:
Output:
Control signals given to rotate the stepper motor using Arduino board.
Result:
30
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Expt. No: 8
Date:
Drive Accelerometer and Display the readings on Hyper Terminal
APPARATUS REQUIRED:
THEORY:
ARDUINO BOARD:
Arduino platform offers open-source hardware and software that is easy to use and is used widely for
hobby projects and prototyping. Many libraries are provided with the software and a large number of
libraries developed by people from around the world are available for free. The functions implemented
in these libraries can be used for quick development purposes. This allows the user to use certain
interfaces or modules without having in depth knowledge about the internal structure or working.
ACCELEROMETER:
An accelerometer is a device that measures the vibration, or acceleration of motion of a structure.
There are two types of accelerometers in general: AC-response and DC-response.
Accelerometer is an electromechanical device that measures the force of acceleration due to gravity in
g unit. It can be used in applications requiring tilt sensing.
The ADXL335 measures acceleration along X, Y and Z axes and gives analog voltage output proportional to the
acceleration along these 3 axes. Microcontrollers can process these voltages by converting them to digital
signals using ADC.
31
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
CIRCUIT CONFIGURATION:
PROCEDURE:
Hardware Procedure:
The ADXL335 pins of VCC and GND is connected to Arduino Uno pins of 5V and GND respectively.
The ADXL335 output pins of X, Y, Z is connected to Arduino Uno analog pins of A1, A2, A3
respectively.
Power jack is connected to the Arduino.
USB connector is connected to Arduino Uno to monitor.
Connect the 12V power supply to development board.
Check the output from the development board.
Software Procedure:
32
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Program:
#include <math.h>
const int x_out = A1; /* connect x_out of module to A1 of UNO board */
const int y_out = A2; /* connect y_out of module to A2 of UNO board */
const int z_out = A3; /* connect z_out of module to A3 of UNO board */
void setup()
{
Serial.begin(9600);
}
void loop()
{
int x_adc_value, y_adc_value, z_adc_value;
double x_g_value, y_g_value, z_g_value;
double roll, pitch, yaw;
x_adc_value = analogRead(x_out); /* Digital value of voltage on x_out pin */
y_adc_value = analogRead(y_out); /* Digital value of voltage on y_out pin */
z_adc_value = analogRead(z_out); /* Digital value of voltage on z_out pin */
Serial.print("x = ");
Serial.print(x_adc_value);
Serial.print("\t\t");
Serial.print("y = ");
Serial.print(y_adc_value);
Serial.print("\t\t");
Serial.print("z = ");
Serial.print(z_adc_value);
Serial.print("\t\t");
//delay(100);
Serial.print("Roll = ");
Serial.print(roll);
Serial.print("\t");
Serial.print("Pitch = ");
Serial.print(pitch);
Serial.print("\n\n");
delay(1000);
}
33
ARM BASED/ AURDINO BASED PROGRAMMING (R20)
Precautions:
Output:
Accelerometer sense the vibrations of structure and that vibration directions shown by serial monitor using
Arduino board.
Result:
34