Robotics 10 Second Quarter - Arduino Tutorial PDF

Summary

This document provides an overview of robotics and Arduino concepts for the second quarter. It details the components of an Arduino Uno, its uses, and the Arduino IDE, and introductory information on how to use it.

Full Transcript

ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias 2.1 - ARDUINO MICROCONTROLLER AND Reset Button This is used to restart the INSTALLING THE ARDUINO IDE...

ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias 2.1 - ARDUINO MICROCONTROLLER AND Reset Button This is used to restart the INSTALLING THE ARDUINO IDE system. ARDUINO MICROCONTROLLER A microcontroller is one of the vital components Power Header of modern electronics. It serves as the heart and This is used to supply enough brain of electronic devices. power to the external Its capabilities are innumerable depending on components of an Arduino what it is instructed to do through a program. project. Digital Input/Output Pins WHY USE ARDUINO? These pins are used to connect external devices to Affordability your board. Digital pins are Simplicity used to read or write digital Cross-Platform Compatibility data, which either HIGH or Open Source LOW. Arduino Community Analog Input Pins ARDUINO UNO MICROCONTROLLER Compared with digital data, which are either HIGH or LOW Arduino Uno is an open-source microcontroller analog data covers all values board based on the ATmega328P microcontroller in a specific range. that was developed by Arduino. Analog Input Pins A0 to A5 PARTS OF THE ARDUINO UNO MICROCONTROLLER Analog Output Pins/PWM UNIT (Pulse-width Modulated Pins) Analog Output pins -3, -5, -6, Microcontroller -9, -10, and -11. (ATmega328P) Arduino Uno is an open-source microcontroller ARDUINO IDE board based on the ATmega328P microcontroller Integrated Development Environment ( I D E ) is a that was developed by software application that provides the developer Arduino. or programmer a development tool with a graphic user interface (GUI) to write and test the USB Port code. This is used both to supply power to the system and to transmit and upload data GETTING STARTED WITH ARDUINO IDE from this computer. Downloading Arduino Software IDE Barrel Jack Installing Arduino IDE It is a circular port with a Opening Arduino IDE 2.1mm diameter. It is another way to supply power to the board using an AC-DC adapter that has 6-20 Volts output. 1 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias PARTS OF THE ARDUINO IDE Toolbar - Open Button This is used to retrieve a Title Bar previous sketch. This shows the filename of the sketch. Toolbar - Save Button This allows you to save the Menu Bar current sketch to your This allows access to all the computer. different functions and commands of the Arduino IDE. Serial Monitor This connects the computer Toolbar and the Arduino. This allows access to all the different functions and commands of the Arduino IDE: Verify Button, Upload Button, New File Button, Open Button, & Save Button Status Bar This provides feedback after Toolbar - Verify Button the verification and compiling This is used to check the code of the program. for any syntax error before the program is uploaded to your controller MICROCONTROLLER TO A COMPUTER Toolbar - Upload Button Using a Type A-B USB Cable, you can directly This is used to transfer connect your Arduino board to your computer. programs from your computer to the microcontroller. SETTING UP THE IDE FOR ARDUINO UNO Selecting the Microcontroller Selecting the Port Toolbar - New File Button This allows you to create a new file or new Arduino window. 2 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias ARDUINO IDE BASIC FUNCTION 2.1 - GETTING STARTED WITH CIRCUITS Saving an Arduino Sketch SIGNALS (File>Save)(Ctrl + S)(Save button) It is used by devices to transmit information from Creating a New Arduino Sketch one device to the other. (File>New)(Ctrl+N) Opening a New Arduino Sketch ANALOG SIGNAL (File>Open)(Ctrl+O)(Open button) It is a continuous wave that changes over a time period. To Check for Syntax Error (Sketch >Verify/Compile)(Ctrl+R)(Verify Button) Uploading the Sketch in the Microcontroller Unit (Sketch>Upload)(Ctrl+U)(Upload button) DIGITAL SIGNAL It is a discrete wave that carries information in binary form. CIRCUITS It refers to different electronic components including resistors, ELECTRONIC transistors, capacitors, CIRCUIT diodes, and others that are conductively connected through wires that allow electricity to flow. Direct current (DC) occurs DIRECT CIRCUIT when the current flows in one constant direction. It usually comes from batteries, solar cells, or from AC/DC converters. Alternating current (AC) ALTERNATING occurs when the electric CIRCUIT current periodically inverts its direction. AC is the method used to deliver electricity through power transmission lines to homes and businesses 3 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias CURRENT TERMINAL STRIPLS (COLUMN) These allow vertical serial It is the kind of circuit that is usually measured in connections. These are amperes or amps (A). where the main components of the circuit are connected. VOLTAGE It is the potential difference in electric energy JUMPER WIRES from one point to the other in the circuit that is measured in volts (V). Jumper wires are short electrical wires that are used to interconnect the different components of RESISTANCE an electronic circuit in the breadboard and the Arduino board. It is a measure of how much components resist Male to male, Female to Male, Female to female or oppose the flow of the current in the circuit that is measured in ohms (Ω). LIGHT EMITTING DIODE (LED) TOLERANCE It is a two-lead semiconductor tiny light bulb that emits light when an electric current passes It is the percentage error of how much or less through it. resistance can be expected from its actual Cathode - Shorter pin and must be connected to measure to its stated resistance. the GND (ground) side. Anode - It can be connected to any of the digital SOLDERLESS BOARD pins (0-19) in your board LED requires a resistor, otherwise, it will easily The solderless breadboard or simply breadboard burn out. is an important component in building your The resistor can be any value between 100 ohms temporary electronic circuit without the need for and 10K ohms. soldering Commonly, 220 ohms is used for LED. A lower value resistor will make an LED emit a PARTS OF A SOLDERLESS BREADBOARD brighter light while a higher value resistor will limit the current flow, making the LED light RAVINE dimmer. This is a horizontal crevasse that separates the two sides of the breadboard in the middle. It serves as a support for dual in-line package (DIP) chip. POWER RAILS This is a serial connection that runs horizontally. It is usually labelled with (+) and (-) and sometimes with a color code to suggest that a red stripe indicates the positive side while a blue, green, or black stripe indicates the negative side. 4 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias 2.3 - LIGHT DEPENDENT RESISTOR 2.4 - PULSE WIDTH MODULATION LIGHT DEPENDENT RESISTOR PULSE WIDTH MODULATION (PWM) Light Dependent Resistor (LDR) is a light sensitive A technique used to simulate an analog output device that is used to measure the intensity of by varying the pulse width (duty cycle) of a light. Other common names for LDR are digital signal. photocell, photoconductive cell, and PWM is typically used to control things like LED photoresistors. brightness, motor speed, and audio signals. Act as a sensor. Small in size. PULSE WIDTH MODULATION - DUTY CYCLE Does not require electric energy. Low power. 1. The duration for which the signal remains HIGH No polarity/bi-directional. within one cycle. 2. Example: A 50% duty cycle means the signal is APPLICATIONS HIGH half the time and LOW the other half. 3. The higher the duty cycle, the more empower Automatic Lighting Switch - The LDR can or brightness the device receives. automatically turn on a light at a certain light level particularly when it is dark. PULSE WIDTH MODULATION IN ELECTRONICS Camera Shutter Control - The LDR is used to detect the intensity of the light and automatically PWM is used in applications like dimming LEDs, adjusts the camera shutter speed to its proper controlling motor speed, audio signal generation, level. and more. Light Meter - It provides information such as a By controlling the amount of time a device is "on, measurement of the exposure or light intensity to " we can simulate continuous analog signals with identify the appropriate combination of the a digital output. shutter speed and aperture to be used. PWM AND ARDUINO Not all Arduino pins support PWM. On the Arduino Uno, PWM-capable pins include 3, 5, 6, 9, 10, and 11 1. PWM is achieved using the analogWrite() function. ANALOGWRITE() FUNCTION Syntax: analogWrite(pin, value) Parameters - pin: the pin to write to. Allowed data types: int. - value: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int 5 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias 2.5 - PIEZO BUTTON & tone() FUNCTION tone() FUNCTION The tone() function is used to allow the piezo PIEZO BUZZER buzzer buzzer to sound. A piezo buzzer (or piezo speaker) is a small audio The frequency will be set when tone() is called on signaling electronic device using piezoelectric the same pin. material that vibrates and moves it receives The pin connected to the piezo buzzer can only electricity, thus producing tones or sounds. generate one tone at a time. With that, if the tone() is already playing in a different pin, calling the function with the other pin will have no effect. CHARACTERISTICS Syntax: tone(pin, frequency); Parameters Wide-operating voltage: 3~250V - Pin: pin number to which the buzzer plays the Lower current consumption: less than 30 mA tone higher rated frequency. Frequency: specify the pitch of the tone in hertz Reliable: Effective in a wide variety of equipment unsigned int and ambient conditions with a clear and Duration: the duration of the tone in milliseconds pleasant electronic tone. (optional) High performance: Able to produce high volume and pressure levels with a wide frequency. noTone() FUNCTION LIMITATIONS When playing different pitches on multiple pins, the noTone() must be called on one pin before The tone() cannot be used while also using the calling the tone() on the next pin. analogwrite() on pins 3 or 11 for it will produce a The noTone() function stops the generation of weird sound. sound created by the tone() function. You cannot generate a tone lower than 31 Hz. If the duration is not specified in the tone() The tone() function cannot play multiple piezo function, the sounds will play continuously until buzzers at the same time even if they are on the noTone() function is called. different pins. You may play them one after the Syntax: noTone(pin); other but make sure to use noTone() to turn off Parameters the first sound before turning on the next one. - Pin: pin number to which the buzzer plays the tone APPLICATIONS Input Indicator Security System Automatic Parking System ARDUINO CIRCUIT DIAGRAM USING PIEZO BUZZER v Materials: Arduino microcontroller, USB connector, breadboard, male to male wire, piezo buzzer. v 6 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias 2.6 -CREATING MELODIES AND TONE 2.7 - ULTRASONIC SENSOR SEQUENCES ULTRASONIC SENSOR CREATING MELODIES AND TONE SEQUENCES An ultrasonic sensor is an excellent contactless Creating melodies and tone sequences with range sensor that uses ultrasonic sound waves Arduino is a fun way to add sound effects to your (sonar) to measure the distance of an object. projects. You can achieve this using the tone() function, which generates square waves at ULTRASONIC SENSOR HC-SR04 specific frequencies to produce different musical notes. There are two types of ultrasonic sensors: Proximity Detection, which is able to detect an BASIC OF SOUND object passing within a specified range and generate an output signal. Sound is a vibration that travels through the air Ranging Measurement, where the distance of a and can be heard when it reaches a person's ear. moving object from the sensor is continuously Frequency (measured in Hertz, Hz): Determines calculated at given time intervals between the pitch of the sound. Higher frequencies = transmission and reflection of sound waves to higher pitch, lower frequencies = lower pitch measure the distance of the objects. PIEZO BUZZER APPLICATIONS Piezo Buzzer: It uses electrical signals to create Vehicle parking sensor signals the driver for any vibrations, producing sound. obstacles while parking. Types of Buzzers: Active (plays a fixed tone) vs. Barrier parking system car entry is controlled Passive (plays varying tones based on through a barrier. frequency). Liquid level control that identifies the water tank levels. Flood control measures and identifies the flood level in the street or river. People detection used for counting. Stacking height control and segregation in warehouse. Protection system notifies the owner if the object is beyond the specified range. CREDITS: UST-JHS | GRADE 10 - TLE LEARNING AREA Contents are purely from the PPTs given by the subject teacher. Encouraged not to make this as your main reviewer. 7 | Rob10|2Q ROBOTICS 10 | Second Quarter Transcribed by: Marchael Matias 2.8 - DC MOTOR AND MOTOR DRIVER SHIELD The 74HC595 shift register, on the other hand, extends the Arduino’s four digital pins to the eight-direction control pins of two L293D chips. DC MOTOR A direct current (DC) motor is an electric MOTOR POWER CONNECTIONS machine that converts direct current electrical The shield supports a motor voltage range of 4.5 energy into rotary mechanical energy through to 25 volts. This power can be shared with the the interaction of magnetic fields and Arduino or used separately. In order to choose conductors. between the two, a special jumper labeled PWR is It is an actuator that produces continuous provided near the two terminal power connector. rotating movement. The speed of its rotation can be easily controlled making it useful in DC MOTOR CONNECTIONS applications that require speed control and The output channels of both L293D ICs are positioning. broken out to the edge of the shield with two 5-pin screw terminals labeled M1, M2, M3, and M4. A total of four DC motors operating at 4.5 – 25V APPLICATIONS can be connected to these terminals. Domestic Appliances OTHER FEATURES It can be used to manipulate and control the The shield includes a pulldown resistor array to rotation of appliances. keep motors off during power-up. Fans, blowers, pumps, DVD players, washing, The on-board LED indicates that the motor power other spinning machines supply is working properly. The motors will not run if it is not lit. Industrial Application The RESET button is nothing but Arduino’s reset Larger, high-end DC motors are responsible for button. It has been brought to the top for easy the operation of most industrial equipment. In access. factories, they are used to start, move, and stop Six analog pins (A0 to A5), as well as 5V and conveyor belts carrying products through ground connections, are provided in the bottom different stages of production including labeling, right corner. You can populate these with bottling, and packaging headers, making them useful for connecting various sensors. Automobile DC motors are also used in automobiles to control the wheels, producing torque to move, start, and stop the vehicle and control its speed. HARDWARE OVERVIEW DRIVER CHIPSET The L293D Motor Driver Shield is a hardware component commonly used in robotics and electronics projects to control DC motors or stepper motors using a microcontroller, such as an Arduino. The brains of the shield are two L293D motor drivers and a 74HC595 shift register. The L293D is a dual-channel H-Bridge motor CREDITS: UST-JHS | GRADE 10 - TLE LEARNING driver that can control two DC motors or a single AREA stepper motor. Because the shield includes two Contents are purely from the PPTs given by the subject such motor drivers, it can control up to four DC teacher. Encouraged not to make this as your main motors or two stepper motors. reviewer. 8 | Rob10|2Q

Use Quizgecko on...
Browser
Browser