Robotics Session day 1
-
Upload
afzal-ahmad -
Category
Documents
-
view
82 -
download
0
Transcript of Robotics Session day 1
CIRCUITS
Electronic circuits?They are a combination of electronic components like resistors, capacitors, transistors etc.
REsistorsThe ohm guy iscalled the Resistor.
transistorsTransistors are an amazing device that can act as a switch.
What do these circuits do?They make each and every thing around us. All the electronic things we see are made from a circuit board.
A simple circuitA simple circuit to light up a bulb.(I know that’s a Boring example)
A mouse with a simple enough circuit
What about a proximity sensor?This circuit can sense any move-ment around it.That’s so very amazing.
A computer motherboard
A motherboard is the major circuit board inside a computer that controls the entire computer. As you saw there were a large number of black boxes on it. So, what are these? The answer is an amazing technology that transformed the world we live in.
Integrated circuit - the magical black box
Integrated circuit are a combination of different circuits elements mounted on a single chip of silicon. These blocks can reduce the size of a large circuit to less than a fingertip while increasing the efficiency.
MicrocontrollersA microcontroller is a combination of processor, memory and input- output peripherals. It is a basically a small computer reduced to the size of a black box.
Microcontroller
What is programming a microcontroller?Programming a microcontroller means setting a set of instructions on the microcontroller to perform a task.The taskmay be addition of two numbers or lighting up an LED or running a motor.
How to program a microcontroller?A software called a compiler is used to convert human level code to electronic instructions. Then these instructions are feeded to the memory of the microcontrollerand these instructions are executed when required.
Arduino The
programmable circuit board
What is an Arduino Board ?A programmable multi-purpose circuit board used to make projects. It is a learning platform for beginners in microcontroller programming.
Describing different parts of Arduino 1: The microcontroller - Atmega328p2: The clock - 16 MHz
3: Input -Output pins4: USB programming port
About the various parts of ArduinoThe microcontroller is the brain of the board. All the commands are given as input to the microcontroller and it works as a C.P.U to process them and gives the output.But it’s not a simple C.P.U or processor.
The microcontroller gives output in the form of current or voltage that can be used to drive other components of a circuit for example- an LED or a motor.
How do you think the controller work?There is a clock attached to the microcontroller that controls the amount of work done by the microcontroller in a second. This clock controls the number of things the controller can do in a second.
The clock- basically a crystal that vibrates.It is similar to the crystal that controls your analog watch.
The clock on the Arduino board here is of 16 Mhz. So, it can process 16 million instructions in a second.
The USb programmer The Arduino board is an advanced board soIt can directly be programmed through aComputer software. There is a USB port available on the board for connecting it to the computer.
The USB port connects the board to the computer. The Arduino software is used to write the program and then upload it to the board. The program then executes itself on the board.
The input and output pinsDigital Input pins- There are 13 digital input/output pins on the board marked as 0-13. These pins can give output of 0V or +5V.They can also take input but only as 0V or +5V.
Digital - meaningDigital means we will work with discrete values of voltages. Normally we use 0V as LOW signal and +5V as HIGH signal. Only these two values are used in digital electronics because they resemble binary numbers.1 - +5V , 0 - 0V.
Analog pinsThe analog pins are named as A0-A5. These pins can be used to get an analog input. Analog means the voltage can be any value between and may not be just 0V or +5V.
The reset buttonThere is a button on the corner of the borad . It is a reset button. Whenever we press this button , all the instructions feeded inside the board run from the very beginning.
Power pins3.3V- This pin gives an output of 3.3 V.5V - This pin gives an output of 5V.GND- This pin gives an output of 0V.Vin- This pin is used to power the borad.
How do we power the board?The board can be powered with a battery orAny other source having a voltage between 7-12 V. Different ways are- 1.Vin pin2.Black coloured jack
Normally when connected to a computer, the board is powered by the USB port of the computer.
Did you know?The USB port on your computer provides a constant voltage of +5V. This power is used by external cooling fans for laptops or computer or even to power any USB device.
Why do we use Arduino ?1: Cheap circuit board2: Easy to use3: Multiple sensors and devices supported4: Open source project 5: Online support
Where do we use it ?1.Make small playful projects.2.Make small robots.3.Implement some solution of a real life problem
4.Make projects related to IOT - Internet Of Things Video
How do we code the board ?The Arduino IDE - the software on which wecode.What is this code? C /C++ - the language on which we code
IMportant information1: GND= 0V2:The language used to write the code here is case sensitive. So, please write the code as shown to you. Don’t even miss a “;” or a “()” or”{ }”.
Glow the on-board LED:There is an on-board LED near the mark L.We can switch on/off this LED via a code.
Let’s try to do some interesting things
Instructions:1: Connect the wire to the arduino board.2: Connect the USB to the USB port.3: Open the Arduino software.
Blink1: Go to File->Examples->Basics->Blink.
Functions usedThere are two parts in our code that are enclosed in { }.These are called functions. Each function has a set of instructions.
Void Setup() - This function is used to set up the initial conditions on the board. In this code we use a command called “pinMode” .This command tells the board the about the mode in which we want to use the pin. The mode is specified as shown - OUTPUT. This means the pin 13 on the board is going to give output of 0V or 5V as it is a digital pin.
Void Loop() - This function runs on repeatedly once the program starts. After the setup gives the instructions about pin-modes, the instructions written inside the loop are ran continuously for infinite time until you switch OFF power.
How to switch the LED on?The LED is a device that works when the longer end is connected to high voltage and shorter leg to low voltage. The on- board LED has it’s longer leg connected to digital pin 13 and shorter leg to GND=0V.
So, when we give output as 5V on pin 13, the LED glows while when we give 0V the LED is OFF.
Digitalwrite commandThis command is used to give output to a pin. The command “digitalWrite(13,HIGH);”means give an output of +5V on the pin 13.Here 5V=HIGH and 0V=LOW.
Once you make the Arduino pin HIGH or LOW the output voltage does not change until you change it by a command. So, the output on pin 13 will be HIGH until we change it to LOW or HIGH again.
Delay commandThe delay command is used to stop the reading of instructions for a given amount of time. The command “delay(1000)” means the code stops for 1000 millisecond or 1 second and then moves on.
1:Write the given code.2: Go to Tools->Board ( Arduino/Genuino UNO)3: Go to Tools->Port-> (whichever port is shown).4: Click on the to upload the code to board.
LED - change the delay time1: Change the blink time - delay() function.2: The given time is in Milliseconds3: Upload to board
Let us program Different led1: Plug in the Longer leg of the LED in Digital pin 2 and shorter leg in digital pin 3.2: Copy the program as shown.3: Upload to board.
Using multiple LEds1: Connect longer legs of LEDs to digital pins 2, 4 and 6 and shorter legs to 3,5 and 7.2: Copy the code as shown.3: Upload.