SlideShare a Scribd company logo
1 of 11
Bluetooth Controlled ROBOT
Aim of the project is to design a robot which can be controlled by
Bluetooth of your mobile phone or PC.
An application program running in PC or android phone is used to send
commands that are received by Bluetooth module attached with the
robot.
Overview
Bluetooth Controlled Robot
Hardware components required and their purpose:
1. Arduino UNO board
2. PC or Mobile phone with customizable Bluetooth module
3. HC-05 Bluetooth module
4. DC motor
5. Motor driver IC (L293D)
6. Wheels
7. Power adopter
 Arduino UNO board: This is the brain of this robot in which the
program is loaded to do the required functioning and is interfaced
with Bluetooth module and the motor driver to make the system work
as required.
 HC-05 Bluetooth Module: This module is capable of communicating
with PC, mobile phone or any other Bluetooth enabled device. It is
interfaced with the microcontroller over the
serial UART port of micro-controller.
 PC or Mobile phone with customizable Bluetooth module: this works
as the remote control for the robot. It has an application program
running on it which enables us to send appropriate command over its
Bluetooth module to control the robot.
Bluetooth Module
 DC Motor: This motor is controlled with DC voltages and can move
in forward and backward direction according to the polarity of the
voltage applied.
 Motor driver IC (L293D): Microcontrollers can’t supply the
current required by DC motor to run. So, to fulfill this requirement
these motor driver ICs are used.
DC motors with Driver IC
 Power adopter: This is used to give appropriate dc power supply to
microcontroller, driver IC sensors and the other passive components
of the robot.
 Wheels: In it three wheels are employed, two at rear end and one at
front end. Rear wheels are attached with the motors and also control
the steering of robot. Front wheel is the loose steered wheel which
moves in the direction of the pressure applied to it.
Block Diagram:
Bluetooth Controlled Robot
Description
For this firstly the application program is developed or a readymade
program is made available to run on the PC or the mobile phone. This
application program send the commands in form of ASCII characters
which are received by HC-05 Bluetooth module and passed to
microcontroller through UART port of microcontroller.
The microcontroller is programmed to take desired actions according to
the command (ASCII character) received to move forward, reverse or to
take a turn.
The microcontroller sends logic 1 or 0 at the specified pin to control
motors of robot which are attached using motor driver IC (L293D).
Program:
/*
left motor attached to pin 5(+ve),6 and
right motor attached to pin 7(+ve),8 and
*/
void setup() {
//Initialize serial
Serial.begin(9600);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{
char value;
value=Serial.read();
switch(value)
{
case 'w':
{
digitalWrite(6, LOW);
digitalWrite(8, LOW);
digitalWrite(5, HIGH);
digitalWrite(7, HIGH);
break;
}
case 'd':
{
digitalWrite(5, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
break;
}
case 'a':
{
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
break;
}
case 'x':
{
digitalWrite(5, LOW);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
break;
}
case ' ':
{
digitalWrite(5, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
break;
}
}
}
Programming Digital I/O pins of Arduino UNO board:
 Each pin is controlled by three commands associated with it which are
designated as:
pinMode()
digitalWrite()
digitalRead()
 pinMode()
This configures the specified pin to behave either as an input or an output.
Syntax
pinMode(pin, mode)
Parameters
pin: the number of the pin whose mode you wish to set
mode: INPUT, OUTPUT.
Returns
None
Example
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
 digitalWrite()
Write a HIGH or a LOW value to a digital pin.
If the pin has been configured as an OUTPUT with pinMode(), its voltage will
be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V
(ground) for LOW.
Syntax
digitalWrite(pin, value)
Parameters
pin: the pin number
value: HIGH or LOW
Returns
None
Example
Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
 digitalRead()
Reads the value from a specified digital pin, either HIGH or LOW.
Syntax
digitalRead(pin)
Parameters
pin: the number of the digital pin you want to read (int)
Returns
HIGH or LOW
Example
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7; // pushbutton connected to digital pin 7
int val = 0; // variable to store the read value
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(inPin, INPUT); // sets the digital pin 7 as input
}
void loop()
{
val = digitalRead(inPin); // read the input pin
digitalWrite(ledPin, val); // sets the LED to the button's value
}

More Related Content

What's hot

WIRELESS ROBOT PPT
WIRELESS ROBOT PPTWIRELESS ROBOT PPT
WIRELESS ROBOT PPT
AIRTEL
 

What's hot (20)

PPT ON Arduino
PPT ON Arduino PPT ON Arduino
PPT ON Arduino
 
Obstacle avoidance robot
Obstacle avoidance robotObstacle avoidance robot
Obstacle avoidance robot
 
Bluetooth controled robot
Bluetooth controled robotBluetooth controled robot
Bluetooth controled robot
 
Obstacle Avoidance Robotic Vehicle
Obstacle Avoidance Robotic VehicleObstacle Avoidance Robotic Vehicle
Obstacle Avoidance Robotic Vehicle
 
Obstacle avoiding Robot
Obstacle avoiding RobotObstacle avoiding Robot
Obstacle avoiding Robot
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino
 
Voice control Wheelchair
Voice control WheelchairVoice control Wheelchair
Voice control Wheelchair
 
Obstacle Avoidance Robot
Obstacle Avoidance RobotObstacle Avoidance Robot
Obstacle Avoidance Robot
 
E- Notice Board Presentation
E- Notice Board PresentationE- Notice Board Presentation
E- Notice Board Presentation
 
Introduction to Node MCU
Introduction to Node MCUIntroduction to Node MCU
Introduction to Node MCU
 
BLUETOOTH CONTROLLED ROBOCAR
BLUETOOTH CONTROLLED ROBOCARBLUETOOTH CONTROLLED ROBOCAR
BLUETOOTH CONTROLLED ROBOCAR
 
Gesture control car
Gesture control carGesture control car
Gesture control car
 
Home automation ppt
Home automation pptHome automation ppt
Home automation ppt
 
OBSTACLE AVOIDING CAR
OBSTACLE AVOIDING CAROBSTACLE AVOIDING CAR
OBSTACLE AVOIDING CAR
 
WIRELESS ROBOT PPT
WIRELESS ROBOT PPTWIRELESS ROBOT PPT
WIRELESS ROBOT PPT
 
Android mobile phone controlled bluetooth robot
Android mobile phone controlled bluetooth robotAndroid mobile phone controlled bluetooth robot
Android mobile phone controlled bluetooth robot
 
Android controlled robot
Android controlled robotAndroid controlled robot
Android controlled robot
 
Wireless E-Notice Board Using Bluetooth Report.docx
Wireless E-Notice Board Using Bluetooth Report.docxWireless E-Notice Board Using Bluetooth Report.docx
Wireless E-Notice Board Using Bluetooth Report.docx
 
Latest ECE Projects Ideas In Various Electronics Technologies
Latest ECE Projects Ideas In Various Electronics TechnologiesLatest ECE Projects Ideas In Various Electronics Technologies
Latest ECE Projects Ideas In Various Electronics Technologies
 
Android Controlled Arduino Spy Robot
Android Controlled Arduino Spy RobotAndroid Controlled Arduino Spy Robot
Android Controlled Arduino Spy Robot
 

Similar to Arduino bluetooth controlled robot

Android Operated Wireless Robot Using 8051 MCU
Android Operated Wireless Robot Using 8051 MCUAndroid Operated Wireless Robot Using 8051 MCU
Android Operated Wireless Robot Using 8051 MCU
Kamal Pradhan
 

Similar to Arduino bluetooth controlled robot (20)

Bluetooth controlled robot
Bluetooth controlled robotBluetooth controlled robot
Bluetooth controlled robot
 
Pc controlled robot
Pc controlled robotPc controlled robot
Pc controlled robot
 
438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx
438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx
438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx
 
Android Operated Wireless Robot Using 8051 MCU
Android Operated Wireless Robot Using 8051 MCUAndroid Operated Wireless Robot Using 8051 MCU
Android Operated Wireless Robot Using 8051 MCU
 
ROBOTIC CAR PPT (2).pptx
ROBOTIC CAR PPT (2).pptxROBOTIC CAR PPT (2).pptx
ROBOTIC CAR PPT (2).pptx
 
Part 2 master
Part 2 masterPart 2 master
Part 2 master
 
Part 2 master
Part 2 masterPart 2 master
Part 2 master
 
Android Control robot using 8051 microcontroler
Android Control robot using 8051 microcontrolerAndroid Control robot using 8051 microcontroler
Android Control robot using 8051 microcontroler
 
SURVEILLANCE ROBOT
SURVEILLANCE ROBOTSURVEILLANCE ROBOT
SURVEILLANCE ROBOT
 
Automatic voice control wheelchair
Automatic voice control wheelchairAutomatic voice control wheelchair
Automatic voice control wheelchair
 
Project_report_voice_controlling_robot
Project_report_voice_controlling_robotProject_report_voice_controlling_robot
Project_report_voice_controlling_robot
 
Touchpad Monitored Car
Touchpad Monitored CarTouchpad Monitored Car
Touchpad Monitored Car
 
Touchpad Monitored Car
Touchpad Monitored Car Touchpad Monitored Car
Touchpad Monitored Car
 
Arduino Based Bluetooth Operated Car Wiping Technique using Android Mobile Phone
Arduino Based Bluetooth Operated Car Wiping Technique using Android Mobile PhoneArduino Based Bluetooth Operated Car Wiping Technique using Android Mobile Phone
Arduino Based Bluetooth Operated Car Wiping Technique using Android Mobile Phone
 
home automation digital
home automation digitalhome automation digital
home automation digital
 
Design and Development of a prototype of AGV
Design and Development of a prototype of AGVDesign and Development of a prototype of AGV
Design and Development of a prototype of AGV
 
Arduino bt mobile robot r2.0
Arduino bt mobile robot r2.0Arduino bt mobile robot r2.0
Arduino bt mobile robot r2.0
 
Intel galileo gen 2
Intel galileo gen 2Intel galileo gen 2
Intel galileo gen 2
 
ROBOT MOTION
ROBOT    MOTIONROBOT    MOTION
ROBOT MOTION
 
Thesis power theft detection ch 3
Thesis power theft detection ch 3Thesis power theft detection ch 3
Thesis power theft detection ch 3
 

More from UVSofts Technologies

More from UVSofts Technologies (14)

Arduino dtmf controlled robot
Arduino dtmf controlled robotArduino dtmf controlled robot
Arduino dtmf controlled robot
 
Vehicle tracting system
Vehicle tracting systemVehicle tracting system
Vehicle tracting system
 
GPS based tracking system
GPS based tracking systemGPS based tracking system
GPS based tracking system
 
Password based door locksystem
Password  based door locksystemPassword  based door locksystem
Password based door locksystem
 
Calculator
CalculatorCalculator
Calculator
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Password based door locksystem
Password  based door locksystemPassword  based door locksystem
Password based door locksystem
 
Pc controlled robot
Pc controlled robotPc controlled robot
Pc controlled robot
 
Mobile controll robot
Mobile controll robotMobile controll robot
Mobile controll robot
 
Mobile controlled robot
Mobile controlled robotMobile controlled robot
Mobile controlled robot
 
Edge detector robot
Edge detector robotEdge detector robot
Edge detector robot
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
Line follower robot
Line follower robotLine follower robot
Line follower robot
 
Edge detector & avoider robot
Edge detector & avoider robotEdge detector & avoider robot
Edge detector & avoider robot
 

Recently uploaded

Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (20)

HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 

Arduino bluetooth controlled robot

  • 1. Bluetooth Controlled ROBOT Aim of the project is to design a robot which can be controlled by Bluetooth of your mobile phone or PC. An application program running in PC or android phone is used to send commands that are received by Bluetooth module attached with the robot. Overview Bluetooth Controlled Robot
  • 2. Hardware components required and their purpose: 1. Arduino UNO board 2. PC or Mobile phone with customizable Bluetooth module 3. HC-05 Bluetooth module 4. DC motor 5. Motor driver IC (L293D) 6. Wheels 7. Power adopter  Arduino UNO board: This is the brain of this robot in which the program is loaded to do the required functioning and is interfaced with Bluetooth module and the motor driver to make the system work as required.  HC-05 Bluetooth Module: This module is capable of communicating with PC, mobile phone or any other Bluetooth enabled device. It is interfaced with the microcontroller over the serial UART port of micro-controller.  PC or Mobile phone with customizable Bluetooth module: this works as the remote control for the robot. It has an application program running on it which enables us to send appropriate command over its Bluetooth module to control the robot.
  • 3. Bluetooth Module  DC Motor: This motor is controlled with DC voltages and can move in forward and backward direction according to the polarity of the voltage applied.  Motor driver IC (L293D): Microcontrollers can’t supply the current required by DC motor to run. So, to fulfill this requirement these motor driver ICs are used.
  • 4. DC motors with Driver IC  Power adopter: This is used to give appropriate dc power supply to microcontroller, driver IC sensors and the other passive components of the robot.  Wheels: In it three wheels are employed, two at rear end and one at front end. Rear wheels are attached with the motors and also control the steering of robot. Front wheel is the loose steered wheel which moves in the direction of the pressure applied to it.
  • 5. Block Diagram: Bluetooth Controlled Robot Description For this firstly the application program is developed or a readymade program is made available to run on the PC or the mobile phone. This application program send the commands in form of ASCII characters which are received by HC-05 Bluetooth module and passed to microcontroller through UART port of microcontroller. The microcontroller is programmed to take desired actions according to the command (ASCII character) received to move forward, reverse or to take a turn.
  • 6. The microcontroller sends logic 1 or 0 at the specified pin to control motors of robot which are attached using motor driver IC (L293D). Program: /* left motor attached to pin 5(+ve),6 and right motor attached to pin 7(+ve),8 and */ void setup() { //Initialize serial Serial.begin(9600); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); } void loop() { char value; value=Serial.read(); switch(value) { case 'w': { digitalWrite(6, LOW);
  • 7. digitalWrite(8, LOW); digitalWrite(5, HIGH); digitalWrite(7, HIGH); break; } case 'd': { digitalWrite(5, HIGH); digitalWrite(7, LOW); digitalWrite(6, LOW); digitalWrite(8, LOW); break; } case 'a': { digitalWrite(5, LOW); digitalWrite(7, HIGH); digitalWrite(6, LOW); digitalWrite(8, LOW); break; } case 'x': { digitalWrite(5, LOW); digitalWrite(7, LOW); digitalWrite(6, HIGH); digitalWrite(8, HIGH);
  • 8. break; } case ' ': { digitalWrite(5, LOW); digitalWrite(7, LOW); digitalWrite(6, LOW); digitalWrite(8, LOW); break; } } }
  • 9. Programming Digital I/O pins of Arduino UNO board:  Each pin is controlled by three commands associated with it which are designated as: pinMode() digitalWrite() digitalRead()  pinMode() This configures the specified pin to behave either as an input or an output. Syntax pinMode(pin, mode) Parameters pin: the number of the pin whose mode you wish to set mode: INPUT, OUTPUT. Returns None Example int ledPin = 13; // LED connected to digital pin 13 void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPin, LOW); // sets the LED off
  • 10. delay(1000); // waits for a second }  digitalWrite() Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. Syntax digitalWrite(pin, value) Parameters pin: the pin number value: HIGH or LOW Returns None Example Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW. int ledPin = 13; // LED connected to digital pin 13 void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second
  • 11. digitalWrite(ledPin, LOW); // sets the LED off delay(1000); // waits for a second }  digitalRead() Reads the value from a specified digital pin, either HIGH or LOW. Syntax digitalRead(pin) Parameters pin: the number of the digital pin you want to read (int) Returns HIGH or LOW Example int ledPin = 13; // LED connected to digital pin 13 int inPin = 7; // pushbutton connected to digital pin 7 int val = 0; // variable to store the read value void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output pinMode(inPin, INPUT); // sets the digital pin 7 as input } void loop() { val = digitalRead(inPin); // read the input pin digitalWrite(ledPin, val); // sets the LED to the button's value }