UNIVERSITY OF PENNSYLVANIA
DEPARTMENT OF ELECTRICAL ENGINEERING
ESE UNDERGRADUATE LABORATORY
ESE 205: Electrical Circuits and Systems I
Laboratory
Measurement of gain (Av) of non-inverting
amplifier using Arduino Board
Goal: To measure and display the gain of a non-inverting amplifier using an Arduino Board
interfaced with 16x2 LCD Display.
Parts Required
1.
2.
3.
4.
5.
6.
7.
8.
Arduino Board
USB Cable
LM 741
1k Ohm Resistor
10k Ohm Potentiometer
5k Ohm Potentiometer
Digital Multi-meter (DMM)
Wires
Procedure:
a. Non-inverting Amplifier circuit
Build a non-inverting amplifier circuit as shown in Figure 1
Figure 1: Non-inverting Amplifier
Document1
Page 1 of
6
The Pin 7 and Pin 4 of LM 741 (Figure
2) are connected to the external power
supply of +15V and -15V respectively.
Please take care not to short any of the
Analog Input pins and the Digital I/O
pins of the Arduino board with the
external power supply. The ground of
the external power supply must be
connected to the ground bus of the
Arduino board
Figure 2: LM 741 – Operational Amplifier
Figure 3: Arduino Board
b. Compile and download the working code to the Arduino Board
Compile the following code in Arduino IDE and download it to the Arduino Board.
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int opampInputPin
= 4; // Analog Input Pin to measure the Vin - input to the OPAMP
int opampOutputPin = 0; // Analog Input Pin to measure the Vout - output of the OPAMAP
Document1
Page 2 of
6
int opampInputValue = 0; // variable to store the Integer Value of Vin - input to the OPAMP
int opampOutputValue = 0; // variable to store the Integer Value of Vout - output of the OPAMAP
float gain
= 0; // variable to store the GAIN value of the OPAMP
float opampInput = 0; // variable to store the actual value of Vin - input to the OPAMP
float opampOutput = 0; // variable to store the actual value of Vout - output to the OPAMP
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
}
void loop(){
// refresh the display to update calculated values
lcd.clear();
if(opampOutput <5.0){
// to calculate Vin - Input Votlage to the OPAMP
opampInputValue = analogRead(opampInputPin);
opampInput = ( ( float(opampInputValue)/1023 ) * 5 );
// to measure Vout - Output Voltage of the OPAMP
opampOutputValue = analogRead(opampOutputPin);
opampOutput = ( ( float(opampOutputValue)/1023 ) * 5);
// to calculate the GAIN of the OPAMP
gain = (opampOutput/opampInput);
// display Vin - Input Voltage of OPAMP
lcd.setCursor(0,0);
lcd.print("Vin :");
lcd.print(opampInput);
// display Vout - Output Voltage of OPAMP
lcd.setCursor(0,1);
lcd.print("Vout:");
Document1
Page 3 of
6
lcd.print(opampOutput);
//display Gain of the OPAMP
lcd.setCursor(12,0);
lcd.print("Gain");
// adjust display if GAIN is greate than 10
if( ((int)gain/10) >=1 ){
lcd.setCursor(11,1);
lcd.print(gain);
}
else{
lcd.setCursor(12,1);
lcd.print(gain);
}
delay(250);
}
// if OPAMP output is greater than 5, which can't be measured by the Arduino Board
else{
lcd.print("Vout is > 5!");
//blink
lcd.noDisplay();
delay(250);
lcd.display();
delay(250);
// to monitor the value of Vout - Output Voltage of OPAMP
// to calculate Vout - Output Voltage of the OPAMP
opampOutputValue = analogRead(opampOutputPin);
opampOutput = ( ( float(opampOutputValue)/1023 ) * 5);
}
}
Document1
Page 4 of
6
c. Display amplifier input, amplifier output and gain
In order to display the measured values you will have to wire the 16x2 LCD display (Figure 4) to
6 Digital Output pins of the Arduino board.
Wire the pins according to the following assignments:
LCD
1
2
3
4
5
6
7 8 9 10 11 12 13 14 15
Arduino
GND +5V GND 12 GND 11 Board
LCD Pin 1
-
-
-
5
4
3
2
16
+5V GND
LCD Pin 16
Figure 4: 16X2 Liquid Crystal Display
LCD Display library functions are used interface the Digital I/O pins of the Arduino board with
the LCD Display. ‘lcd.print(“xxxxx”)’ function is used to display the measured values. Refer to
the above code.
d. Change Vin- Input Voltage of the non-inverting amplifier
The input voltage Vin of the non-inverting amplifier can be changed by varying R3(5k Ohm
Potentiometer). The change in value of Vin is displayed real-time in the LCD Display.
e. Change the Gain of the amplifier:
The gain Av of the non-inverting amplifier
Av = Vout/Vin = 1 + (R2/R1)
The value of R1 (1k Ohm) is fixed. The gain of the non-inverting amplifier can be changed by
varying R2 (10k Ohm potentiometer). The change in value of Av is displayed real-time in the
LCD Display.
Document1
Page 5 of
6
Please note that the Arduino analog Input pins can’t measure values beyond +5V. To obtain a
range of gain Av values you can change the input voltage Vin by changing the value of R3(5k
Ohm Potentiometer). Whenever your amplifier output is greater than +5V the LCD display will
blink Vout > 5V, change the value of Vin by changing R3 or change the value of Av by changing
R2 to make Vout less than or equal to 5.00V
Set the input voltage of the non-inverting amplifier (Vin) to different values between 0.01V and
5.00V, change the gain (Av) by varying R2. Measure the value of R2 using DMM, calculate the
theoretical value of gain (Av) and record the practical value of gain (Av).
Vin (Voltage)
R2 (Ohms)
Theoretical Value of Av
Practical Value of Av
g. Questions:
i.
ii.
iii.
Explain how do you measure/calculate the following using the Arduino Board?
a. Input Voltage(Vin)
b. Ouput Voltage(Vout)
c. Gain(Av)
What are the maximum and minimum gain values of the non-inverting amplifier that
can be measured using this Arduino board set-up?
Can the Arduino board be used to measure gain of an inverting amplifier?
GOOD LUCK!
Figure 5: Measurement of gain (Av) of a
Non-inverting amplifier using Arduino Board
Document1
Page 6 of
6
© Copyright 2026 Paperzz