Arduino Tinkercad Experiments
Arduino Tinkercad Experiments
Arduino Tinkercad Experiments
1 a)Write the code to blink an LED on Arduino Uno. Compile and verify the result on the serial
monitor of Arduino IDE.
Additional Programs:
i) To blink two LED’s alternatively
ii) To blink odd and even leds
iii) To scroll an LED’s
2 Interfacing of Arduino Uno with LED and switch. Write a program to
control LED using Switch.
Additional Programs:
i)Single switch to control multiple LED’s
ii)Multi switches to control multiple LED’s
3 Interfacing of Arduino Uno with potentiometer and LED. Write a program to vary the intensity of
LED using a potentiometer.
Additional Programs:
i)Adjust the brightness of LED without potentiometer.
4 (a)Interfacing of Ultrasonic sensor with Arduino Uno. Write a program to measure the distance
from obstacle and display on the serial monitor.
(b)Interface an IR sensor with Arduino Uno. Write a program to detect obstacle and display on the
serial monitor.
5
(a) Interfacing of Temperature sensor with Arduino Uno. Write a program to read the specific
temperature of a room and display on the serial monitor.
(b) Interfacing of LDR with Arduino Uno. Write a program to control the intensity of LED using LDR.
6 (a) Interfacing of DC motor with Arduino Uno. Write a program to rotate the motor in clockwise
and anticlockwise direction with using a delay of 2 sec.
(b) Familiarize the concept of pulse width modulation. Write a program to control the speed of DC
motor using PWM.
7 (a) Interfacing of a display device, i.e., LCD x2 with Arduino Uno. Write a
program to display “HELLO IOT” on LCD.
(b) Write a program to scroll the message “Welcome to IoT Lab.”
(c) Write a program to blink the message “Hello IoT.”
EXPERIMENT 1
Aim of the Experiment: To Blink LED
Circuit Diagram:
Software program:
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(13, HIGH);
Serial.println("LED : ON");
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, LOW);
Serial.println("LED : OFF");
delay(1000); // Wait for 1000 millisecond(s)
}
Screenshot of Serial monitor:
EXPERIMENT 2
Aim of the Experiment: Controlling LED with Switch.
Circuit Diagram:
Circuit Diagram:
Software program:
int value=0;
void setup()
{
pinMode(A0, INPUT);
pinMode(11, OUTPUT);
}
void loop()
{
value = analogRead(A0);
digitalWrite(11,HIGH);
delay(value);
digitalWrite(11, LOW);
delay(value);
}
EXPERIMENT 4(a)
Aim of the Experiment: Measure the distance from obstacle and display on the serial
monitor using ultrasonic sensor
Circuit Diagram:
Software program:
const int trigpin =6;
const int echopin =7;
int distance;
int duration;
void setup()
{
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(trigpin, LOW);
delayMicroseconds(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
duration = pulseIn(echopin, HIGH);
distance = (0.034*duration)/2;
Serial.print("Distance is =");
Serial.println(distance);
}
Circuit Diagram :
Software program:
int ir;
void setup()
{
pinMode(11,INPUT);
Serial.begin(9600);
}
void loop()
{
ir=digitalRead(11);
Serial.println(ir);
}
Screenshot of Serial monitor:
EXPERIMENT 5(a)
Circuit Diagram:
Software program:
#include <LiquidCrystal.h>
Serial.begin(9600);
lcd.begin(16,2);
}
void loop()
{
sensorInput = analogRead(A0);
temp = (double)sensorInput / 1024;
temp = temp * 5;
temp = temp - 0.5;
temp = temp * 100;
lcd.setCursor(0,0);
lcd.print("Temp:");
lcd.setCursor(6,0);
lcd.print(temp);
Serial.print("Current Temperature: ");
Serial.println(temp);
}
Circuit Diagram:
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
void loop()
{
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 200)
{
digitalWrite(ledPin, HIGH);
Serial.print("Its DARK, Turn on the LED : ");
Serial.println(ldrStatus);
}
else
{
digitalWrite(ledPin, LOW);
Serial.print("Its BRIGHT, Turn off the LED : ");
Serial.println(ldrStatus);
}
}
Aim of the Experiment: Rotating a DC Motor in clockwise & anticlockwise direction using delay.
Components Used: Arduino UNO, DC Motor, H- Bridge Motor Driver, Tinkercad Stimulation.
Circuit Diagram:
pinMode(In1,OUTPUT);
pinMode(In2,OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(In1,HIGH);
digitalWrite(In2,LOW);
Serial.println(“Clockwise”);
delay(2000);
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);
Serial.println(“Anti Clockwise”);
delay(2000);
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);
Serial.println(“Stop”);
delay(2000);
}
Circuit Diagram:
Software program:
int en=5;
int In1=12;
int In2=9;
void setup()
{
pinMode(en,OUTPUT);
pinMode(In1,OUTPUT);
pinMode(In2,OUTPUT);
Serial.begin(9600);
}
void loop()
{
analogWrite(en,255);
digitalWrite(In1,HIGH);
digitalWrite(In2,LOW);
Serial.println("Clockwise");
delay(2000);
analogWrite(en,255);
digitalWrite(In1,LOW);
digitalWrite(In2,HIGH);
Serial.println("Anti Clockwise");
delay(2000);
analogWrite(en,255);
digitalWrite(In1,LOW);
digitalWrite(In2,LOW);
Serial.println("Stop");
delay(2000);
}
Circuit Diagram:
Software program:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
lcd.setCursor(4,0);
lcd.print("Hello IoT");
delay(1000);
}
201
EXPERIMENT 7(b)
Circuit Diagram:
3
EXPERIMENT 7(c)
Circuit Diagram: