KESHAV
MAHAVIDYALAYA
UNIVERSITY OF DELHI
B.SC (HONS.) ELECTRONICS ,4TH SEMESTER
**********************************************************************
*********************************************************************
SEC- “ROBOTICS”
PRACTICAL FILE
***********************************************************************
**************************************************************
NAME OF STUDENT: JAY PRAKASH
COLLEGE ROLL NO. 1073
EXAM ROLL NO. 19035558024
..
INDEX
SNO. NAME OF EXPERIMENT DATE OF EXP. DATE OF SUB. SIGNATURE
Interfacing experiments using available
1
hardwre like LCD,LED,BUZZER,MOTORS.
1. To blink a LED using digitalWrite command 06/01/2021 07/02/2021
2 . To control the brightness of a LED using
07/01/2021
analogWrite command 07/01/2021
3. To demonstrate basic BUZZER. 20/01/2021 07/02/2021
4. To print data using 16*2 LCD display(8-pins
20/01/2021
configuration) 07/02/2021
5. To demonstrate the SERVO MOTOR 21/01/2021 07/02/2021
6. To control the speed of a DC MOTOR using
21/01/2021
potentiometer and transistor. 07/02/2021
7. To control a LED using PUSH BUTTON 21/01/2021 07/02/2021
8.To control two motors using L293D MOTOR
28/01/2021
DRIVER CODE. 07/02/2021
9. To control the colour of RGB light. 13/01/2021 07/02/2021
10. To control a LED and BUZZER using PUSH
28/01/2021
BUTTON 07/02/2021
To display the buttons on the IR remote to the
2 04/02/2021
liquid crystal display(LCD) using aurdino uno. 07/02/2021
EXPERIMENT 1
• AIM: Interfacing experiments using available hardware like LCD,LED,BUZZER,MOTORS.
void setup()
{
pinMode(5, OUTPUT);
CODE: 1.AIM: To blink a LED using digitalWrite command.
pinMode(10, OUTPUT); (LED)
pinMode(12, OUTPUT);
}
void loop()
{
digitalWrite(5, HIGH);
delay(400);
digitalWrite(5, LOW);
delay(400);
digitalWrite(10, HIGH);
delay(400);
digitalWrite(10, LOW);
delay(400);
digitalWrite(12, HIGH);
delay(400);
digitalWrite(12, LOW);
delay(400);
}
2.
CODE:
int brightness = 0; AIM: To control the brightness of a LED using
void setup() analogWrite command
{
pinMode(13, OUTPUT);
}
void loop()
{
for (brightness = 0; brightness <=255;
brightness += 5)
{
analogWrite(9, brightness);
delay(1000);
}
for (brightness = 255; brightness >= 0;
brightness -= 5)
{
analogWrite(13, brightness);
delay(1000);
}
}
const int buzzer = 12;
const int buz = 13;
void setup(){
CODE: 3. AIM: To demonstrate basic BUZZER.
pinMode(buzzer, OUTPUT); (BUZZER)
pinMode(buz,OUTPUT);
}
void loop(){
tone(buzzer, 1000); // Send 1KHz sound
signal...
delay(500); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(1000); // ...for 1sec
tone(buz, 1000); // Send 1KHz sound signal...
delay(1000); // ...for 1 sec
noTone(buz); // Stop sound...
delay(500); // ...for 1sec
tone(buz, 1000); // Send 1KHz sound signal...
delay(500); // ...for 1 sec
noTone(buz); // Stop sound...
delay(200); // ...for 1sec
tone(buzzer, 1000); // Send 1KHz sound
signal...
delay(500); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(1000); // ...for 1sec
}
CODE: (LCD 8 BIT MODE) 4.
#include <LiquidCrystal.h> AIM: To print data using 16*2 LCD display(8-pins
configuration)
LiquidCrystal lcd(2,3,4,5,6,7,8,9,10,11);
void setup()
{
lcd.begin(16,2);
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("I AM JAY PRAKASH
FROM KESHAV MAHAVIDYALAYA ");
lcd.scrollDisplayLeft();
}
#include <Servo.h>
CODE:
5. AIM: To demonstrate the SERVO MOTOR
Servo servo1;
Servo servo2; (SERVO
Servo servo3;
Servo servo4; MOTORS)
void setup()
{
servo1.attach(8);
servo2.attach(9);
servo3.attach(7);
servo4.attach(6);
}
void loop()
{
servo1.write(0);
delay(1000);
servo1.write(360);
delay(1000);
servo2.write(0);
delay(1000);
servo2.write(360);
delay(1000);
servo3.write(360);
delay(1000);
servo3.write(0);
delay(1000);
servo4.write(360);
delay(1000);
servo4.write(0);
delay(1000);
}
CODE: (DC 6.
MOTORS)
void setup() AIM: To control the speed of a DC MOTOR using
{ potentiometer and transistor.
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(11, HIGH);
delay(10);
}
const int LED = 8; // the pin for the LED
const int BUTTON = 13; // input pin of the
7.
pushbutton AIM: To control a LED using PUSH BUTTON
int val = 0; // stores the state of the input pin
int old_val = 0; // stores the previous value
of "val"
int state = 0; // 0 = LED off while 1 = LED on
int brightness = 128; // Stores the brightness
value
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED
is an output
pinMode(BUTTON, INPUT); // and BUTTON
is an input
}
void loop() {
val = digitalRead(BUTTON); // read input
value and store it
// check if there was a transition
if ((val == HIGH) && (old_val == LOW))
{
state = 1 - state; // change the state from off
to on
delay(10);
}
old_val = val; // val is now old, let’s store it
if (state == 1) {
analogWrite(LED, brightness); // turn LED
ON at the
// current brightness level
} else {
analogWrite(LED, 0); // turn LED OFF
}
}
(LED PUSH BUTTON)
int motor1APin = 7; // H-bridge leg 1
int motor2APin = 5; // H-bridge leg 2 8. AIM: To control two motors using L293D MOTOR
void setup()
{ DRIVER CODE.
pinMode(motor1APin, OUTPUT);
pinMode(motor2APin, OUTPUT);
}
void loop()
{
digitalWrite(motor1APin, LOW); //
set leg 1 of the H-bridge low
digitalWrite(motor2APin, HIGH); //
set leg 2 of the H-bridge high
delay (6000);
digitalWrite(motor1APin, LOW); //
set leg 1 of the H-bridge low
digitalWrite(motor2APin, LOW); //
set leg 2 of the H-bridge low
delay (1000);
digitalWrite(motor1APin, HIGH); //
set leg 1 of the H-bridge low
digitalWrite(motor2APin, LOW); //
set leg 2 of the H-bridge high
delay (5000);
digitalWrite(motor1APin, LOW); //
set leg 1 of the H-bridge low
digitalWrite(motor2APin, LOW); //
set leg 2 of the H-bridge low
delay (3000);
} (DC MOTORS WITH LM239D)
CODE: (LED 9. AIM:To control the colour of RGB light.
RBG)
void setup()
{ pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{ analogWrite(9, 51);
analogWrite(10, 204);
analogWrite(11, 255);
delay(1000);
analogWrite(9, 153);
analogWrite(10, 51);
analogWrite(11, 153);
delay(1000);
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(11, 153);
delay(1000);
}
CODE: 10.
int buttonState = 0; AIM: To control a LED and BUZZER using PUSH
int buttonState1 = 0; BUTTONS.
void setup()
{ pinMode(2, INPUT);
pinMode(13, OUTPUT);
pinMode(4, INPUT);
pinMode(12, OUTPUT);
}
void loop()
{ buttonState = digitalRead(2);
if (buttonState == HIGH)
{ digitalWrite(13, HIGH);
}
else { digitalWrite(13, LOW);
} delay(10) ;
buttonState1 = digitalRead(4);
if (buttonState1 == HIGH)
digitalWrite(12, HIGH); } else
{ digitalWrite(12, LOW);
} delay(10); }
EXPERIMENT 2
AIM: To display the buttons on the IR remote to the liquid crystal display(LCD) using aurdino uno.
CODE:
#include <LiquidCrystal.h>
#include <IRremote.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
// set up the LCD's number of columns and rows:
Serial.begin(9600);
lcd.begin(16, 2);
irrecv.enableIRIn();
// Print a message to the LCD.
}
.
void loop() {
// set the cursor to column 0, lllllline 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0);
if (irrecv.decode(&results))// Returns 0 if no data ready, 1 if
data ready.
{
int x = results.value;// Results of decoding are stored in
result.value
Serial.println(" ");
Serial.print("Code: ");
Serial.println(results.value); //prints the value a a button press
Serial.println(" ");
irrecv.resume(); // Restart the ISR state machine and Receive
the next value
}
.
switch(results.value) case 16589023 :
{ {
case 16580863 : lcd.print("BACKWARD");
{ delay(1000);
lcd.print(" ON/OFF"); lcd.clear();
delay(1000); break;
lcd.clear(); }
break; case 16621663 :
} {
case 16613503 : lcd.print("PAUSE/PLAY");
{ delay(1000);
lcd.print("VOL+"); lcd.clear();
delay(1000); break;
lcd.clear(); } case 16605343 :
break; {
} lcd.print("FAST FORWARD");
case 16597183 : delay(1000);
{ lcd.clear();
lcd.print("FUNC/STOP"); break;
delay(1000); }
lcd.clear();
break;
}
.
case 16584943 : case 16609423 :
{ case 16623703 :
{ {
lcd.print("DOWN");
delay(1000); lcd.print("ST/REPT"); lcd.print(" FIVE");
lcd.clear(); delay(1000); break;
break; lcd.clear(); } case 16607383 :
} break; {
case 16617583 : } lcd.print(" SIX");
{ case 16582903 :
lcd.print("VOL-"); break;
{ }
delay(1000);
lcd.clear(); lcd.print(" ONE"); case 16586983 :
break; break; {
} } lcd.print(" SEVEN");
case 16601263 : case 16615543 : break;
{ { }
lcd.print("UP"); lcd.print(" TWO");
delay(1000); case 16619623 :
break; {
lcd.clear();
break; } lcd.print(" EIGHT");
} case 16599223 : break;
case 16593103 : { }
{ lcd.print(" THREE"); case 16603303 :
lcd.print("O"); break; {
break; }
} case 16625743 :
lcd.print(" NINE");
{
case 16591063 : break;
lcd.print("EQ"); { }
delay(1000); lcd.print("FOUR"); }
lcd.clear();
break;
break; }
.} }
}
.