SlideShare a Scribd company logo
1 of 37
Basic Mechatronics
Basic Tutorial for Arduino
By,
Manas Shrivastava
MNNIT, Allahabad
Contents
● Control systems - open loop and closed loop
● Structure of Arduino
● What can I do with Arduino?
● Open loop control system with Arduino
● Closed loop control system with Arduino
● Sensors
● Devices
● Coding
● Examples
● Troubleshooting
Control Systems
● Any system that controls a process based on inputs given to it is a control
system.
● In our everyday life, we are surrounded by various control systems.
● For example, the maintenance of a definite temperature inside a refrigerator
is achieved through a control system.
● A simple cam-follower mechanism is an example of a control system.
● Touch screen of phone functions through a control system.
● As we can see, there are infinite control systems all around us.
● Control systems are not just mechanical or electrical, even the facing of a
sunflower towards the sun and the entire operation of the human body are
also a few examples of controls systems.
A broad classification of control systems
There are broadly two kinds of control systems - Open loop control and Closed
loop control systems.
Open loop control systems - These systems do not take any feedback from the
output conditions. We just give an input and get an output. Easy and cheap :)
Closed loop control systems - These systems take their job seriously and check
whether the system is producing the desired output or not? This requires feedback
from the output conditions and thus, increases the complications and cost of the
system.
Depending upon our application, we choose open or closed control system.
Examples of open loop control systems
● Cam-follower pair
● Induction Cooker
● Air conditioner in a car
● Remote of TV
● Manual Washing machine
● Regulator of fans
● Spring damper system
● Water taps
● Shells from cannons
Examples of closed loop control systems
● Valve opening in IC Engines by camshaft.
● Air conditioners/ Refrigerators
● Guided bombs and missiles
● Autopilot in aircrafts
● Adaptive brightness in smartphones
● Automatic doors in buildings
● Automatic electric iron
● Water level control through balloon in tanks
Structure of Arduino
What can we do with an Arduino?
● A wide range of operations is possible by making use of the Arduino IDE.
● Project examples-
1. Remote controlled Quadcopter drone
2. Theft detector
3. Home automation circuit
4. Automatic sweet dispenser
5. Sorting machines
6. Bomb defuser (and the bomb as well)
7. Spyware
8. Robots carrying out various functions
9. Robotic Arm
10.Health tracker
Open loop and closed loop control system with
Arduino
Open loop - Arduino is the microcontroller, we give input through the code, and
anything like a motor, LED, buzzer, can be used as an actuator to give motion,
rotation, sound, light, etc as outputs.
Closed loop - We add sensors to the above mentioned system for feedback, and
change the input accordingly. Sensors include resistive, inductive or capacitive
transducers, ultrasonic distance sensors, IR sensors, gas sensors, etc.
Sensors
● For measuring distance:
○ Ultrasonic Distance sensors
■ Ultrasonic waves are triggered, and the time that they take to reflect back is measured to
calculate distance of object.
■ Used for a range of 3cms to 4m.
■ Cheap and easily available.
○ Laser Distance sensors
■ Very accurate with high range and fast response time
■ Costly
● For differentiating between light and dark colours:
○ IR sensors: Emit Infrared rays, dark surfaces absorb them, light surfaces reflect them. A
reverse biased diode receives the reflected rays and detects bright surfaces. These are cheap
and can detect only dark or white surfaces.
○ Colour sensors: They can detect any colour depending upon the wavelength of light reflected
back, they are costly and can detect any distinct colour.
● For measuring Rotation:
○ Potentiometers: They are cheap and easy to use.
○ Rotary Encoders: They are more precise, and more complex than potentiometers.
● For measuring presence of gas: Various gas sensors use chemicals whose
conductivity varies with concentration of particular gas around them.
● For measuring magnetic field intensity: Hall sensors use Hall effect to detect
magnetic field variation around them.
● Miscellaneous sensors and combinations:
○ Many other sensors are used according to applications like vibration sensors, flow sensors,
temperature and humidity sensors, etc.
○ Combination of transducers can be used to make more applications like joystick, which uses a
combination of two potentiometers to detect rotation in X and Y axis.
Devices
● Once the Microcontroller processes the input, we need actuators and devices
to get an output.
● Just like sensors, we have many devices according to our applications. Some
of them are:
○ Motors - DC, Servo, Stepper, etc
○ Linear actuators
○ LED’s, LCD Displays, OLED displays, LED Matrix, etc
○ Buzzers
○ Relays
○ Various Modules
Coding
● Arduino IDE’s coding is a mixture of C and Java.
● The basic structure of a code comprises of two parts: Setup and Loop
● Setup is the part of the code which just runs once when the Arduino is
started, it defines which pins are we using and what do we want from the
board to do in this code.
● Loop is where you put your main code to run it throughout the time period of
the Arduino being switched on.
Input Output commands
● As we already know, there are two kinds of pins - digital and analog
● The input commands are:
○ digitalRead(pin_number);
○ analogRead(pin_number);
● The output commands are:
○ digitalWrite(pin_number, state); //State can be ‘HIGH’/1 or “LOW”/0
○ analogWrite(pin_number, value); //Value can be anything between 0 to 1023 (1024 values)
● // is used for writing single line comments, /* is used to write multi line
comments */
● To define the mode of pins (Input or Output) in setup, pinMode(mode); is
used. //mode = INPUT or OUTPUT
● To hold the looping code for some time at any instance, we use
delay(milliseconds); //milliseconds of the delay that we want
Variables, control statements, loops, arrays,
functions
● The above mentioned commands are same as in C, the only difference is that
instead of using “||”, we use “or”, and instead of “&&”, we use “and”.
We will be seeing some examples for more clarity now..
Example #1
A program to flash a LED connected to digital pin 9 when a button on digital pin 3
is pressed.
Connections:
Example #2
A program to make a tune Beepbeep….beepbeep… through a buzzer at pin 8.
Connection:
Example #3
A program to rotate a motor connected to pin 3 and 4 in a certain direction when a
button at pin 7 is pressed, and in opposite direction when a button at pin 8 is
pressed.
Connection:
Example #4
A program to make basic line follower robot using three infrared sensors and two
motors.
Line follower robot:
On a white surface, there is a black line. Our robot will follow that line. We use
three IR sensors here, if the surface under the IR sensor is black, it will return low
analog values. When the left IR sensor show black line under it, we stop the left
motor, and keep rotating the right motor, so that the robot takes a turn. For
smoother motion, we can also slow down the left motor instead of stopping it using
analog output through PWM pins. We perform the same action for right turn and
thus, follow the black line.
● Since Arduino can not provide sufficient current for operation of motors, we
use an IC called L293D, which is a motor driver IC.
● Motor driver IC’s use external power supply source to drive motors, and they
take signal from Arduino to determine where and when to supply the voltage
to the motor.
● The connections of L293D can be seen in the connection diagram shown in
next slide...
2
1
3
Troubleshooting
Here are the steps to perform troubleshooting in the system:
● Check for loose connections, if any.
● Check for proper shorting and voltage supply to each component.
● Check for connections you actually made and connections that you coded in
Arduino.
● Use serial monitor to check code and sensor values:
○ Serial monitor is a special facility in Arduino where you can print anything that goes on with the
sensors or the code on your laptop screen.
○ Use Serial.begin(9600); in setup function of the code to start Serial monitor at 9600 baud rate.
//Baud rate is the rate of data transmitted per second, it depends on level of our application.
○ We will explore Serial Monitor in upcoming slides...
Serial Monitor
● Serial monitor can be accessed through tools menu of Arduino IDE or by
pressing Ctrl+Shift+M.
● Serial.print(variable); command is used to print a variable, generally this is
used to check sensor output values or to calibrate sensors.
● Serial.println(variable); prints the value and moves to the next line.
● Serial.print(“Hey!”); can be used to print strings whenever required.
● The upcoming examples show how to use serial monitor...
Serial monitor example #1
● Suppose you are using analog input pins to get values from an IR sensor to
detect black and white lines.
● In a particular lighting condition, the IR sensor returns values below “500” for
black surface, and above “500” for white.
● So we code that if(analogRead(3) <= 500){ line = 0; /*0 for black*/ }.
● Now the lighting conditions change, and this time “700” below means black.
● So we need to calibrate the sensor and replace the 500 with 700.
● Now, how do we know about these values that the sensor is returning. This
500, 700, how do we determine these values?
● This is where the Serial monitor comes up!
Serial monitor example #2
Suppose you write a conditional code (using if else) in loop function and it doesn’t
work! :(
What could have happened! There’s no response from the code, so it might be
that the conditional command is false, and hence the code is not going further.
To check the state of the conditional command, we can use Serial monitor here!
● Now, we knew that the code wasn’t working since pin 5 was at LOW state.
So, to check which if condition if not working, we used the above mentioned
code.
● If serial monitor shows that only component at A2 satisfies the condition, we
will know that component at A4 is faulty, or if serial monitor doesn’t show
anything, then component at A2 may be faulty.
● In this way, the Serial monitor is used to reach the point of error very
accurately and eliminates the need of checking each and every component or
each and every part of the code.
Back to troubleshooting
● After we are done checking each and every part of the code with Serial
monitor, we will be able to find in which part the code goes wrong.
● After debugging the part, we check the functioning of the functions again, till it
works perfectly.
Conclusion
● After this basic part of the Arduino tutorial, we have reached the stage from
where we can control motors, buzzers, and many more devices using
buttons, sensors, or any input devices that we wish to use with Arduino.
● Next up: Using EEPROM memory of Arduino to store data even when it is not
working, using advanced Modules like the GPS, GSM, Wifi, etc; Using
displays such as OLED, LCD, SSD module, etc; Using Serial communication
and much more!
● Have fun exploring the new stuff now!
Get the Arduino IDE at: https://www.arduino.cc/en/Main/Software
Basics of mechatronics - Arduino tutorial

More Related Content

What's hot

Process control 2 chapter
Process control 2 chapterProcess control 2 chapter
Process control 2 chapterSrinivasa Rao
 
Introduction to HMI (Human Machine Interface) | Just Engineering
Introduction to  HMI (Human Machine Interface) |  Just EngineeringIntroduction to  HMI (Human Machine Interface) |  Just Engineering
Introduction to HMI (Human Machine Interface) | Just EngineeringJustengg1
 
Industrial automation - Sensors and Transducers
Industrial automation - Sensors and TransducersIndustrial automation - Sensors and Transducers
Industrial automation - Sensors and TransducersRamaniIA
 
Mechatronics-Introduction to Mechatronics System
Mechatronics-Introduction to Mechatronics SystemMechatronics-Introduction to Mechatronics System
Mechatronics-Introduction to Mechatronics SystemMani Vannan M
 
Automation PLC & SCADA
Automation PLC & SCADA Automation PLC & SCADA
Automation PLC & SCADA NITISH SINGH
 
Sensors and actuators
Sensors and actuatorsSensors and actuators
Sensors and actuatorsnazibhmd
 
Basic of Analog and Digital sensors.ppt
Basic of Analog and Digital sensors.pptBasic of Analog and Digital sensors.ppt
Basic of Analog and Digital sensors.pptEricByiringiro1
 
Embedded systems and their applications in our daily routine
Embedded systems and their applications in our daily routineEmbedded systems and their applications in our daily routine
Embedded systems and their applications in our daily routineAsad Qayyum Babar
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerMujahid Hussain
 
Smart Door locking system using arduino
Smart Door locking system using arduinoSmart Door locking system using arduino
Smart Door locking system using arduinoBhawnaSingh351973
 
Inductive proximity sensor
Inductive proximity sensorInductive proximity sensor
Inductive proximity sensorAkmal Hakim
 
automation slides,plc,scada,HMI
automation slides,plc,scada,HMIautomation slides,plc,scada,HMI
automation slides,plc,scada,HMIBOSCH
 
Scada classification
Scada classificationScada classification
Scada classificationAhmed Sebaii
 
Sensors And Actuators
Sensors And ActuatorsSensors And Actuators
Sensors And ActuatorsJinesh Patel
 
Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...
Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...
Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...Waqas Afzal
 
Basics of Automation, PLC and SCADA
Basics of Automation, PLC and SCADABasics of Automation, PLC and SCADA
Basics of Automation, PLC and SCADAIndira Kundu
 

What's hot (20)

Process control 2 chapter
Process control 2 chapterProcess control 2 chapter
Process control 2 chapter
 
Introduction to HMI (Human Machine Interface) | Just Engineering
Introduction to  HMI (Human Machine Interface) |  Just EngineeringIntroduction to  HMI (Human Machine Interface) |  Just Engineering
Introduction to HMI (Human Machine Interface) | Just Engineering
 
Industrial automation - Sensors and Transducers
Industrial automation - Sensors and TransducersIndustrial automation - Sensors and Transducers
Industrial automation - Sensors and Transducers
 
Mechatronics-Introduction to Mechatronics System
Mechatronics-Introduction to Mechatronics SystemMechatronics-Introduction to Mechatronics System
Mechatronics-Introduction to Mechatronics System
 
Automation PLC & SCADA
Automation PLC & SCADA Automation PLC & SCADA
Automation PLC & SCADA
 
Sensors and actuators
Sensors and actuatorsSensors and actuators
Sensors and actuators
 
Basic of Analog and Digital sensors.ppt
Basic of Analog and Digital sensors.pptBasic of Analog and Digital sensors.ppt
Basic of Analog and Digital sensors.ppt
 
Embedded systems and their applications in our daily routine
Embedded systems and their applications in our daily routineEmbedded systems and their applications in our daily routine
Embedded systems and their applications in our daily routine
 
Proximity sensor
Proximity sensorProximity sensor
Proximity sensor
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
Control system
Control systemControl system
Control system
 
Smart Door locking system using arduino
Smart Door locking system using arduinoSmart Door locking system using arduino
Smart Door locking system using arduino
 
Presentaton on Plc & Scada
Presentaton on Plc & ScadaPresentaton on Plc & Scada
Presentaton on Plc & Scada
 
Inductive proximity sensor
Inductive proximity sensorInductive proximity sensor
Inductive proximity sensor
 
Class 17 integral and derivative control mode
Class 17   integral and derivative control modeClass 17   integral and derivative control mode
Class 17 integral and derivative control mode
 
automation slides,plc,scada,HMI
automation slides,plc,scada,HMIautomation slides,plc,scada,HMI
automation slides,plc,scada,HMI
 
Scada classification
Scada classificationScada classification
Scada classification
 
Sensors And Actuators
Sensors And ActuatorsSensors And Actuators
Sensors And Actuators
 
Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...
Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...
Signal and System, CT Signal DT Signal, Signal Processing(amplitude and time ...
 
Basics of Automation, PLC and SCADA
Basics of Automation, PLC and SCADABasics of Automation, PLC and SCADA
Basics of Automation, PLC and SCADA
 

Similar to Basics of mechatronics - Arduino tutorial

Color Sensor.pptx
Color Sensor.pptxColor Sensor.pptx
Color Sensor.pptxRituSachan2
 
Physical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsPhysical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsTony Olsson.
 
Sensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerSensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerArsalanAthar
 
Automatic railway gate control using arduino uno
Automatic railway gate control using arduino unoAutomatic railway gate control using arduino uno
Automatic railway gate control using arduino unoselvalakshmi24
 
Automatic_room_light_controller_ PPT.pptx
Automatic_room_light_controller_ PPT.pptxAutomatic_room_light_controller_ PPT.pptx
Automatic_room_light_controller_ PPT.pptxSwarajDhumal
 
Robotics and Automation Using Arduino
Robotics and Automation Using ArduinoRobotics and Automation Using Arduino
Robotics and Automation Using ArduinoABHISHEKJAISWAL282
 
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...Tawsif Rahman Chowdhury
 
Smart Safety Door based on Arduino Uno R3
Smart Safety Door based on Arduino Uno R3Smart Safety Door based on Arduino Uno R3
Smart Safety Door based on Arduino Uno R3Ziddan Kundrat
 
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors  B...Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors  B...
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...Faqih Fadhila Ardiansyah
 
Porte à puce - Smart Safety Door based on Arduino UNO R3
Porte à puce - Smart Safety Door based on Arduino UNO R3Porte à puce - Smart Safety Door based on Arduino UNO R3
Porte à puce - Smart Safety Door based on Arduino UNO R3Meifani Sumadijaya
 
Introduction to arduino!
Introduction to arduino!Introduction to arduino!
Introduction to arduino!Makers of India
 
Digital tachometer using pic18
Digital tachometer using pic18Digital tachometer using pic18
Digital tachometer using pic18Muhammad Usman
 
Automatic Door Opener using PIR Sensor
Automatic Door Opener using PIR SensorAutomatic Door Opener using PIR Sensor
Automatic Door Opener using PIR SensorRAGHUVARMA09
 
Chapter 3 Monitoring and Control
Chapter 3 Monitoring and ControlChapter 3 Monitoring and Control
Chapter 3 Monitoring and ControlAnjan Mahanta
 

Similar to Basics of mechatronics - Arduino tutorial (20)

Color Sensor.pptx
Color Sensor.pptxColor Sensor.pptx
Color Sensor.pptx
 
Physical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsPhysical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensors
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Sensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerSensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controller
 
Complex Sensors
Complex SensorsComplex Sensors
Complex Sensors
 
Automatic railway gate control using arduino uno
Automatic railway gate control using arduino unoAutomatic railway gate control using arduino uno
Automatic railway gate control using arduino uno
 
Automatic_room_light_controller_ PPT.pptx
Automatic_room_light_controller_ PPT.pptxAutomatic_room_light_controller_ PPT.pptx
Automatic_room_light_controller_ PPT.pptx
 
Robotics and Automation Using Arduino
Robotics and Automation Using ArduinoRobotics and Automation Using Arduino
Robotics and Automation Using Arduino
 
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
 
Arduino Family
Arduino FamilyArduino Family
Arduino Family
 
Smart Safety Door based on Arduino Uno R3
Smart Safety Door based on Arduino Uno R3Smart Safety Door based on Arduino Uno R3
Smart Safety Door based on Arduino Uno R3
 
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors  B...Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors  B...
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
 
Porte à puce - Smart Safety Door based on Arduino UNO R3
Porte à puce - Smart Safety Door based on Arduino UNO R3Porte à puce - Smart Safety Door based on Arduino UNO R3
Porte à puce - Smart Safety Door based on Arduino UNO R3
 
Introduction to arduino!
Introduction to arduino!Introduction to arduino!
Introduction to arduino!
 
JamesEndl
JamesEndlJamesEndl
JamesEndl
 
Digital tachometer using pic18
Digital tachometer using pic18Digital tachometer using pic18
Digital tachometer using pic18
 
Automatic Door Opener using PIR Sensor
Automatic Door Opener using PIR SensorAutomatic Door Opener using PIR Sensor
Automatic Door Opener using PIR Sensor
 
Chapter 3 Monitoring and Control
Chapter 3 Monitoring and ControlChapter 3 Monitoring and Control
Chapter 3 Monitoring and Control
 
chapter 3.pdf
chapter 3.pdfchapter 3.pdf
chapter 3.pdf
 
Sensors.pptx
Sensors.pptxSensors.pptx
Sensors.pptx
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Basics of mechatronics - Arduino tutorial

  • 1. Basic Mechatronics Basic Tutorial for Arduino By, Manas Shrivastava MNNIT, Allahabad
  • 2. Contents ● Control systems - open loop and closed loop ● Structure of Arduino ● What can I do with Arduino? ● Open loop control system with Arduino ● Closed loop control system with Arduino ● Sensors ● Devices ● Coding ● Examples ● Troubleshooting
  • 3. Control Systems ● Any system that controls a process based on inputs given to it is a control system. ● In our everyday life, we are surrounded by various control systems. ● For example, the maintenance of a definite temperature inside a refrigerator is achieved through a control system. ● A simple cam-follower mechanism is an example of a control system. ● Touch screen of phone functions through a control system. ● As we can see, there are infinite control systems all around us. ● Control systems are not just mechanical or electrical, even the facing of a sunflower towards the sun and the entire operation of the human body are also a few examples of controls systems.
  • 4. A broad classification of control systems There are broadly two kinds of control systems - Open loop control and Closed loop control systems. Open loop control systems - These systems do not take any feedback from the output conditions. We just give an input and get an output. Easy and cheap :) Closed loop control systems - These systems take their job seriously and check whether the system is producing the desired output or not? This requires feedback from the output conditions and thus, increases the complications and cost of the system. Depending upon our application, we choose open or closed control system.
  • 5.
  • 6. Examples of open loop control systems ● Cam-follower pair ● Induction Cooker ● Air conditioner in a car ● Remote of TV ● Manual Washing machine ● Regulator of fans ● Spring damper system ● Water taps ● Shells from cannons
  • 7. Examples of closed loop control systems ● Valve opening in IC Engines by camshaft. ● Air conditioners/ Refrigerators ● Guided bombs and missiles ● Autopilot in aircrafts ● Adaptive brightness in smartphones ● Automatic doors in buildings ● Automatic electric iron ● Water level control through balloon in tanks
  • 9. What can we do with an Arduino? ● A wide range of operations is possible by making use of the Arduino IDE. ● Project examples- 1. Remote controlled Quadcopter drone 2. Theft detector 3. Home automation circuit 4. Automatic sweet dispenser 5. Sorting machines 6. Bomb defuser (and the bomb as well) 7. Spyware 8. Robots carrying out various functions 9. Robotic Arm 10.Health tracker
  • 10. Open loop and closed loop control system with Arduino Open loop - Arduino is the microcontroller, we give input through the code, and anything like a motor, LED, buzzer, can be used as an actuator to give motion, rotation, sound, light, etc as outputs. Closed loop - We add sensors to the above mentioned system for feedback, and change the input accordingly. Sensors include resistive, inductive or capacitive transducers, ultrasonic distance sensors, IR sensors, gas sensors, etc.
  • 11. Sensors ● For measuring distance: ○ Ultrasonic Distance sensors ■ Ultrasonic waves are triggered, and the time that they take to reflect back is measured to calculate distance of object. ■ Used for a range of 3cms to 4m. ■ Cheap and easily available. ○ Laser Distance sensors ■ Very accurate with high range and fast response time ■ Costly ● For differentiating between light and dark colours: ○ IR sensors: Emit Infrared rays, dark surfaces absorb them, light surfaces reflect them. A reverse biased diode receives the reflected rays and detects bright surfaces. These are cheap and can detect only dark or white surfaces. ○ Colour sensors: They can detect any colour depending upon the wavelength of light reflected back, they are costly and can detect any distinct colour.
  • 12. ● For measuring Rotation: ○ Potentiometers: They are cheap and easy to use. ○ Rotary Encoders: They are more precise, and more complex than potentiometers. ● For measuring presence of gas: Various gas sensors use chemicals whose conductivity varies with concentration of particular gas around them. ● For measuring magnetic field intensity: Hall sensors use Hall effect to detect magnetic field variation around them. ● Miscellaneous sensors and combinations: ○ Many other sensors are used according to applications like vibration sensors, flow sensors, temperature and humidity sensors, etc. ○ Combination of transducers can be used to make more applications like joystick, which uses a combination of two potentiometers to detect rotation in X and Y axis.
  • 13. Devices ● Once the Microcontroller processes the input, we need actuators and devices to get an output. ● Just like sensors, we have many devices according to our applications. Some of them are: ○ Motors - DC, Servo, Stepper, etc ○ Linear actuators ○ LED’s, LCD Displays, OLED displays, LED Matrix, etc ○ Buzzers ○ Relays ○ Various Modules
  • 14. Coding ● Arduino IDE’s coding is a mixture of C and Java. ● The basic structure of a code comprises of two parts: Setup and Loop ● Setup is the part of the code which just runs once when the Arduino is started, it defines which pins are we using and what do we want from the board to do in this code. ● Loop is where you put your main code to run it throughout the time period of the Arduino being switched on.
  • 15. Input Output commands ● As we already know, there are two kinds of pins - digital and analog ● The input commands are: ○ digitalRead(pin_number); ○ analogRead(pin_number); ● The output commands are: ○ digitalWrite(pin_number, state); //State can be ‘HIGH’/1 or “LOW”/0 ○ analogWrite(pin_number, value); //Value can be anything between 0 to 1023 (1024 values) ● // is used for writing single line comments, /* is used to write multi line comments */ ● To define the mode of pins (Input or Output) in setup, pinMode(mode); is used. //mode = INPUT or OUTPUT ● To hold the looping code for some time at any instance, we use delay(milliseconds); //milliseconds of the delay that we want
  • 16. Variables, control statements, loops, arrays, functions ● The above mentioned commands are same as in C, the only difference is that instead of using “||”, we use “or”, and instead of “&&”, we use “and”. We will be seeing some examples for more clarity now..
  • 17. Example #1 A program to flash a LED connected to digital pin 9 when a button on digital pin 3 is pressed. Connections:
  • 18.
  • 19. Example #2 A program to make a tune Beepbeep….beepbeep… through a buzzer at pin 8. Connection:
  • 20.
  • 21. Example #3 A program to rotate a motor connected to pin 3 and 4 in a certain direction when a button at pin 7 is pressed, and in opposite direction when a button at pin 8 is pressed. Connection:
  • 22.
  • 23. Example #4 A program to make basic line follower robot using three infrared sensors and two motors. Line follower robot: On a white surface, there is a black line. Our robot will follow that line. We use three IR sensors here, if the surface under the IR sensor is black, it will return low analog values. When the left IR sensor show black line under it, we stop the left motor, and keep rotating the right motor, so that the robot takes a turn. For smoother motion, we can also slow down the left motor instead of stopping it using analog output through PWM pins. We perform the same action for right turn and thus, follow the black line.
  • 24. ● Since Arduino can not provide sufficient current for operation of motors, we use an IC called L293D, which is a motor driver IC. ● Motor driver IC’s use external power supply source to drive motors, and they take signal from Arduino to determine where and when to supply the voltage to the motor. ● The connections of L293D can be seen in the connection diagram shown in next slide...
  • 25.
  • 26. 2 1 3
  • 27. Troubleshooting Here are the steps to perform troubleshooting in the system: ● Check for loose connections, if any. ● Check for proper shorting and voltage supply to each component. ● Check for connections you actually made and connections that you coded in Arduino. ● Use serial monitor to check code and sensor values: ○ Serial monitor is a special facility in Arduino where you can print anything that goes on with the sensors or the code on your laptop screen. ○ Use Serial.begin(9600); in setup function of the code to start Serial monitor at 9600 baud rate. //Baud rate is the rate of data transmitted per second, it depends on level of our application. ○ We will explore Serial Monitor in upcoming slides...
  • 28. Serial Monitor ● Serial monitor can be accessed through tools menu of Arduino IDE or by pressing Ctrl+Shift+M. ● Serial.print(variable); command is used to print a variable, generally this is used to check sensor output values or to calibrate sensors. ● Serial.println(variable); prints the value and moves to the next line. ● Serial.print(“Hey!”); can be used to print strings whenever required. ● The upcoming examples show how to use serial monitor...
  • 29. Serial monitor example #1 ● Suppose you are using analog input pins to get values from an IR sensor to detect black and white lines. ● In a particular lighting condition, the IR sensor returns values below “500” for black surface, and above “500” for white. ● So we code that if(analogRead(3) <= 500){ line = 0; /*0 for black*/ }. ● Now the lighting conditions change, and this time “700” below means black. ● So we need to calibrate the sensor and replace the 500 with 700. ● Now, how do we know about these values that the sensor is returning. This 500, 700, how do we determine these values? ● This is where the Serial monitor comes up!
  • 30.
  • 31.
  • 32. Serial monitor example #2 Suppose you write a conditional code (using if else) in loop function and it doesn’t work! :( What could have happened! There’s no response from the code, so it might be that the conditional command is false, and hence the code is not going further. To check the state of the conditional command, we can use Serial monitor here!
  • 33.
  • 34. ● Now, we knew that the code wasn’t working since pin 5 was at LOW state. So, to check which if condition if not working, we used the above mentioned code. ● If serial monitor shows that only component at A2 satisfies the condition, we will know that component at A4 is faulty, or if serial monitor doesn’t show anything, then component at A2 may be faulty. ● In this way, the Serial monitor is used to reach the point of error very accurately and eliminates the need of checking each and every component or each and every part of the code.
  • 35. Back to troubleshooting ● After we are done checking each and every part of the code with Serial monitor, we will be able to find in which part the code goes wrong. ● After debugging the part, we check the functioning of the functions again, till it works perfectly.
  • 36. Conclusion ● After this basic part of the Arduino tutorial, we have reached the stage from where we can control motors, buzzers, and many more devices using buttons, sensors, or any input devices that we wish to use with Arduino. ● Next up: Using EEPROM memory of Arduino to store data even when it is not working, using advanced Modules like the GPS, GSM, Wifi, etc; Using displays such as OLED, LCD, SSD module, etc; Using Serial communication and much more! ● Have fun exploring the new stuff now! Get the Arduino IDE at: https://www.arduino.cc/en/Main/Software