Want to create interactive content? It’s easy in Genially!
Mechatronics foundation lab
Pragya Duggal
Created on November 13, 2022
Start designing with a free template
Discover more than 1500 professional designs like these:
View
Practical Presentation
View
Smart Presentation
View
Essential Presentation
View
Akihabara Presentation
View
Pastel Color Presentation
View
Nature Presentation
View
Higher Education Presentation
Transcript
Mechatronics Foundations Lab
BE-Mechatronics
Index
Section 3
About
Potentiometer and LDR sensor
Introduction to Arduino
Section 4
Section 1
Ultrasonic sensors
Input/Output signals and PWM
Section 5
Section 2
Project work : Mood Lamp
LED and push button
ABOUT
Introduction to Arduino
An Arduino is an open source hardware development board that can be used by tinkerers, hobbyists and makers to design and build devices that interact with the real world.Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins of which 6 can be used as PWM outputs, 6 analog outputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller, simply connect it to a computer with a USB cable or power it with AC-to-DC adapter or battery to get started.
Arduino Board
Menu
Section 1
Input/Output signals
Digital Input
Digital Output
Analog Input
Digital input means when we are supplying HIGH/1/+5V or LOW/0/GND to the Arduino board. Digital inputs are binary inputs (0 or 1) that are applied to the PLC. Binary inputs are basically voltages, varying from 5V to 230V depending upon the type of card used. For example, it will help to read the LED as photodiodes.
Digital output means when we are taking HIGH/1/+5V or LOW/0/GND from the Arduino.Digital outputs are binary outputs (0 or 1) from the PLC. It is a processed control output from the PLC to the field. It is used to ON or OFF any piece of field equipment. DO is like a contact of a relay when the preprogrammed conditions are satisfied the contacts are closed.
The analogue inputs are used in control systems with input sensors that produce a voltage, current or resistance change in response to an environmental variation or system measurement. The main function of the analog pin in Arduino is to read the analog sensors. The analog pins also have all the functionality of general-purpose input/output.
ADC Pins: Analog to Digital Pins
There are 6 analog input pins in Arduino Uno namely, A0, A1, A2...and so on. The Analog pins are further connected to an A.D.C. pin. It has 10-bit ADC, meaning it will give digital value iin the range of 0-1023 (210). This is called as resolution which indicates the number of discrete values it can produce over the range of analog values. Digital Output Value Calculation: Digital Output = Vin / Resolution where, ADC Resolution = Vref / (2n - 1) Vref: The reference voltage is the maximum value that the ADC converts. Functions for Arduino ADC: analogRead (pin): This function is used to read analog value from specified analog pin. Pin: Number fo analog pin which want to read. Returns: digital value between 0 and 1023. For an example, analogRead(A0)//read analog value at A0 channel. analogReference (type): This function is used for configuring the refernece voltage used for analog input.
PWM - Pulse Width Modulation
Pulse Width Modulation or PWM is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal is switched between on and off. This on-off pattern can stimulate voltages in between 0V and 5V. The duration of "on" time is called the pulse width. To get varying analog values, you change or modulate that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage controlling the brightness of the LED. The Arduino IDE has a built-in function, "analogWrite()" which can be used to generate the PWM signal. The frequency of this generated signal for most pins will be about 490 Hz and we can give the value from 0-255 using this function.
A PWM signal consists of two main components that define its behaviour, a duty cycle and a frequency.
The frequency of a signal determines how fast the PWM completes a cycle (i.e., 1000 Hz would be 1000 cycles per second) which means how fast it switches between On (high) and OFF (low) states. By repeating this ON-OFF pattern at a fast-enough rate, and with a certain duty cycle, the output will appear to behave like a constant voltage signal when providing power to the devices. To sum it up, PWM frequency is the count of PWM interval periods per second, expressed in Hertz. Mathematically: PWM frequency = 1/PWM interval period
A period of a pulse consists of an ON cycle (5V) and an OFF cycle (0V). The fraction for which the signal is ON over a period is known as a duty cycle. It is given out as a percentage. For example, a perefect square wave with equal high time and low time has a duty cycle of 50%, which actually means that the 50% of the time, it is ON and for 50% of the time, it is OFF. Mathematically: Duty Cycle = [Ton / (Ton+Toff)]*100
Section 2
LED and Push Button
A light-emitting diode (LED) is a semiconductor device that emits light when current flows through it. Electrons in the semiconductor recombine with electron holes, releasing energy in the form of photons.We connect positive of led to digital out pins and negative to ground pins.Then declare the pin using pinMode(pin no. , HIGH) .Then we can turn on and blink led using digitalWrite and delay functions.
Arduino (ATmega) has in-built configurable push button. These resistors enable using pinMode () with mode set to INPUT_PULLUP. When connecting a device or sensor to a pin configured as input with pull-up, the other end should be connected to ground. e.g. pinMode (3, INPUT_PULLUP). We can configure input pull-up in another way too. If we set direction of pin as input and then write HIGH value on that pin will turn on the pull-up resistor. In other manner, if we write HIGH on pin configured as OUTPUT and then configure that pin as input will also enable the pull-up resistor.
To switch the LED on.
Section 3
&
LDR Sensor
Potentiometer
A potentiometer is a simple mechanical device that provides a varying amount of resistance when its shaft is turned. By passing voltage through a potentiometer and into an analog input on your board, it is possible to measure the amount of resistance produced by a potentiometer (or pot for short) as an analog value. The Arduino boards ADC that reads this changing voltage and converts it to a number between 0 and 1023. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is turned all the way in
LDR ( light dependent resistor ) also called photoresistors are responsive to light. Photoresistors are used to indicate the intensity or the presence or the absence of light. When there is darkness the resistance of photoresistor increases and when there is sufficient light it dramatically decreases. LDR ( light dependent resistor ) which has two terminals. Terminal one is the signal pin which should be connected according to the code. Another terminal is considered as the ground pin which should be connected to the ground of the system. Connections of LDR sensor : First terminal should be connected to analog pin 0 (A0) of Arduino. Second terminal should be connected any one led pf the resistor. Another leg of resistor should be connected to Gnd of Arduino. Led connections : Positive pin should be connected to digital
the opposite direction, there are 5 volts going to the pin and the input value is 1023. In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.
pin 5 of Arduino. Negative pin should be connected any one led pf the resistor. Another leg of resistor should be connected to Gnd of Arduino.
Potentiometer working with Arduino
Arduino
Potentiometer
LDR sensor working with Arduino
Arduino
LDR
Section 4
Ultrasonic sensors
Ultrasonic sensor
An ultrasonic sensor is an electronic device that measures the distance of a target object by emitting ultrasonic sound waves, and converts the reflected sound into an electrical signal. Ultrasonic sensors are highly accurate and can be used to detect very small alterations in position. Ultrasonic sensors have two main components: the transmitter, which transmits the sound using piezoelectric crystals and the receiver, which encounters the sound after it has travelled to and from the target. Considering the travel time and the speed of the sound, it can calculate distance. There are four pins that are used to interface Arduino with the sensor, VCC, trig (signal output pin), Echo (signal input pin), and Gnd.
Ultrasonic HC-SR04 module Timing
In order to generate the ultrasound we need to set the Trigger Pin on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo Pin. The Echo Pin will output the time in microseconds the sound wave traveled. If the object is 20 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 588 microseconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by speed of sound (0.034) and divide it by 2.
Working of an Ultrasonic sensor with Arduino
Section 5
Project Work: Mood Lamp
The Mood lamp is an exclusive working system of an Arduino board along with RGB LEDs, resistors and a touch sensor. It works in such a way that whenever the touch sensor is touched by a human, it changes the colour in a cycle of eight colors, namely, Red, Green, Blue, Greenish-blue, Purple, Orange, Pink, Spring Green. It is called a mood lamp since it changes colour whenever the human adds the input to change the colour through the touch sensor. The code is stored on the Arduino atmega board and connected to a power supply, a battery and so it works properly. It can be used in households and workplaces as a decor item.
Coding done for the mood lamp and to make it work using Arduino.
Thank You!
submitted by:
- Pragya Duggal
- Lavanya
- Raghav Aggarwal