0% found this document useful (0 votes)
25 views20 pages

ATL 24 Nov

Uploaded by

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

ATL 24 Nov

Uploaded by

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

Program1:-

void setup()

{Serial.begin(9600);

void loop () {

Serial.println(" Enter the first number " );

while(Serial.available()==0) {// waiting for response

FNum=Serial.parseInt();//save the First num

Serial.print("First Number,");

Serial.println(FNum);

delay(10);

Serial.println(" Enter the Second number " );

while(Serial.available()==0) {// waiting for response

SNum=Serial.parseInt();//save the First num

Serial.print("Second Number,");

Serial.println(SNum);

delay(10);

Serial.println(FNum+SNum);
}

Output:-
int number;

void setup()

{Serial.begin(9600);

void loop () {

Serial.println(" hey! sir mam ,which no table do you want? " );

while(Serial.available()==0){

// waiting for response

number=Serial.parseInt();

for (int x=1;x<11;x++) {

Serial.print(number);

Serial.print("X");

Serial.print(x);

Serial.print("=");

Serial.println(number*x);

delay(500);

PROGRAM 2:-Write a program to print table based from user input.


Output:-
Date: 15 Dec 2023

Coding:-If-Else with ARDINO

String ans;

void setup()

{Serial.begin(9600);

Serial.println("Is it morning?,y/n" );

void loop () {

while(Serial.available()==0){

// waiting for response

ans=Serial.readString();

Serial.println(ans);

if(ans=="y")

Serial.print("Hello:)Good Morning!!!");

}
else

Serial.print("Hello:)Good Night!!!");

delay(500);

OUTPUT:-
Coding:-Calculator If-Else with ARDINO

float a;

float b;

String opt;

void setup()

{Serial.begin(9600);

void loop () {

Serial.println("Choose an operator (+,x,-,÷) " );//

while(Serial.available()==0){
// waiting for response

opt=Serial.readString();

delay(10);

Serial.println("Enter the first number." );

while(Serial.available()==0){

// waiting for response

a=Serial.parseFloat();

delay(10);

Serial.println("Enter the second number." );

while(Serial.available()==0){

// waiting for response

delay(10);

b=Serial.parseFloat();

if (opt=="+")

{ Serial.print(a);

Serial.print("+");

Serial.print(b);

Serial.print("=");

Serial.println(a+b);

delay(500);
}

if (opt=="-")

{ Serial.print(a);

Serial.print("-");

Serial.print(b);

Serial.print("=");

Serial.println(a-b);

delay(500);

if (opt=="x")

{ Serial.print(a);

Serial.print("x");

Serial.print(b);

Serial.print("=");

Serial.println(a*b);

delay(500);

if (opt=="÷")

{ Serial.print(a);

Serial.print("÷");

Serial.print(b);

Serial.print("=");

Serial.println(a/b);
delay(500);

else {

Serial.println("error");

}
Output:-
Coding:- Touch Sensor with ARDINO

int value;// variable to save the value of sensor

int S_pin=8;// varialble for the pon on which we have connected to the
sensor,digital input

void setup() {

pinMode(S_pin,INPUT);//0 to 3 input/output pin in case of sensor

Serial.begin(9600);// turn on the serial monitor to see the value of sensor

void loop() {

value=digitalRead(S_pin);//read the value of sensor

Serial.println(value);//Print the value on Serial Monitor


delay(10); }

Coding:-Touch_Sensor with LED


int value;// variable to save the value of sensor

int S_pin=8;// varialble for the pon on which we have connected to the sensor,digital input

void setup() {

pinMode(S_pin,INPUT);

pinMode(13,OUTPUT);//0 to 3 input/output pin in case of sensor

Serial.begin(9600);// turn on the serial monitor to see the value of sensor

void loop() {

value=digitalRead(S_pin);//read the value of sensor

Serial.println(value);//Print the value on Serial Monitorvoid setup() {


if(value==1){

digitalWrite(13,1);

else

digitalWrite(13,0);

delay(10);

Output:

You might also like