Welcome to Arduino workshop
Microcontrollers The microcontroller is a computer-on-chip. It is an integrated circuit that contains microprocessor, memory, I/O ports and sometimes A/D converters. It can be programmed using several languages (such as Assembly or C/C++). It can be used in manufacturing lines, but requires additional hardware. Microcontrollers are mainly used in engineering products such as washing machines and air-conditioners.
Microcontrollers Companies
What is Arduino? An open-source hardware and software platform for building electronics projects A physical programmable circuit board (often referred to as a microcontroller) A piece of software, or IDE (Integrated Development Environment) that runs on your computer, used to write and upload computer code to the physical board (supports Mac/Windows/Linux)
Arduino Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. The hardware consists of a simple open source hardware board designed around an 8-bit Atmel AVR microcontroller, though a new model has been designed around a 32-bit Atmel ARM
Different flavours!!! There are many versions of Arduino board.versions differ by size,microcontroller,etc
9
- You need an adapter with a 2. 1 mm barrel tip and a positive center - You need an adapter with a 2.1 mm barrel tip and a positive center. - Please note that older versions of the Arduino board (Arduino-NG and Diecimila) don’t switch automatically between an external power supply and a USB supply. - Supplying 9 volts (the recommended range is 7V to 12V).
ARDUINO http://ardumap.everpi.net
Concepts: INPUT vs. OUTPUT 20 Concepts: INPUT vs. OUTPUT Inputs is a signal / information going into the board. Output is any signal exiting the board. Almost all systems that use physical computing will have some form of output What are some examples of Outputs?
Concepts: INPUT vs. OUTPUT 21 Concepts: INPUT vs. OUTPUT Referenced from the perspective of the microcontroller (electrical board). Inputs is a signal / information going into the board. Output is any signal exiting the board. Examples: Buttons Switches, Light Sensors, Flex Sensors, Humidity Sensors, Temperature Sensors… Examples: LEDs, DC motor, servo motor, a piezo buzzer, relay, an RGB LED
Concepts: Analog vs. Digital Microcontrollers are digital devices – ON or OFF. Also called – discrete. analog signals are anything that can be a full range of values. What are some examples? More on this later… 5 V 0 V
Digital and analog. Digital or Analog? All physical quantities are analog. Analog means that the quantity can take any value between its minimum value and maximum value. Digital means that the quantity can take specific levels of values with specific offset between each other. Ex: 1- Digital: English alpha consists of 26 letter, there is no letter between A and B. - Square waves are Digital. Ex.: 2- Analog: Temperature, can take any value[-1,12.8,25.002,… etc.]. - Sine waves are analog. Digital and analog. 23
- 14 Digital IO pins (pins 0–13): These can be inputs or outputs, which is specified by the sketch you create in the IDE. - 6 Analogue In pins (pins 0–5): These dedicated analogue input pins take analogue values (i.e., voltage readings from a sensor) and convert them into a number between 0 and 1023. - 6 Analogue Out pins (pins 3, 5, 6, 9, 10, and 11): These are actually six of the digital pins that can be reprogrammed for analogue output using the sketch you create in the IDE.
Basic I/O - Digital Writes
Digital Write – Key Concepts pinMode(): Configures the specified pin to behave either as an input or an output Syntax: pinMode(pin, mode) Example: pinMode(13, OUTPUT) set pin 13 to output mode Example: pinMode(13, INPUT) set pin 13 to input mode digitalWrite(): Write a HIGH or a LOW value to a digital pin If set to OUTPUT with pinMode(), 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. Syntax: digitalWrite(pin, value) Example 1: digitalWrite(13, HIGH) is 5 volts to pin 13 Example 2: digitalWrite(13, LOW) is 0 volts to pin 13
Action Round #1– Blink LED Project Name: Blink LED (Instructor Lead) Goal: Turns LED on for one second, then off for one second, repeatedly Software pinMode() digitalWrite() delay() Hardware 5mm LED (1) 220 Ohm Resister (1) Arduino Uno (1) Breadboard Jumper Wires
Breadboard Layout Connected dots represent connectivity
LED BASIC How to tell between anode and cathode? Features: A basic 5mm LED with a red lens. 1.8-2.2VDC forward drop Max current: 20mA Suggested using current: 16-18mA Luminous Intensity: 150-200mcd Safety Tips: Must use a pull-up resister to connect to 5V source! Math: (5V-1.8V)/16mA = 200 ohm Pick: 220 ohm resister
Action Round #1– Blink LED Software /* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int led = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW Hardware Connect Arduino Vcc and GND to breadboard power rails Put in a LED on breadboard D13> 220 Ohm resister -> LED -> GND
Digital Design Using your own circuit design and Arduino sketch, design a solution that solves the following challenges. Challenge 1a: Add a Second LED to the circuit and make them Blink together. Challenge 1b: Then make them Blink alternating on and off.
Digital Design Software /* Blink two LEDs together Modified by Matt Royer May 5, 2014 */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int led1 = 13; int led2 = 12; // Additional LED Pin // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); // Additional LED Pinmode } // the loop routine runs over and over again forever: void loop() { digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW Challenge 1a: Add a Second LED to the circuit and make them Blink together
Digital Design Challenge 1b: Make them Blink Alternating on and off. Software /* Blink two LEDs together Modified by Matt Royer May 5, 2014 */ // Pin 13 has an LED connected on most Arduino boards. // give it a name: int led1 = 13; int led2 = 12; // Additional LED Pin // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); // Additional LED Pinmode } // the loop routine runs over and over again forever: void loop() { digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(led2, LOW); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW digitalWrite(led2, HIGH); // turn the LED off by making the voltage LOW
Control structures while Syntax: while(expression){ // statement(s) } Example: var = 0; while (var < 200) { // do something repetitive 200 times var++; }
Control structures If if else, if else if, else Syntax: if (boolean condition) { //statement(s); } if else, if else if, else Syntax: if (condition1) { // do Thing A } else if (condition2) { // do Thing B … }else { // do Thing C
Control structures switch case Syntax: switch (var) { case label: // statements break; default: } Example: switch (var) { case 1: //do something when var equals 1 break; case 2: //do something when var equals 2 Default: // if nothing else matches, do the default // default is optional }
Try adding other LEDs
Arrays Create an Array Syntax: int myInts[6]; int myPins[] = {2, 4, 8, 3, 6, 1}; int mySensVals[6] = {2, 4, -8, 3, 2, 0}; char message[6] = "hello!"; Access an Array Array index starts from 0. int myArray[10]={9,3,2,4,3,2,7,8,9,11}; // myArray[9] contains 11 // myArray[10] is invalid and contains random information (other memory address) To assign a value to an array mySensVals[0] = 10; To retrieve a value from an array: x = mySensVals[4];
Arrays and for-loop Arrays are often manipulated inside for loops, where the loop counter is used as the index for each array element. For example, to print the elements of an array over the serial port, you could do something like this: Example: int i; int myPins[3] = {0,1,2}; for (i = 0; i < 3; i = i + 1) { digitalWrite(myPins[i], HIGH); delay(2000); //delay for 2 seconds }
Action Round #2: 3 LEDs blink in series and repeat. Goal: take turn You’ll be using: for loop, array, delay() Software pinMode() digitalWrite() array [ ] for loop delay() Hardware 5mm LED (3) 220 Ohm Resister (3) Arduino Uno (1) Breadboard Jumper Wires
Action Round #2: 3 LEDs blink in series and repeat. Software /* Blink Cycle through Array list of LEDs. For each LED in Array turns it on for 1 second. Modified by Matt Royer May 5, 2014 */ const int numberOfLED = 3; // Number of LED in Array const int lEDToBlink[numberOfLED] = { // Array to store LED Pins 13, 12, 11 }; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output // For each LED in Array, initialize for (int initalizeLED = 0; initalizeLED < numberOfLED; initalizeLED++){ pinMode(lEDToBlink[initalizeLED], OUTPUT); } } // the loop routine runs over and over again forever: void loop() { for (int lightLED = 0; lightLED < numberOfLED; lightLED++){ // For each LED in Array, Blink digitalWrite(lEDToBlink[lightLED], HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); digitalWrite(lEDToBlink[lightLED], LOW); // turn the LED on (HIGH is the voltage level) }
Programming Concepts: Variables Variable Scope Global --- Function-level
Programming Concepts: Variable Types 8 bits 16 bits 32 bits byte char int unsigned int long unsigned long float
Basic I/O - Analog Writes
Analog Write PWM pins ONLY 8 bit resolution (GPIO) pins
Pulse Width Modulation In Summary: PWM is a technique for getting analog results with digital means. To be exact, a signal is switched between on and off to create a square wave, by controlling the percentage of time the signal is on (duty cycle), we simulate “a steady analog source” which can be considered as “ the digital average”. Vanalog = Vdigital * DutyCycle The table shows relation between PWM duty cycle and simulated analog voltage, assume Vdigital = 5V 0V 1.25V 2.5V 3.75V 5V
Pulse Width Modulation How to use in Arduino ? Identify the pins: PWM is supported on Pin 3, 5, 6, 9, 10, 11 , with a “~” Modulate pulse width by calling analogWrite() analogWrite ranges from 0 -255, with 0 being 0% duty cycle, 255 being 100% For example, 50% duty cycle is 255*50% = 127, analogWrite(PIN, 127) makes the analog output looks like it’s connected to a steady 2.5V source Provide 8/12bit PWM output with the analogWrite() function. The resolution of the PWM can be changed with the analogWriteResolution() function.
Analog Write – Key Concepts Arduino Default PWM is 8 bit void Setup() pinMode(): Configures the specified pin to behave either as an input or an output Example: pinMode(11, OUTPUT) void loop() analogWrite(): Writes an analog value (Pulse Width Modulation wave) to a pin. Example: analogWrite (11, 64) Q: What’s the Duty Cycle does 64 represent, suppose PWM precision is 8 bit ? Hint: the max number can be represented by 8 bit is
Action Round#1 – Fading LED using analog Write Goal: Change the brightness of an LED using PWM to make it appear to fade in and out by itself You will be using: Analog Write and Serial Monitor Software analogWrite() pinMode() Hardware 5mm LED (1) 220 Ohm Resister (1) Breadboard Jumper Wires
Basic I/O - Serial Writes
Refresher: Arduino Serial Interfaces Used for communication between the Arduino board and a computer or other devices. Arduino platforms have at least one serial port (also known as a UART or Universal Asynchronous Receiver/Transmitter) Serial Communicates through digital pins 0 (RX) & 1 (TX) and via USB to Computer for Sketches
Serial Write – Key Concepts Serial.begin(): Sets the data rate in bits per second (baud) for serial data transmission Syntax: Serial.begin(baud) Example: Serial.begin(9600) sets serial baud rate to 9600 bits per second Serial.print(): Prints data to the serial port as human-readable ASCII text without carriage return / Newline Feed character Syntax: Serial.print(val) or Serial.print(val, format) Parameters: val: the value to print - any data type format: specifies the number base or number of decimal places Example: Serial.print(”Hello world.“) gives "Hello world.“ Example: Serial.print(1.23456, 2) gives “1.23”
Serial Write – Key Concepts Serial.println(): Prints data to the serial port as human-readable ASCII text followed by a carriage return and a newline character Syntax: Serial.println(val) or Serial.print(val, format) Parameters: val: the value to print - any data type format: specifies the number base or number of decimal places Example: Serial.println(”Hello world.“) gives "Hello world.“ Example: Serial.println(1.23456, 2) gives “1.23” Serial.write(): Writes binary data to the serial port. This data is sent as a byte or series of bytes Syntax: Serial.write(val) Example: Serial.wrtie(”Hello world“) writes "Hello world“
OR Bring up Serial Monitor Select “Tools” -> “Serial Monitor” or click Serial Monitor Icon Note: Sketch must be loaded first; else, Serial Monitor will close on Sketch upload OR
Basic I/O - Digital Reads
Digital Read – Key Concepts Reminder pinMode(): Configures the specified pin to behave either as an input or an output Syntax: pinMode(pin, mode) Example: pinMode(2, OUTPUT) set pin 2 to output mode Example: pinMode(2, INPUT) set pin 2 to input mode digitalRead(): Reads the value from a specified digital pin, either HIGH or LOW Syntax: pinMode(pin) Example 1: digitalRead(2) reads High or Low from pin 2
Action Round#1: Digital Read from push button Project Name: LED Button Press(Instructor Lead) Goal: Illuminate LED when push button is being pressed Software pinMode() digitalWrite() digitalRead() if / else Hardware 5mm LED (1) Momentary Switch/push button (1) 220 Ohm Resister (1) 10k Ohm Resister (1) Arduino (1) Breadboard Jumper Wires
* Other names and brands may be claimed as the property of others Action Round#1: Digital Read from push button Hardware Connect power rails to breadboard D13>220 ohm->anode->cathode->GND Vcc->10k ohm-> pushbutton->GND D2->pushbutton and resistor junction point Software // constants won't change. They're used here to // set pin numbers: const int buttonPin = 7; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } * Other names and brands may be claimed as the property of others
Goal: when button is pressed, blink LED continuously Action Round #2: Blink LED continuously while button is pressed Goal: when button is pressed, blink LED continuously You’ll be using: if , delay() Software pinMode() digitalWrite() if delay() Hardware 5mm LED (1) Momentary Switch/push button (1) 220 Ohm Resister (1) 10k Ohm Resister (1) Intel Galileo Board (1) Breadboard Jumper Wires
* Other names and brands may be claimed as the property of others Action Round #3: Blink LED continuously while button is pressed Hardware Connect power rails to breadboard D13>220 ohm->anode->cathode->GND Vcc->10k ohm-> pushbutton->GND D2->pushbutton and resistor junction point Software // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); delay(500); digitalWrite(ledPin, LOW); } digitalWrite(ledPin, LOW); * Other names and brands may be claimed as the property of others
Action Round #3: Press button to turn on and off LED Goal: when button is pressed and released first time, turn on LED; and the second time, turn off LED; and continues turning on and off LED with each press and release of button Software pinMode() digitalWrite() digitalRead() If boolean variable boolean operation (!) delay() Hardware 5mm LED (1) Momentary Switch/push button (1) 220 Ohm Resister (1) 10k Ohm Resister (1) Intel Galileo Board (1) Breadboard Jumper Wires
* Other names and brands may be claimed as the property of others Action Round #3: Blink LED continuously while button is pressed Software const int buttonPin = 2; // the number of the pushbutton const int ledPin = 13; boolean ledState = false; boolean buttondown = false; // variables will change: void setup() { // initialize the relay pin as an output: pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop(){ //get the button State by using digitalRead buttondown = digitalRead(pushbutton); if(buttondown){ //invert the ledState if button is pressed ledState = !ledState; //Write inverted state to LED digitalWrite(ledPin, ledState); delay(200); //delay is necessary to stabilize the processing, not allowing immediate input from pushbutton * Other names and brands may be claimed as the property of others
Basic I/O Analog Read
Analog signals . Analog signal is any continuous signal Vs. time! digital signal uses discrete (discontinuous) values .
Analog Read – Board Hardware
10 bit resolution . (GPIO) pins . 100 µs (0.0001 s) to read an analog input . reading rate = 10,000 /s
Analog sensors LDR Potentiometer LM35
Analog Read – Key Concepts analogRead(): Reads the value from the specified analog pin. Syntax: analogRead(pin) Example: analogRead(A0) reads analog value of pin A0
Action- Round #1 Read Value from potentiometer Goal: Read the voltage adjusted by potentiometer and print out on Serial Monitor You will be using: Analog Read and Serial Monitor Hardware Potentiometer(1) Breadboard Jumper Wires Software analogRead() Serial.println()
Action- Round #1 Read Value from potentiometer Hardware Connect Galileo Vcc and GND to breadboard power rails Put in a potentiometer(POT) on breadboard Connect POT middle pin to A0 Connect POT other two pins to Vcc, GND on breadboard respectively Software void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); // delay in between reads for stability delay(500); Intel Confidential test 2
Action- Round #1 Read Value from potentiometer Observation What is the range of potentiometer output? Why is it represented in numbers rather than actual voltage?
Data Types — Floating point Syntax: A. float var = val; B. (float) var -- type casting Example: A. float x= 1.25; B. int x; int y; float z; x = 1; y = x / 2; // y now contains 0, int can't hold fractions z = (float)x / 2.0; // z now contains 0.5 (you have to use 2.0, not 2)
Action- Round #3 Read Value from POT and convert it to true floating point value Hint: The range of POT voltage output is 0 to 5V Define a floating point variable, ex. float vPOT; vPOT = sensorValue/sensorFullRange * 5.0 Don’t forget the type casting! void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); // delay in between reads for stability delay(500); Arduino Examples: Basic->ReadAnalogVoltage Intel Confidential test 2
Action Round#4 Calibration – Calibrating analog input to fit digital range Goal: Given an analog input source whose range is unknown, map the range to the digital representation at initial setup time You will be using: millis(), map(), Analog Read, Serial Monitor Software analogWrite() pinMode() Hardware 5mm LED (2) 220 Ohm Resister (2) Potentiometer Breadboard Jumper Wires
Action Round#3 Calibration – Calibrating analog input to fit digital range Software First run the code -> File->Example-> Analog->Calibration Add Serial Print to monitor Print out the Sensor Min value and Sensor Max value to see how it changes as flex sensor is being bent. Serial.begin(9600); Serial.print("Calibration time sensorMin = "); Serial.println(sensorMin); Serial.print("Calibration time sensorMax = "); Serial.println(sensorMax); Making the Calibration time longer and add delay function if necessary to better observe in Serial Monitor. while (millis() < 10000) { … delay(100); } Intel Confidential test 2
Map() function map(): Re-maps a number from one range to another. Value can be mapped to values that are out of range. Syntax: map(Source, fromLow, fromHigh, toLow, toHigh) Example: map(val, 0, 1023, 0, 255) Useful for dealing with different precisions/representations, 5V is represented as 1023 previously, now as 255. For example: Arduino Default analog read (ADC) is 10bit precision, 5V = 1023 Arduino Default PWM is 8bit precision, 5V = 255 Use map() to adapt one range to the other
Constrain() function Constrains a number to be within a range. Syntax: constrain(x, a, b) Returns: x: if x is between a and b a: if x is less than a b: if x is greater than b Example: sensVal = constrain(sensVal, 10, 150); // limits range of sensor values to between 10 and 150
Action Round #4 – Read and Serial Print Map Value Software const int analogInPin = A0; // Analog input pin that the potentiometer is attached to //const int analogOutPin = 11; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: // analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); // wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(200);
LDR Light Dependent Resistor
يجب توصيل مقاومة مع الحساس لعمل voltage divider ... لنتمكن من قياس تغير الجهد على الحساس !
Schematic Diagram
LM35 The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly-proportional to the Centigrade temperature. Features Calibrated Directly in Celsius (Centigrade) Linear + 10-mV/°C Scale Factor 0.5°C Ensured Accuracy (at 25°C) Rated for Full −55°C to 150°C Range Suitable for Remote Applications Low-Cost Due to Wafer-Level Trimming Operates from 4 V to 30 V Less than 60-μA Current Drain Low Self-Heating, 0.08°C in Still Air Non-Linearity Only ±¼°C Typical Low-Impedance Output, 0.1 Ω for 1-mA Load
Analogue or Digital ?! ^_^ ) /1024.0
Enough with LED, Let’s play with motors! DC motors Direct Current controlled motor, using two wires to connect to Power and Ground Servo motors A servomotor is a rotary actuator that allows for precise control of angular position, velocity and acceleration. 0-180 degrees Arduino Example: Basic-> Fade Intel Confidential test 2
DC Motor The most common actuator in mobile robotics is the direct current (DC) motor Advantages: simple, cheap, various sizes and packages, easy to interface, clean. DC motors convert electrical into mechanical energy.
DC Motor DC motors consist of permanent magnets with loops of wire inside When current is applied, the wire loops generate a magnetic field, which reacts against the outside field of the static magnets The interaction of the fields produces the movement of the shaft/armature A commutator switches the direction of the current flow, yielding continuous motion
Problem !!!! Motors need at least 200mA to start on ! >_< How could I do this from arduino ?! ^_^
Transistors
Transistor History Invention: 1947,at Bell Laboratories. John Bardeen, Walter Brattain, and William Schockly developed the first model of transistor (a Three Points transistor, made with Germanium) They received Nobel Prize in Physics in 1956 "for their researches on semiconductors and their discovery of the transistor effect" First application: replacing vacuum tubes (big & inefficient). Today: millions of Transistors are built on a single silicon wafer in most common electronic devices First model of Transistor
What is a transistor ? The Transistor is a three-terminal, semiconductor device. It’s possible to control electric current or voltage between two of the terminals (by applying an electric current or voltage to the third terminal). The transistor is an active component. With the Transistor we can make amplification devices or electric switch. Configuration of circuit determines whether the transistor will work as switch or amplifier As a miniature electronic switch, it has two operating positions: on and off. This switching capability allows binary functionality and permits to process information in a microprocessor.
Bipolar Junction Transistors (BJT’s) The term bipolar refers to the use of both holes and electrons as charge carriers in the transistor structure There are two types of BJTs, the NPN and PNP
Transistor symbols Transistor symbols
Transistor operation force – voltage/current water flow – current - amplification
Connection Why we need the diode ?!
Connection on breadboard
Speed of the Motor ?!
PWM
What about Direction ?!
H-Bridge
H-Bridge
IC ( L293B )
Connections
Servo Motor It is sometimes necessary to move a motor to a specific position DC motors are not built for this purpose, but servo motors are Servo motors are adapted DC motors: gear reduction position sensor (potentiometer) electronic controller Range of at least 180 degrees
Servo Motor Continuous Standard
Servo Motor
#include <Servo.h> Servo Library #include <Servo.h> Servo myservo ; myservo.attach(9); myservo.write(pos);
Ultrasonic Sensor An ultrasonic transducer is a device that converts energy into ultrasound, or sound waves above the normal range of human hearing. Systems typically use a transducer which generates sound waves in the ultrasonic range, above 18,000 hertz, by turning electrical energy into sound, then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed.
Ultrasonic sensors (also known as transceivers when they both send and receive) work on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object.
Interfacing & Features description: ultrasonic transducer - receiver max. input voltage: 20Vrms operating temperature: -20°C to +85°C range: 0.04 to 4m nominal frequency: 40kHz sensitivity: -67dB min. sound pressure: 112dB min.
Ultrasonic
Ultrasonic
Applications
Ultrasonic Library #include "Ultrasonic.h“ Ultrasonic ultrasonic(TRIGGER_PIN ,ECHO_PIN); ultrasonic.Ranging(CM);