0% found this document useful (0 votes)
597 views5 pages

Arduino Practical Programming Examples

The document contains 8 Arduino code examples that demonstrate various functions: 1) A counter program that displays the seconds on an LCD screen. 2) A program that turns an LED on and off using a push button. 3) A program that prints all integer numbers from 0 to 99 using a for loop. 4) A program that reads a number from the serial monitor and prints its multiplication table. 5) A program that calculates and prints the square root of a given number. 6) A program that turns a buzzer on and off with a 1 second delay to create a buzzing sound. 7) A simple "Hello World" program for an LCD display. 8

Uploaded by

radharathour505
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)
597 views5 pages

Arduino Practical Programming Examples

The document contains 8 Arduino code examples that demonstrate various functions: 1) A counter program that displays the seconds on an LCD screen. 2) A program that turns an LED on and off using a push button. 3) A program that prints all integer numbers from 0 to 99 using a for loop. 4) A program that reads a number from the serial monitor and prints its multiplication table. 5) A program that calculates and prints the square root of a given number. 6) A program that turns a buzzer on and off with a 1 second delay to create a buzzing sound. 7) A simple "Hello World" program for an LCD display. 8

Uploaded by

radharathour505
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
  • Arduino Practical Question 1
  • Arduino Practical Question 3
  • Arduino Practical Question 2
  • Arduino Practical Question 5
  • Arduino Practical Question 4
  • Arduino Practical Question 6
  • Arduino Practical Question 7
  • Arduino Practical Question 8
  • Arduino Practical Questions 9-17
  • Arduino Practical Questions 18-19

Arduino Practical Questions/Answers

1. Arduino program to run a counter and display in LCD?


1. #include
2. int seconds = 0;
3. Adafruit_LiquidCrystal lcd(0);
4. void setup()
5. {
6. [Link](16,2);
7. [Link]("Start");
8. }
9. void loop()
10. {
11. [Link](0, 1);
12. [Link](seconds);
13. [Link](1);
14. delay(500); // Wait for 500 millisecond(s)
15. [Link](0);
16. delay(500); // Wait for 500 millisecond(s)
17. seconds += 1;
18. }

2. Arduino program to connect a led through push button?


int buttonState = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// read the state of the pushbutton value
buttonState = digitalRead(2);
if (buttonState == HIGH)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else {
digitalWrite(LED_BUILTIN, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}

3. Arduino program to print all integer number from 0 to 99


using for loop
void setup()
{
[Link](9600);
for(int a=0;a<100;a++)
{
[Link](a);
}
}
void loop()
{

}
4. Arduino program to read a integer number and print its
table
int num = 0;
int a;
void setup() {
[Link](9600);
}

void loop() {
if ([Link]() > 0)
{
num = [Link]();
[Link]("Table of : ");
[Link](num);
for(a=1;a<=10;a++)
{
[Link](num*a);
}
}
}

[Link] program to print the square root of a given


number
void setup() {

[Link](9600);

void loop() {

if ([Link]() > 0) {

float number = [Link]();

float squareRootValue = sqrt(number);

[Link]("Square Root of ");

[Link](number);

[Link](" is: ");

[Link](squareRootValue);

6. Arduino program to interface buzzer with Arduino board to buzz on off


with the delay of 1sec.
const int BUZZER = 9;//buzzer to arduino pin 9
void setup()
{
pinMode(BUZZER, OUTPUT);//7 Set buzzer - pin 9 as an output
}
void loop()
{
tone(BUZZER, 1000); // Send 1KHz sound signal...
delay(1000);//for 1 sec
noTone(BUZZER); //Stop sound...
delay(1000); //..for 1sec
}

[Link] program to print Hello word in LCD


#include
Adafruit_LiquidCrystal lcd(0);
void setup()
{
[Link](16,1);
[Link]("hello world");
}
void loop()
{

[Link] program to interface buzzer with LDR and LED


void setup()
{
[Link](9600);
pinMode(13,OUTPUT);
pinMode(8,OUTPUT);
pinMode(A0,INPUT);

}
void loop()
{
int signal;
signal=analogRead(A0);
[Link](signal);
if(signal>=400)
{
tone(8,1000);
digitalWrite(13,HIGH);
delay(100);
noTone(8);
digitalWrite(13,LOW);
delay(100);
[Link]("ALARM ACTIVATED");
}
else
{
noTone(8);
digitalWrite(13,LOW);
[Link]("ALARM DEACTIVATED");
}
}

Arduino Practical Questions/Answers 
1. Arduino program to run a counter and display in LCD? 
1. #include  
2. int seconds =
4. Arduino program to read a integer number and print its 
table 
int num = 0; 
int a; 
void setup() { 
  Serial.begin(9600);
noTone(BUZZER); //Stop sound... 
 
delay(1000); //..for 1sec  
} 
7.Arduino program to print Hello word in LCD 
#include

You might also like