Lecture 4: Basic Electronics. Lecture 4 Brief Introduction to Electronics and the Arduino

Similar documents
Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

DASL 120 Introduction to Microcontrollers

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Blink. EE 285 Arduino 1

THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS.

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

Embedded Controls Final Project. Tom Hall EE /07/2011

TV Remote. Discover Engineering. Youth Handouts

FABO ACADEMY X ELECTRONIC DESIGN

Rodni What will yours be?

MAKEVMA502 BASIC DIY KIT WITH ATMEGA2560 FOR ARDUINO USER MANUAL

Lab 2: Blinkie Lab. Objectives. Materials. Theory

INA169 Breakout Board Hookup Guide

The Motor sketch. One Direction ON-OFF DC Motor

Coding with Arduino to operate the prosthetic arm

Arduino An Introduction

Module: Arduino as Signal Generator

Objective of the lesson

Data Conversion and Lab Lab 1 Fall Operational Amplifiers

Figure 1. Digilent DC Motor

1. Introduction to Analog I/O

DFRduino Romeo All in one Controller V1.1(SKU:DFR0004)

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

Lesson 3: Arduino. Goals

Breadboard Arduino Compatible Assembly Guide

Data Conversion and Lab Lab 4 Fall Digital to Analog Conversions

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

USER MANUAL SERIAL IR SENSOR ARRAY5

Lab 06: Ohm s Law and Servo Motor Control

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Assignments from last week

Lecture 6. Interfacing Digital and Analog Devices to Arduino. Intro to Arduino

USER MANUAL FOR THE LM2901 QUAD VOLTAGE COMPARATOR FUNCTIONAL MODULE

Sidekick Basic Kit for Arduino V2 Introduction

Internet of Things Student STEM Project Jackson High School. Lesson 3: Arduino Solar Tracker

Touch Potentiometer Hookup Guide

Breadboard Primer. Experience. Objective. No previous electronics experience is required.

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

Programmable Control Introduction

Lab 2.4 Arduinos, Resistors, and Circuits

Arduino Digital Out_QUICK RECAP

Preface. If you have any problems for learning, please contact us at We will do our best to help you solve the problem.

Basics before Migtrating to Arduino

LED + Servo 2 devices, 1 Arduino

Arduino

Exam Practice Problems (3 Point Questions)

128 KB (128K 1 = 128K

12V Dimmer Kit, version 2

1Getting Started SIK BINDER //3

LEDs and Sensors Part 2: Analog to Digital

Servo Sweep. Learn to make a regular Servo move in a sweeping motion.

.:Twisting:..:Potentiometers:.

Microcontrollers and Interfacing

Bill of Materials: PWM Stepper Motor Driver PART NO

Motors and Servos Part 2: DC Motors

PART 1: DESCRIPTION OF THE DIGITAL CONTROL SYSTEM

SPI, Talking to Chips, and Minimizing Noise

Arduino: Sensors for Fun and Non Profit

Vacuum Tubes. BJT or FET. Transistor Configurations. Depends on application Amplifiers

TWEAK THE ARDUINO LOGO

CMU232 User Manual Last Revised October 21, 2002

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

TECH 3232 Fall 2010 Lab #1 Into To Digital Circuits. To review basic logic gates and digital logic circuit construction and testing.

Written by Hans Summers Wednesday, 15 November :53 - Last Updated Wednesday, 15 November :07

POLOLU DUAL MC33926 MOTOR DRIVER FOR RASPBERRY PI (ASSEMBLED) USER S GUIDE

ENGN/PHYS 207 Fall 2018 Assignment #5 Final Report Due Date: 5pm Wed Oct 31, 2018

INSTANT ROBOT SHIELD (AXE408)

PWM CONTROL USING ARDUINO. Learn to Control DC Motor Speed and LED Brightness

introduction to Digital Electronics Install the Arduino IDE on your laptop if you haven t already!

PARAMETER CONDITION VALUE (TYPICAL) PVIN Power Input Voltage Range Operating 20V - 28V. VIN Pin Input Voltage Range Operating 8V - 14V

EE 308 Spring S12 SUBSYSTEMS: PULSE WIDTH MODULATION, A/D CONVERTER, AND SYNCHRONOUS SERIAN INTERFACE

Disclaimer. Arduino Hands-On 2 CS5968 / ART4455 9/1/10. ! Many of these slides are mine. ! But, some are stolen from various places on the web

Experiment # 2 The Voting Machine

Lab Exercise 6: Digital/Analog conversion

Electronics: Design and Build Training Session. Presented By: Dr. Shakti Singh Hazem Elgabra Amna Siddiqui

Programmable Timer Teaching Notes Issue 1.2

Motor Control Demonstration Lab

Arduino Programming Part 3

The ilab Experience. Smart Space Orchestration (s2o) Part I: Hardware Nov 29, you set the focus. a blended learning hands-on course concept

Digital Electronics & Chip Design

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Practice Homework Problems for Module 1

Arduino Intermediate Projects

Real Time Embedded Systems. Lecture 1 January 17, 2012

The answer is R= 471 ohms. So we can use a 470 ohm or the next higher one, a 560 ohm.

Lab 13: Microcontrollers II

Electronics. RC Filter, DC Supply, and 555


MICROPROCESSORS A (17.383) Fall Lecture Outline

Pulse Width Modulation and

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Application Note AN 102: Arduino I2C Interface to K 30 Sensor

Training Schedule. Robotic System Design using Arduino Platform

LAB PROJECT 2. Lab Exercise

Pololu DRV8835 Dual Motor Driver Kit for Raspberry Pi B+

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

CSCI1600 Lab 4: Sound

Transcription:

Lecture 4: Basic Electronics Lecture 4 Page: 1 Brief Introduction to Electronics and the Arduino colintan@nus.edu.sg

Lecture 4: Basic Electronics Page: 2 Objectives of this Lecture By the end of today s lecture you will be able to: Understand the use of resistors and other passive components in circuit design. Understand how to use a breadboard. Understand the Arduino Mega.

Lecture 4: Basic Electronics Page: 3 Power Supply Power supply is divided into Vcc (or Vin) and GND. Vcc is the positive side of the supply, and on TTL (transistor-transistor logic) devices like the Arduino, is usually 5 volts. GND is ground, the negative side of the circuit.

Lecture 4: Basic Electronics Page: 4 Resistors A resister is a passive component (does not significantly alter the properties of a signal) that is used to reduce current. The symbol for a resistor is shown below:

Lecture 4: Basic Electronics Page: 5 Resistors Resistance is measured in ohms. You can read the value of a particular resistor by looking at the colored stripes on its body:

Lecture 4: Basic Electronics Page: 6 Resistors Example: We have a resistor with green, blue and brown stripes on its body: Green: 5 Blue: 6 Brown: 1 zero. Total -> 560 ohms Another resistor as brown, black and orange stripes. Brown: 1 Black 0 Orange: 3 zeros. This is a 10000 ohm resistor, or 10 kilohms.

Lecture 4: Basic Electronics Page: 7 Resistors Resistors are used for: Limiting current through a system. This is to prevent damage to sensitive devices like lightemitting diodes (LEDs) and transistors. Dividing voltages. This is used to get a lower voltage from a higher voltage, e.g. to reduce 5v to 3.3v. Also used in transistor amplifiers to bias the base to reduce noise. Pulling up or down inputs.

Lecture 4: Basic Electronics Page: 8 Resistors Current Limiting The LEDs you are given can take a maximum of 20mA. If you exceed this current by too much, your LED will smoke and you will owe me a new LED. Our Arduino General Purpose Input/Output (GPIO) pins produce 5v. From ohm s law, V=RI, or R=V/I R = 5 / 0.02 = 250 ohms.

Lecture 4: Basic Electronics Page: 9 Resistors Real resistors are offered in a small set of values (see later). The closest is 270 ohms Your Arduino kit only has 330 ohms (orange-orange-brown) and 10 kilohms. Our final circuit looks like this:

Lecture 4: Basic Electronics Page: 10 Resistors Voltage Divider A voltage divider is used to step down a voltage source. We will use a circuit like this: The voltage Vout is given by:

Lecture 4: Basic Electronics Page: 11 Resistors Voltage Divider: E.g. we want to reduce a source voltage from 5v to 3.3v (very important for low-power electronics) We choose R2 to be 1k. We have 3.3 = [1/(1+R1)] * 5 R1=0.515k. Closest value is 510 ohms Our final output voltage is 5 * [1/(1+0.51)] = 3.31v.

Lecture 4: Basic Electronics Page: 12 Resistors Voltage divider circuits are also used for sensing light, when combined with a light dependent resistor.

Lecture 4: Basic Electronics Page: 13 Resistors Suppose an LDR s resistance is 10 ohms in bright light and 50000 ohms in the dark (very typical values). Suppose R2 is fixed at 330 ohms, input voltage is 5v. The output voltage Vout in the light would be 5 * (330 / 340) = 4.85v The output voltage Vout in the dark would be 5 * (330/50330) =0.03v. The Analog-Digital Converters (ADC) on the Arduino are able to sense this difference in voltages.

Lecture 4: Basic Electronics Page: 14 Resistors Circuit inputs should never be left hanging. We must always weakly pull them up to 5V or drop them to 0V. We use pull-up and pull-down resistors for this. We always use relatively large resistors like 10k so that the current is low.

Lecture 4: Basic Electronics Page: 15 Resistors

Lecture 4: Basic Electronics Page: 16 Resistors Common Resistor Values The Arduino kit comes with 330 ohm and 10k ohm resistors.

Lecture 4: Basic Electronics Page: 17 Light Emitting Diodes Similar to small bulbs, but much more energy efficient. The LEDs you are given have a maximum safe current load of 20 ma. If you put more than 20 ma the magic smoke will escape (more on this later). Always use a current limiting resistor! Two legs: Longer leg -> Positive terminal. Shorter leg -> Connect to GND.

Lecture 4: Basic Electronics Page: 18 Potentiometer A potentiometer functions like an adjustable voltage divider. Turn the dial to adjust the output voltage. Has 3 legs: First and third leg connect to VCC and GND (Polarity not important). Second leg is the output voltage.

Lecture 4: Basic Electronics Page: 19 The Breadboard You are provided with a breadboard:

Lecture 4: Basic Electronics Page: 20 The Breadboard A breadboard s holes are internally connected in very particular ways:

Lecture 4: Basic Electronics Page: 21 The Breadboard This means that you must connect your components carefully to prevent short circuits:

Lecture 4: Basic Electronics Page: 22 The Breadboard

Lecture 4: Basic Electronics Page: 23 The Breadboard Connecting resistors correctly:

Lecture 4: Basic Electronics Page: 24 The Breadboard The top two rows are used for power supply. Conventionally the top row is for Vcc and bottom is for GND.

Lecture 4: Basic Electronics Page: 25 The Breadboard

Lecture 4: Basic Electronics Page: 26 Wire Color Codes You should ALWAYS color code your wires: Use BLACK wires for GND. Use RED wires for VCC. ALWAYS use the same colors for the same function. E.g.: Blue for input, brown for output. Yellow for TX, green for RX. Etc. Color-coding makes it easier to debug your circuit.

Lecture 4: Basic Electronics Page: 27 The Arduino Mega You are also issued with an Arduino Mega board:

Lecture 4: Basic Electronics Page: 28 The Arduino Mega The Arduino Mega is based on the Atmega 2560 microcontroller chip. 256KB of flash memory. 4KB of EEPROM. Good for storing data permanently. Will be damaged if written to too often. 8KB of RAM 16 MHz clock.

Lecture 4: Basic Electronics Page: 29 The Arduino Mega The pins labelled 1 to 53 are General Purpose Input/Output pins. These are 5v TTL pins. GPIO commands: pinmode Sets a pin to be input or output. digitalread Read the pin. You will get 1 if there is a 5V input to the pin, 0 if 0V. digitalwrite Write to the pin. If you write a HIGH, the pin will be driven to 5v. If you write a LOW, the pin will be driven to 0v.

Lecture 4: Basic Electronics Page: 30 The Arduino Mega

Lecture 4: Basic Electronics Page: 31 The Arduino Mega

Lecture 4: Basic Electronics Page: 32 Example #define inputpin 10 #define outputpin 13 void setup() { pinmode(10, INPUT); pinmode(13, OUTPUT); } void loop() { unsigned int flag; flag=digitalread(10); if(flag) digitalwrite(13, HIGH); else digitalwrite(13, LOW); } int main() { setup(); while(1) loop(); return 0; }

Lecture 4: Basic Electronics Page: 33 Handling Analog Data Digital input and output is simple: Either ON or OFF. Analog input and output is more complex: Temperature reading of 23.12C People of heights 1.62m, 1.76m, 1.83m, etc. Key issues with analog input: Infinite set of possible values. E.g. Current temperature is 24C, or 23.9C, or 23.91C, or 23.912C, or 23.9119C, or 23.91194C, or 23.911943C, or.

Lecture 4: Basic Electronics Page: 34 Handling Analog Data The pins labelled A0 to A15 are for analog inputs, pins 1 to 13 marked PWM are analog outputs.

Lecture 4: Basic Electronics Page: 35 Handling Analog Data

Lecture 4: Basic Electronics Page: 36 Power Supply The power supply pins supply 5 volts, 3.3 volts and GND. Vin is for supplying power to the Arduino. Maximum current draw of 200mA. Do not exceed this.

Lecture 4: Basic Electronics Page: 37 Analog Programming on Arduino #define inputpin 0 #define outputpin 5 // Remaps from 0-1023 to 0-255 int remap(int val) { return (int)(val * 255.0 / 1023.0); } int main() { while(1) { // Note: ADC returns values // from 0 to 1023, while // analogwrite accepts // values from 0 to 255. int val=analogread(inputpin); int outval=remap(val); analogwrite(outputpin, outval); } // while(1) return 0; }

Lecture 4: Basic Electronics Page: 38 Serial Programming There are four serial interfaces on the Mega, marked TX, RX, TX1, RX1, TX2, RX2, TX3, RX3.

Lecture 4: Basic Electronics Page: 39 Serial Programming Serial ports are accessed using the Serial, Serial1, Serial2, Serial3 static objects. Serial.begin(baudrate) Serial.write(ch) ch = Serial.read(); String str=serial.readstring() Serial.available() Serial.print/Serial.println Serial.setTimeout(timeoutInMS)

Lecture 4: Basic Electronics Page: 40 Serial Programming