ES Experiment No. 05 B-10
ES Experiment No. 05 B-10
Experiment No. 05
Aim –
To display GCD code on LCD.
Software used –
Tinkercad.
Components used –
Arduino Uno, Resistors (220 ohm), Breadboard small, LCD 16x2, Connecting wires.
Procedure –
Open the Tinkercad software.
Create new project.
Select all the components.
Connect the components appropriately.
1. LCD RS pin to digital pin 7.
2. LCD Enable pin to digital pin 6.
3. LCD D4 pin to digital pin 5.
4. LCD D5 pin to digital pin 4.
5. LCD D6 pin to digital pin 3.
6. LCD D7 pin to digital pin 2.
7. LCD VCC pin to +5V .
8. LCD GND pin to POT.
Write the code in the text box.
Click on start simulation.
Once the simulation is started, the monitor asks for number 1 and number 2. After
that the numbers will get compared and we will get the GCD of two numbers
displayed on the LCD.
Code –
#include<LiquidCrystal.h
> #include<stdio.h>
#include<stdlib.h>
int number_1;
int number_2;
int dividend;
int euclid_gcd(int number_1, int number_2);
LiquidCrystal lcd(7,6,5,4,3,2);
void setup()
{
Serial.begin(9600);
Serial.println("Enter first number: ");
while(Serial.available() == 0) {}
number_1 = Serial.parseInt();
Serial.println(number_1);
Serial.begin(9600);
Serial.println("Enter second number: ");
while(Serial.available() == 0) {}
number_2 = Serial.parseInt();
Serial.println(number_2);
dividend = euclid_gcd(number_1, number_2);
}
void loop()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(dividend)
; delay(1000);
}
Output –
Here, the two input numbers are, 36 and 15.
Conclusion –
Hence, we studied the GCD code by interfacing of LCD with Arduino.
***