Program 1:

Develop a program to blink 5 LEDs back and forth.

Aim:

To develop an Arduino program that makes 5 LEDs blink sequentially back and forth, creating a back-and-forth running light effect.





Component:

Circuit:


Procedure:

Step 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Click “Circuits” “Create new Circuit”

 

Step 2: Add Components

·        Drag and drop:

o   1 Arduino Uno

o   5 LEDs

o   5 Resistors

o   (Optional) 1 Breadboard Step 3: Wiring the LEDs

For each LED:

·        Anode (long leg) connect to a digital pin via a resistor (220 Ω):

o   LED1 Pin 2

o   LED2 Pin 3

o   LED3 Pin 4

o   LED4 Pin 5

o   LED5 Pin 6

·        Cathode (short leg) connect to GND Step 4: Add the Arduino Code

Click “Code” → change from Blocks to Text. Delete the default code and write the following:

 

Program Code:

int ledPins[] = {2,3,4,5,6};

int numLeds=5;

int delayTime=150;

void setup(){

  for(int i=0;i<numLeds;i++){

    pinMode(ledPins[i], OUTPUT);

  }

}

void loop(){

  for(int i=0;i<numLeds;i++){

    turnOnOnly(i);

    delay(delayTime);

  }

  for(int i=numLeds-2; i>0;i--){

    turnOnOnly(i);

    delay(delayTime);

  }

}

void turnOnOnly(int idx){

  for(int j=0;j<numLeds;j++){

    digitalWrite(ledPins[j],(j==idx));

  }

}

Step 5: Start Simulation

·        Click “Start Simulation”

·        LEDs will blink from left to right, then right to left, continuously

 Output:



Program 2:

Develop a program to interface a relay with Arduino board.

Aim

To interface a relay module with an Arduino board to control high voltage devices using Arduino’s digital output pin.

Components:

 

 

Circuits:




PROCEDURE:

Step 1: Open Tinkercad

1.       Go to: https://www.tinkercad.com/

2.       Log in or create a free account.

3.       Click on “Circuits” from the left menu.

4.       Click “Create New Circuit”.

 

 

Step 2: Add Components

Drag and drop the following components into your workspace:

·        Arduino Uno R3

·        Relay Module (5V)

·        Light Bulb

·        DC Power Supply (to simulate AC power)

·        Jumper wires

 

 

Step 3: Wiring the Components

Follow this wiring diagram (as shown in the image):

Arduino to Relay:

·        Digital Pin 7 IN pin of the Relay module

·        5V VCC on Relay

·        GND GND on Relay

Relay to Light Bulb & Power Supply:

·        Power supply positive (+) COM on Relay

·        NO (Normally Open) on Relay One terminal of the bulb

·        Other terminal of the bulb Power supply negative (-)


Step 4: Add the Code

Click the “Code” button and use Text (C++) mode.

 

 

Program Code:

void setup()

{

pinMode(13,OUTPUT);

}


void loop()

{

digitalWrite(13,HIGH);

  delay(1000);

    digitalWrite(13,LOW);

  delay(1000);

}

Step 5: Start Simulation

1.       Click “Start Simulation”.

2.       The relay should click every 2 seconds, toggling the bulb ON and OFF.




Output:




Program 3:

Develop a program to deploy an intrusion detection system using Ultrasonic and sound sensors.

Aim

To develop an intrusion detection system using an ultrasonic sensor to detect movement within a certain distance and a sound sensor to detect noise, triggering an alarm or indicator when an intrusion is detected.



Components:

 




Circuit:




PROCEDURE:

1.  Open Tinkercad:

·        Go to https://www.tinkercad.com

·        Log in or create a free account.

 

 

2.  Create a New Circuit:

·        Click on “Circuits” from the left-hand menu.

·        Click “Create New Circuit.”

 

 

3.  Add Components:

Drag and drop the following components into your workspace:

·        1x Arduino Uno R3

·        1x Ultrasonic Sensor HC-SR04

·        (Optional: 1x Breadboard if needed for future expansion)

4.  Connect the Ultrasonic Sensor:

Referencing your image, do the wiring as follows:

 

HC-SR04 Pin

Connects To

VCC

Arduino 5V

GND

Arduino GND

Trig

Arduino Digital Pin 9

Echo

Arduino Digital Pin 10

 

Use wires to make these connections. Match the colors as per your preference. The image uses:

·        Red for VCC

·        Black for GND

·        Green for Echo

·        Yellow for Trig


5.  Add the Code:

Click the "Code" button (top-right), select "Text" mode, then paste the following Arduino code:

 

 

Program code:

#define trigPin 9

#define echoPin 10

#define soundSensor A0

#define alertPin 13  


void setup() {

  Serial.begin(9600);

  pinMode(trigPin, OUTPUT);

  pinMode(echoPin, INPUT);

  pinMode(alertPin, OUTPUT);

}


void loop() {

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

  

  long duration = pulseIn(echoPin, HIGH);

  int distance = duration * 0.034 / 2;


  int soundLevel = analogRead(soundSensor);


  Serial.print("Distance: ");

  Serial.print(distance);

  Serial.print(" cm | Sound: ");

  Serial.println(soundLevel);


  if ((distance > 0 && distance < 50) || soundLevel > 600) {

    digitalWrite(alertPin, HIGH); 

  } else {

    digitalWrite(alertPin, LOW);  

  }


  delay(100);

}



 

6.  Start Simulation:

·        Click “Start Simulation.”

·        Open the Serial Monitor (click the small monitor icon or click the dropdown beside "Start Simulation").

·       
You should see the distance readings in centimeters. Output:



Serial Monitor:

Distance: 96 cm | Sound: 387

Distance: 96 cm | Sound: 685

Distance: 96 cm | Sound: 101

Distance: 114 cm | Sound: 88

Distance: 125 cm | Sound: 414

Distance: 125 cm | Sound: 593

Distance: 125 cm | Sound: 928

Distance: 125 cm | Sound: 49

Distance: 125 cm | Sound: 318

Distance: 125 cm | Sound: 91

Distance: 125 cm | Sound: 86

Distance: 125 cm | Sound: 311

Distance: 125 cm | Sound: 687

Distance: 125 cm | Sound: 924

Distance: 125 cm | Sound: 793

Distance: 125 cm | Sound: 897

Distance: 125 cm | Sound: 206

Distance: 125 cm | Sound: 320

Distance: 125 cm | Sound: 583

Distance: 125 cm | Sound: 660

Distance: 125 cm | Sound: 561

Distance: 125 cm | Sound: 358

Distance: 125 cm | Sound: 979

Distance: 125 cm | Sound: 555

Distance: 125 cm | Sound: 184

Distance: 125 cm | Sound: 225

Distance: 125 cm | Sound: 516

Distance: 125 cm | Sound: 932

Distance: 125 cm | Sound: 989

Distance: 125 cm | Sound: 1006

Distance: 125 cm | Sound: 717

Distance: 125 cm | Sound: 768


 

Program 4:

 

Develop a program to control a DC motor with Arduino board.

 

 

AIM

To develop a program that controls a DC motor using an Arduino board. Component:

 

 

 


 

 

 

 

 

 



Circuit :


PROCEDURE:

STEP 1: Open Tinkercad

·        Go to: https://www.tinkercad.com

·        Log in Click "Circuits" Click “Create New Circuit”

STEP 2: Add Components

From the components menu, drag and drop:

·        Arduino Uno R3

·        Breadboard

·        DC Motor

·        L298N Motor Driver (IC)

·        Jumper Wires

STEP 3: Make the Connections

🔌 L298N Motor Driver IC Pin Connections:

 

L298N Pin

Connects To

Pin 1 (Enable A)

Arduino Digital Pin 9

Pin 2 (Input 1)

Arduino Digital Pin 8

Pin 3 (Output 1)

One terminal of DC Motor

Pin 4 (GND)

GND (to Breadboard/Arduino)

Pin 5 (GND)

GND (to Breadboard/Arduino)

Pin 6 (Output 2)

Other terminal of DC Motor

Pin 7 (Input 2)

Arduino Digital Pin 7

Pin 8 (VCC for Motor)

External 5V (or 9V battery) (optional, or use 5V from Arduino if low-power motor)

Pin 9 (VCC for IC)

5V from Arduino

Make sure both GNDs of the Arduino and L298N are connected together (common ground).


STEP 4: Upload the Code

Click “Code” Text Mode Paste this Arduino code: Program Code:


  // C++ code

//

void setup()

{

  pinMode(11, OUTPUT);

  pinMode(9, OUTPUT);

}


void loop()

{

  digitalWrite(11,HIGH);

  digitalWrite(9,LOW);

  delay(3000); 

  digitalWrite(11,LOW);

  digitalWrite(9,LOW);

  delay(3000); 

  digitalWrite(9,HIGH);

  digitalWrite(11,LOW);

  delay(3000);

  digitalWrite(11,HIGH);

  digitalWrite(9,LOW);

  delay(3000); 

}

STEP 5: Start the Simulation

·        Click “Start Simulation”

·        The motor should spin forward for 2 seconds, pause, reverse for 2 seconds, then pause again in a loop


Output:

 


 

 

 

 

 

 

 

 




Program 5:

Develop a program to deploy smart street light system using LDR sensor.

AIM

To develop a program to deploy a smart street light system using an LDR (Light Dependent Resistor) sensor with an Arduino board.




Components:

 

Circuit:





PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Log in Click “Circuits” Click “Create New Circuit”

 

 

STEP 2: Add Components

Drag and drop the following into the workspace:

·        Arduino Uno R3

·        LDR sensor

·        2 LEDs

·        Resistors (220Ω and 10kΩ)

·        Jumper wires

 

 

STEP 3: Make the Circuit Connections

📷 LDR Circuit (Light Sensor)

·        Connect one leg of the LDR to 5V

·        Connect the other leg of the LDR to:

o   A0 (Analog pin) of Arduino

o   One side of 10kΩ resistor

·        Connect the other side of the 10kΩ resistor to GND

This forms a voltage divider for reading light levels on A0.

 

 

LEDs Circuit

·        Connect anode (long leg) of each LED to Digital Pin 8 and 9

·        Connect cathode (short leg) of each LED to GND through a 220Ω resistor

 

LED

Anode

Cathode

LED1

Pin 8

GND via 220Ω


LED

Anode

Cathode

LED2

Pin 9

GND via 220Ω

 

STEP 4: Add the Arduino Code

Click on “Code” Select "Text" mode Paste this code: Program code:

const int LDR_PIN = A0; 

const int LED_PIN = 9; 

int threshold = 600;  

void setup() { 

pinMode(LED_PIN, OUTPUT); 

Serial.begin(9600); 

void loop() { 

int ldrValue = analogRead(LDR_PIN); 

Serial.println(ldrValue);   

if (ldrValue < threshold) { 

digitalWrite(LED_PIN, HIGH);   

} else { 

digitalWrite(LED_PIN, LOW);    

delay(500); 

STEP 5: Start the Simulation

·        Click “Start Simulation”

·        Open the Serial Monitor to view the LDR value

·        Block the LDR (with your cursor or simulate dark conditions)

o   LED1 should turn ON (LED2 OFF) in dark

o   LED2 should turn ON (LED1 OFF) in bright light




Output:




Program 6:

Develop a program to classify dry and wet waste with the Moisture sensor (DHT22).

AIM:

Develop a program to classify dry and wet waste using a DHT22 sensor based on humidity readings.



Components:


 



Circuit:




PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Login Go to "Circuits" Click “Create New Circuit”

 

 

STEP 2: Add Components

Drag the following components into your circuit:

·        Arduino Uno R3

·        Soil Moisture Sensor (with fork and amplifier module)

·        2 LEDs (Green and Blue)

·        2 Resistors (220Ω)

·        Jumper wires

 

 

STEP 3: Wire the Circuit

🔌 Soil Moisture Sensor Connections:

 

Soil Sensor Pin

Connects To

VCC

Arduino 5V

GND

Arduino GND

A0 (Analog Out)

Arduino A0

 

 

LED Connections:

 

LED Color

Anode (Long Leg)

Cathode

Green

Digital Pin 8

GND via 220Ω

Blue

Digital Pin 9

GND via 220Ω

 

Use resistors in series with the LEDs to prevent burning them out.


STEP 4: Add the Arduino Code

Click “Code” Select “Text” mode and paste the following code: Program code:

const int PH_PIN = A0;  // Simulated pH analog input 

 const int MOISTURE_PIN = A0; // Sensor analog pin

const int DRY_LED = 8; // Green LED for dry waste

const int WET_LED = 9; // Blue LED for wet waste

int threshold = 600; // Tune this value based on readings

void setup() {

 Serial.begin(9600);

 pinMode(DRY_LED, OUTPUT);

 pinMode(WET_LED, OUTPUT);

}

void loop() {

 int moistureValue = analogRead(MOISTURE_PIN);

 Serial.print("Moisture: ");

 Serial.println(moistureValue);

 if (moistureValue > threshold) {

 // Wet waste

 Serial.println("Classified: WET WASTE");

 digitalWrite(WET_LED, HIGH);

 digitalWrite(DRY_LED, LOW);

 } else {

 // Dry waste

 Serial.println("Classified: DRY WASTE");

 digitalWrite(DRY_LED, HIGH);

 digitalWrite(WET_LED, LOW);

 }

 delay(1000); // Wait for 1 second

}


STEP 5: Start the Simulation

·        Click “Start Simulation”

·        Open the Serial Monitor to view real-time moisture values

·        You can simulate wet/dry conditions by changing the soil sensor’s value in the simulation settings

 



OUTPUT:

'' failed to upload. Invalid response: Error code = 103, Path = /u/1/_/BloggerUi/data/batchexecute, Message = There was an error during the transport or processing of this request., Incomplete XSS header at end of request (HTTP Status: 502) (XHR Error Code: 6) (XHR Error Message: ' [502]')



Program 7:

Develop a program to read the pH value of a various substances like milk, lime and water.

AIM

To develop a program that reads the pH value of various substances such as milk, lime juice, and water using a pH sensor and Arduino board.



Components:



 





Circuit:



 

PROCEDURE:

STEP 1: Open Tinkercad

1.       Visit https://www.tinkercad.com

2.       Log in Go to “Circuits” Click “Create New Circuit”

 

 

STEP 2: Add Components

Drag the following components into your workspace:

·        Arduino Uno R3

·        Potentiometer

·        Jumper wires

 

 

STEP 3: Wiring the Potentiometer

A potentiometer has 3 pins:

·        Left pin Connect to GND

·        Right pin Connect to 5V

·        Middle pin (wiper) Connect to Analog Pin A0 Wiring summary based on your image:

 

Potentiometer Pin

Connects To

Left

GND (Black wire)

Right

5V (Red wire)

Middle (wiper)

A0 (Green wire)


 

STEP 4: Add the Arduino Code

Click "Code" Select “Text” Mode Paste the following code:

 

 

 

 

Program Code:

const int PH_PIN = A0;  // Simulated pH analog input 

 

void setup() { 

  Serial.begin(9600); 

 

void loop() { 

  int analogValue = analogRead(PH_PIN);      // Range: 0–1023 

  float voltage = analogValue * (5.0 / 1023.0); // Convert to voltage (0–5V) 

   

  // Simulate pH scale: 0V = pH 0, 5V = pH 14 

  float pHValue = voltage * (14.0 / 5.0); 

 

  Serial.print("Analog: "); 

  Serial.print(analogValue); 

  Serial.print(" | Voltage: "); 

  Serial.print(voltage); 

  Serial.print(" V | pH Value: "); 

  Serial.println(pHValue); 

 

  // Classify substance based on pH 

  if (pHValue < 3.0) { 

    Serial.println("Substance: Lime Juice (Strong Acid)"); 

  } else if (pHValue >= 6.0 && pHValue < 7.0) { 

    Serial.println("Substance: Milk (Weak Acid)"); 

  } else if (pHValue >= 7.0 && pHValue <= 7.5) { 

    Serial.println("Substance: Water (Neutral)"); 

  } else { 

    Serial.println("Substance: Unknown"); 

  }

  delay(1000); 

 

STEP 5: Start the Simulation

·        Click “Start Simulation”

·        Open the Serial Monitor (click the monitor icon)

·        Turn the potentiometer knob in the simulation

o   
You will see values ranging from 0 (min) to 1023 (max) based on the position

 

 

 

 

 

 

 

Output:



Substance: Unknown

Analog: 818 | Voltage: 4.00 V | pH Value: 11.19 Substance: Unknown

Analog: 818 | Voltage: 4.00 V | pH Value: 11.19 Substance: Unknown

Analog: 818 | Voltage: 4.00 V | pH Value: 11.19 Substance: Unknown

Analog: 143 | Voltage: 0.70 V | pH Value: 1.96 Substance: Lime Juice (Strong Acid)

Analog: 143 | Voltage: 0.70 V | pH Value: 1.96 Substance: Lime Juice (Strong Acid)

Analog: 164 | Voltage: 0.80 V | pH Value: 2.24


Substance: Lime Juice (Strong Acid)

Analog: 164 | Voltage: 0.80 V | pH Value: 2.24 Substance: Lime Juice (Strong Acid)

Analog: 164 | Voltage: 0.80 V | pH Value: 2.24 Substance: Lime Juice (Strong Acid)

Analog: 164 | Voltage: 0.80 V | pH Value: 2.24 Substance: Lime Juice (Strong Acid)

Analog: 164 | Voltage: 0.80 V | pH Value: 2.24 Substance: Lime Juice (Strong Acid)

Analog: 164 | Voltage: 0.80 V | pH Value: 2.24 Substance: Lime Juice (Strong Acid)

Program 8:

Develop a program to detect the gas leakage in the surrounding environment.

AIM

To develop a program to detect gas leakage in the surrounding environment using a gas sensor and Arduino.


Component:




Circuit:

 

PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Log in Go to “Circuits” Click “Create New Circuit”

 

 

STEP 2: Add Components

From the components panel, add:

·        Arduino Uno R3

·        MQ-2 Gas Sensor

·        Red LED

·        Buzzer

·        Breadboard

·        Resistors (220Ω, 10kΩ)

·        Jumper wires

 

 

STEP 3: Wiring the Components

🔌 MQ-2 Gas Sensor Connections (Analog Output)

 

MQ-2 Pin

Connects To

VCC

Arduino 5V


MQ-2 Pin

Connects To

GND

Arduino GND

A0

Arduino A0

 

Some versions may also have a DO (digital out) use A0 for analog input.

 

 

LED Connection

 

LED Leg

Connects To

Anode (+)

Arduino Pin 8 (via 220Ω resistor)

Cathode (–)

GND

 

 

🔊 Buzzer Connection

 

Buzzer Pin

Connects To

+ (long pin)

Arduino Pin 9

(short pin)

GND

 

STEP 4: Add the Arduino Code

Click “Code” Select “Text” mode Paste this code: Program code:

int redLed=12; 

int buzzer=10; 

int smokeA0=A5; 

int sensorThree=100; 

void setup() 

pinMode(redLed,OUTPUT); 

pinMode(buzzer,OUTPUT); 

pinMode(smokeA0,INPUT); 

Serial.begin(9600); 

void  loop() 

int analogSensor=analogRead(smokeA0); 

Serial.print("Pin A0:"); 

Serial.println(analogSensor); 

if(analogSensor>sensorThree) 

digitalWrite(redLed,HIGH); 

tone(buzzer,1000,200); 

else 

digitalWrite(redLed,LOW); 

noTone(buzzer); 

delay(100); 


STEP 5: Start the Simulation

·        Click “Start Simulation”

·        Open the Serial Monitor

·        Increase the analog value of the MQ sensor in the simulation settings to simulate gas detection

o   Once it goes above 400, the LED and buzzer turn ON


Output:



Pin A0:122 Pin A0:122 Pin A0:122 Pin A0:130 Pin A0:146 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:90 Pin A0:121 Pin A0:154 Pin A0:150 Pin A0:149 Pin A0:149 Pin A0:181 Pin A0:251 Pin A0:243 Pin A0:277 Pin A0:224 Pin A0:136


Pin A0:124 Pin A0:119 Pin A0:114 Pin A0:123 Pin A0:142 Pin A0:130 Pin A0:100 Pin A0:90 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:85 Pin A0:87 Pin A0:133 Pin A0:142 Pin A0:142 Pin A0:147 Pin A0:149 Pin A0:150


 

Program 9:

Develop a program to demonstrate weather station readings using Arduino.

AIM

To develop a program to demonstrate a weather station using Arduino to measure temperature, humidity, and optionally atmospheric pressure.


Components:


Circuit:


 

PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Log in Go to “Circuits” Click “Create New Circuit”

 

 

STEP 2: Add Components

Search and drag the following into your workspace:

·        Arduino Uno R3

·        LM35 Temperature Sensor

·        16x2 LCD Display (standard)

·        10kΩ potentiometer

·        Breadboard

·        Jumper wires

 

 

STEP 3: Wire the Circuit

🔌 LM35 Temperature Sensor Wiring

 

LM35 Pin

Connects To

Left (VCC)

Arduino 5V

Middle (Vout)

Arduino A0

Right (GND)

Arduino GND

 

 

LCD to Arduino Wiring (in 4-bit mode)

 

LCD Pin

Connects To

VSS

GND

VDD

5V


LCD Pin

Connects To

VO

Middle pin of potentiometer (for contrast)

RS

Pin 12

RW

GND

E

Pin 11

D4

Pin 5

D5

Pin 4

D6

Pin 3

D7

Pin 2

A              (LED+)

5V (optional for backlight)

K                (LED-)

GND

🔁 Potentiometer Connections

·        One side GND

·        Other side 5V

·        Middle → LCD VO pin (for contrast)


STEP 4: Add the Arduino Code

Click “Code” Select “Text” mode Paste the following code:

 

Program code:

#include <LiquidCrystal.h>

// LCD pin setup: RS, E, D4, D5, D6, D7

LiquidCrystal lcd(7, 6, 5, 4, 3, 8);

// TMP36 on A1, LDR on A0

const int tempPin = A1;

const int ldrPin = A0;

void setup() {

Serial.begin(9600);

lcd.begin(16, 2);

lcd.print("Weather Station");

delay(2000);

lcd.clear();

}

void loop() {

// Read temperature from TMP36

int tempReading = analogRead(tempPin);

float voltage = tempReading * (5.0 / 1023.0);

float temperatureC = (voltage - 0.5) * 100;

// Read LDR and map to light percentage

int ldrValue = analogRead(ldrPin);

int lightPercent = map(ldrValue, 0, 1023, 100, 0); // 0 = bright, 100 = dark

// Print to Serial Monitor

Serial.print("Temp: ");

Serial.print(temperatureC);

Serial.print(" °C, Light: ");

Serial.print(lightPercent);

Serial.println("%");

// Display on LCD

lcd.setCursor(0, 0);

lcd.print("Temp:");

lcd.print(temperatureC, 1);

lcd.print((char)223); // Degree symbol

lcd.print("C ");

lcd.setCursor(0, 1);

lcd.print("Light:");

lcd.print(lightPercent);

lcd.print("% ");

delay(2000);

}

STEP 5: Start the Simulation

·        Click “Start Simulation”

·        You should see temperature values displayed on the LCD screen

·        You can simulate different temperatures by adjusting the LM35 in the Tinkercad panel

Output:


Temp: -33.87 °C, Light: 95%

Temp: 291.15 °C, Light: 95%

Temp: 262.81 °C, Light: 95%

Temp: 232.50 °C, Light: 95%

Temp: 310.70 °C, Light: 95%

Temp: 209.53 °C, Light: 95%


Program 10:

Develop a program to setup a UART protocol and pass a string through the protocol.

AIM

To develop a program that sets up UART communication and transmits a string using the UART protocol.


Components:


Circuit:


PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Log in Go to Circuits Click Create New Circuit

 

 

STEP 2: Add Components

·        Drag 2 Arduino Uno boards into the workspace.

 

 

STEP 3: Connect the Arduinos

 

Connection

Arduino 1 Pin

Arduino 2 Pin

Ground (GND)

GND

GND

TX RX

Pin 1 (TX)

Pin 0 (RX)

RX TX

Pin 0 (RX)

Pin 1 (TX)

 

In your image, only one data wire and GND wire are connected; typically, TX of Arduino1 goes to RX of Arduino2 and vice versa for full duplex.

 

 

STEP 4: Upload Arduino Sketches

Program code:

Arduino 1 (Sender):

 

void setup() { Serial.begin(9600);

}

 

void loop() {

Serial.println("Hello from Arduino 1"); delay(1000);

}

Arduino 2 (Receiver):

Code for Receiver (Arduino 2):


void setup() { Serial.begin(9600);

}

 

void loop() {

if (Serial.available()) {

String msg = Serial.readStringUntil('\n'); Serial.print("Received: "); Serial.println(msg);

}

}

STEP 5: Simulate

·        Upload sketches to respective Arduinos (one sender, one receiver).

·        Start simulation.

·        Open Serial Monitor for Arduino 2 to see incoming messages.

Output:

Sender (Arduino 1):

Hello from Arduino 1 Hello from Arduino 1 Receiver (Arduino 2):

Received: Hello from Arduino 1 Received: Hello from Arduino 1


 

 

Program 11:

Develop a water level depth detection system using Ultrasonic sensor.

AIM

To develop a system to detect water level depth using an ultrasonic sensor and Arduino.


Components:


Circuit:


PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Log in Go to Circuits Click Create New Circuit

 

 

STEP 2: Add Components

·        Drag Arduino Uno and HC-SR04 Ultrasonic Sensor into the workspace.

 

 

STEP 3: Wiring the HC-SR04

 

HC-SR04 Pin

Connects To Arduino Pin

VCC

5V

GND

GND

Trig

Digital Pin 7

Echo

Digital Pin 6

 

 

STEP 4: Add Arduino Code

Click “Code” Select “Text” mode Paste this code: Program Code:

const int sensorPin = 7; // SIG pin

 

long duration; float distanceCM;

 

void setup() { Serial.begin(9600); pinMode(sensorPin, OUTPUT);

}

 

void loop() {


// Send trigger pulse pinMode(sensorPin, OUTPUT); digitalWrite(sensorPin, LOW); delayMicroseconds(2); digitalWrite(sensorPin, HIGH); delayMicroseconds(10); digitalWrite(sensorPin, LOW);

 

// Change pin to input to read echo pinMode(sensorPin, INPUT);

 

// Read the echo pulse duration duration = pulseIn(sensorPin, HIGH);

 

// Calculate distance in cm distanceCM = duration * 0.034 / 2;

 

Serial.print("Distance: "); Serial.print(distanceCM); Serial.println(" cm");

 

delay(1000);

}

STEP 5: Start Simulation

·        Click “Start Simulation”

·        Open the Serial Monitor to see distance readings update continuously

·        You can manually move the sensor or objects in Tinkercad to see changes in distance values.

 

 

Output:


Distance: 332.03 cm

Distance: 332.04 cm

Distance: 332.04 cm

Distance: 332.06 cm

Distance: 332.04 cm

Distance: 332.04 cm

Distance: 332.04 cm

Distance: 161.04 cmDistance: 161.02 cm

Distance: 332.08 cm

Distance: 332.08 cm


Program12:

Develop a program to simulate interfacing with the keypad module to record the keystrokes.

AIM

To develop a program to simulate interfacing with a keypad module and record the keystrokes using an Arduino.

Components:




Circuit:



PROCEDURE:

STEP 1: Open Tinkercad

1.       Go to https://www.tinkercad.com

2.       Log in Go to Circuits Click Create New Circuit

 

 

STEP 2: Add Components

·        Drag Arduino Uno

·        Drag 4x4 Matrix Keypad

 

 

STEP 3: Wiring the Keypad

 

Keypad Pin

Arduino Pin

1 (Row 1)

9

2 (Row 2)

8

3 (Row 3)

7

4 (Row 4)

6

5 (Col 1)

5

6 (Col 2)

4

7 (Col 3)

3

8 (Col 4)

2

 

 

STEP 4: Add the Arduino Code

Click “Code” Select “Text” mode Paste the following code: Program Code:

#include <Keypad.h>

 

const byte ROWS = 4; // Four rows const byte COLS = 4; // Four columns


char keys[ROWS][COLS] = {

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

};

 

byte rowPins[ROWS] = {9, 8, 7, 6}; // Connect to the row pinouts of the keypad byte colPins[COLS] = {5, 4, 3, 2}; // Connect to the column pinouts

 

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

 

String inputBuffer = "";

 

void setup(){ Serial.begin(9600);

Serial.println("Keypad Ready. Press any key...");

}

 

void loop(){

char key = keypad.getKey(); if (key){

inputBuffer += key; Serial.print("Key Pressed: "); Serial.println(key); Serial.print("Current Input: "); Serial.println(inputBuffer);

}

}

STEP 5: Start Simulation

·        Click “Start Simulation”

·        Open the Serial Monitor

·        Press buttons on the virtual keypad and watch the pressed keys appear on the Serial Monitor.


Output:

Keypad Ready. Press any key... Key Pressed: 1

Current Input: 1 

Key Pressed: A 

Current Input: 1A 

Key Pressed: 5 

Current Input: 1A5 

Key Pressed: # 

Current Input: 1A5# 

Key Pressed: D

Current Input: 1A5#D 

Key Pressed: *

Current Input: 1A5#D*


Comments

Popular posts from this blog