Arduino 101 Part 2. So far we have begun to get

Similar documents
Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

DC Circuits (Combination of resistances)

Lab 3 - DC Circuits and Ohm s Law

Basic Pulse Width Modulation

Introduction to Arduino

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

GLOLAB Universal Telephone Hold

Arduino Lesson 14. Servo Motors

SYSTEM 4C. C R H Electronics Design

Arduino Lesson 13. DC Motors. Created by Simon Monk

ECEN 1400, Introduction to Analog and Digital Electronics

WHO ANSWERED FIRST? FIND OUT WITH THIS QUIZ BUZZER KIT

Using Ohm s Law to Build a Voltage Divider

Electronics and Soldering Notes

Measuring Electric Phenomena: the Ammeter and Voltmeter

Solar Energy Discovery Lab

Lab E1: Introduction to Circuits

Arduino Microcontroller Guide W. Durfee, University of Minnesota ver. oct-2011 Available on-line at

Lab 2: Resistance, Current, and Voltage

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Renewable Energy Monitor User Manual And Software Reference Guide. (979)

POINTS POSITION INDICATOR PPI4

LocoNet, the Digitrax Difference

Arduino Lesson 0. Getting Started

TEACHING RESOURCES SCHEMES OF WORK DEVELOPING A SPECIFICATION COMPONENT FACTSHEETS HOW TO SOLDER GUIDE GET IN TUNE WITH THIS FM RADIO KIT. Version 2.

SYSTEM 45. C R H Electronics Design

Tristan s Guide to: Solving Parallel Circuits. Version: 1.0 Written in Written By: Tristan Miller Tristan@CatherineNorth.com

Arduino Lesson 16. Stepper Motors

BMD16N-SD. version 1.2

Electronics. Discrete assembly of an operational amplifier as a transistor circuit. LD Physics Leaflets P

How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Series and Parallel Resistive Circuits Physics Lab VIII

Using Ohm s Law to Build a Voltage Divider

DEPARTMENT OF ELECTRONICS ENGINEERING

4/Really Getting Started with Arduino

DET Practical Electronics (Intermediate 1)

LAB2 Resistors, Simple Resistive Circuits in Series and Parallel Objective:

step 1 Unpack the lunchbox And check whether you have got all the components~ If you have questions please contact us at: info@unitunlikely.

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

Arduino project. Arduino board. Serial transmission

Basic DC Motor Circuits. Living with the Lab Gerald Recktenwald Portland State University

Basic DC Motor Circuits

OHM S LAW AND RESISTANCE

Martin County Amateur Radio Association. Nightfire Kits 1 LED Torch Kit Contents. Description

Glolab Talking Phone Dial Monitor

GROUND DETECTION CIRCUITS FOR STATIONARY APPLICATIONS (IN PLAIN DOWN TO EARTH LANGUAGE)

Servo Info and Centering

Physics 3330 Experiment #2 Fall DC techniques, dividers, and bridges R 2 =(1-S)R P R 1 =SR P. R P =10kΩ 10-turn pot.

Inductors. AC Theory. Module 3

IR Communication a learn.sparkfun.com tutorial

Experiment #5, Series and Parallel Circuits, Kirchhoff s Laws

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

Using and Wiring Light Emitting Diodes (LEDs) for Model Railroads

Tristan s Guide to: Solving Series Circuits. Version: 1.0 Written in Written By: Tristan Miller Tristan@CatherineNorth.com

The $25 Son of a cheap timer This is not suitable for a beginner. You must have soldering skills in order to build this kit.

Electronics 5: Arduino, PWM, Mosfetts and Motors

THE BREADBOARD; DC POWER SUPPLY; RESISTANCE OF METERS; NODE VOLTAGES AND EQUIVALENT RESISTANCE; THÉVENIN EQUIVALENT CIRCUIT

Building the AMP Amplifier

Capacitive Touch Sensor Project:

Odyssey of the Mind Technology Fair. Simple Electronics

8 Channel Status Input Panel model SIP-8

CONSTRUCTING A VARIABLE POWER SUPPLY UNIT

RGB for ZX Spectrum 128, +2, +2A, +3

Annex: VISIR Remote Laboratory

LM 358 Op Amp. If you have small signals and need a more useful reading we could amplify it using the op amp, this is commonly used in sensors.

Essential Electrical Concepts

GLOLAB Two Wire Stepper Motor Positioner

DMX-K-DRV. Integrated Step Motor Driver + (Basic Controller) Manual

Model SETR-50 and SETR-51 Trim Tab Control

Using the Motor Controller

!Operation:!1. Connect an external power source to J1 (+ and - IN terminals). The

TEECES DOME LIGHTING SYSTEMS

HOW TO USE MULTIMETER. COMPILE BY: Dzulautotech

PhidgetInterfaceKit 8/8/8

Tutorials Drawing a 555 timer circuit

Analog control unit for mobile robots

Mobile Device Power Monitor Battery Connection Quick Start Guide

What you will do. Build a 3-band equalizer. Connect to a music source (mp3 player) Low pass filter High pass filter Band pass filter

PolyBot Board. User's Guide V1.11 9/20/08

BURGLAR ALARM KIT MODEL K-23. Assembly and Instruction Manual ELENCO

How To Power A 12 Volt Relay On A Car Or Truck

Touch Screen for Pictiva OLED display. Application Note. Introduction

Robot Board Sub-System Testing. Abstract. Introduction and Theory. Equipment. Procedures. EE 101 Spring 2006 Date: Lab Section # Lab #6

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

AUTOMATIC CALL RECORDER JAMECO PART NO

Lecture - 4 Diode Rectifier Circuits

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

BUILDING INSTRUCTIONS

RADIANT PLASMA 4700 Plasma Spark Generator

Combi B Alarm box. Mounting instructions

Arduino Lesson 9. Sensing Light

Arduino Lesson 1. Blink

Experiment 4 ~ Resistors in Series & Parallel

The components. E3: Digital electronics. Goals:

MANUAL FOR RX700 LR and NR

Transcription:

Arduino 101 It's easy to connect many things to YourDuino. There are many pins for Ground and +V. The two pairs of pins on the right side are handy for connecting to your breadboard. Three-pin cables with the standard pattern of Ground- Voltage-Signal (usually Black-Red-White) plug right in. Arduino 101 Part by Terry King So far we have begun to get acquainted with the Arduino and IDE, the sketches or programs that make it work, and we have got it working blinking an LED on and off. In this article we will delve a little deeper preparatory to diving right in with a fully fledged project with some realworld applications in the next issue. We have set up a page on The Shed website to hold all the arduino sketches we are discussing here. You can simply copy and past them into your own IDE. To begin you need to understand a bit about electricity (see panel) and how that translates into the digital scheme of things. Circuit diagrams Often an actual circuit (like the YourDuino and Breadboard hookup) gets to be a confusing bunch of wires and components going in all directions. To keep it simple we draw Circuit Diagrams to show what we're trying to do. Notice the symbols used in the diagram above for things like: Switch, Resistor, LED and there are labels on connections, like, INPUT, OUTPUT, etc. Arduino is powered by +.0 Volts of DC (Direct Current).We show the +.0 Volts connected HIGH on the top. Look closely at the YourDuino find the PIN marked "V". That's the one +.0V power is connected to. Where does it come from? In the first place it comes from the USB cable from your computer to Arduino. There is provision for a dedicated power supply, however. We show (Ground) Switch Pulldown resistor V Arduino 1 connected LOW on the bottom of the Arduino. Find the Pin marked "". There are actually "" pins. Rails The parallel lines of +V (HIGH) on the diagram, and (LOW) on the diagram are called Rails. Like railroad rails across the top and bottom. Almost everything that happens on Arduino is between the +V (High) rail and the (Low) (0.0V) rail. HIGH Circuit diagram terminology. Some of the conventions used in circuit drawings. LED Current limiting Resistor LOW The Shed October/November 01

Digital signal You will hear Digital signals described three or four ways: but 0, OFF and LOW mean the same thing. And 1, ON and HIGH mean the same thing. When a Pin (or wire or connection) changes from 0 to 1, or 1 to 0, we say it is a SIGNAL, like someone raising or lowering a flag. Each signal is referred to as a BIT (a Binary InTeger) A bit is a number which has only two possible values: 0 (Low) and 1(High). Bits & Bytes A group of bits is called a BYTE. 10 bytes (1 bits) is one Kilobyte(It s based on to the power of 10 ( 10 ). 10 bytes ( to the power of 0) is 1 Megabyte (MB) and 1 Gigabyte (GB is 0.) Note that this convention is not the same as a kilogram which is 1000 grams. Electricity basics We presume that you are familiar with the basics of electricity. But in case you re not here s a quick summary. An electrical circuit can be viewed as being similar to a plumbing system. The stream of water is the current and the pressure to drive the stream is the voltage. Imagine a stream flowing through a hose. Kinking the hose or adding a valve will cause the stream to be throttled; the more you narrow the hose the more constricted is the flow. This is resistance which constricts the flow of electricity and converts it into heat, lessening the current. Too much current can be bad for some components, for example LEDs. In the case of electricity the battery represents the pressure in the system, the flow is current of course and the constriction is resistance. These three elements are linked through the fundamental formula known as Ohms law. Often called the most important formula in electricity and the only formula you really need to know. In summary it is: R (Resistance)= V (Voltage) / I (Current) V = R x I I = V/R The Shed October/November 01 Output signals: An LED or Buzzer connected to an Arduino OUTPUT can "signal" you that something has happened. I V R Ohms Law triangle shows the relationship between Voltage, current and resistance. Put your finger on the value you want to see how to calculate it. Input Signals: If you push a button that changes an INPUT, you "signal" Arduino that something should be done. Time to hook real things up to those INPUTS and OUTPUTS. Take a couple of minutes to look at the Arduino board closely. All regular Arduino boards have the same overall size and the same long black connector strips across the top and bottom edges. These are female sockets that pins can plug into. Let's look at the details. Switch V First the top connector: The sockets are numbered 0 to 1 from right to left. These are the DIGITAL INPUT/ OUTPUT connections. You can push wires or the pins on the end of wires into those "Black Holes" and connect them to many different devices. We then tell the arduino how to treat them: as Input (digital Read) devices or output (digitalwrite) devices. The circuit diagram for the button input sketch. 10 Digital input Our circuit diagram shows a very simple circuit using a pushbutton to control the outputs of two LEDs. Make up the circuit shown on your breadboard. The pushbutton switch causes the INPUT to change from LOW to HIGH, which is a "signal" to the arduino. Arduino can change the OUTPUT on one LED from LOW to HIGH, and the other from HIGH to LOW. Copy and paste the sketch into your IDE and load it. This sketch adds three constants: two LEDs on pins 10 and 11 and a new INPUT, the BUTTON on pin. This sketch introduces a new concept essential to all microprocessor and computer programs the If statement. 10KΩ Arduino 11 0Ω 0Ω If statement The If statement makes the computer ask a question and take an action based on the answer to that question. In this case we have asked it to digitalread the buttonpin and compare it to a reference. The == symbol is used when we need to The Shed October/November 01

Layout for the ButtonInput sketch. Pushbutton switch from +V and Pin 10k resistor from pin to ground LED and 0Ω resistor in series from Pins 10 and 11 to Gnd Arduino 101 V SHED Magazine Arduino Sketch Button Input - Reads state of Pushbutton, changes state of LEDS - SEE the comments after "//" on each line below - CONNECTIONS: - Pushbutton Switch from + to Pin - 10K Resistor from Pin to ground - LED and 0 ohm resistor in series from pins 10 and 11 to Gnd Questions: terry@yourduino.com */ Pot A0 Arduino S Servo /*-----( Declare Constants and Pin Numbers )-----*/ #define buttonpin // Pins to connect to #define ledpin1 10 #define ledpin 11 The diagram for the Potentiometer-controlled Servo. compare a value against a reference you supplied (that s what HIGH means). It returns an answer of either true or false. If TRUE then the program carries out the actions described in the curly brackets immediately following. If FALSE then it runs the instructions in the else condition. The else condition is optional the default is to do nothing and make no change. Feel free to make additions to this sketch and try different combinations. Add more pushbuttons for example or more LEDS. Resistors You may be wondering what the purpose of the 10kΩ resistor connected to the GRD rail is. This is what is called a pulldown resistor. In this case it ties the output to ground when the button is open. Remove it and see how the circuit performs. Without the resistor the arduino gets no signal to the pin so it tends to pick up stray electromagnetic signals called noise and these can cause the pin to fluctuate between its two states rapidly and generate an inconsistent response. The resistor ties the circuit to ground with a high resistance when the circuit is open so the pin has a LOW signal rather than NO signal. The lower resistance of the closed circuit (when the button pushed) will activate the pin high as more current void setup() /****** SETUP: RUNS ONCE ******/ pinmode (ledpin1,output) ; // PIN 10 is an OUTPUT pinmode (ledpin, OUTPUT) ; // PIN 11 is an OUPUT pinmode (buttonpin, INPUT) ; // PIN is an INPUT }//--(end setup )--- void loop() /****** LOOP: RUNS CONSTANTLY ******/ if (digitalread(buttonpin)==high) // IF button is pushed digitalwrite(ledpin1, HIGH) ; // LED1 ON digitalwrite(ledpin, LOW) ; // LED OFF } else digitalwrite(ledpin1, LOW) ; // LED1 OFF digitalwrite(ledpin, HIGH) ; // LED ON } delay(0); // Wait a bit } //--(end main loop )--- You can copy this from The Shed website page at www.theshedmag.co.nz/online/ arduino and paste it directly in to your IDE. will flow directly to the pin overriding the pulldown resistor. The switch will PULLUP the pin against the PULLDOWN resistor. These resistors are important in digital circuits. They The Shed October/November 01

The circuit layout for the ServoPot sketch: Pot connected to + and Gnd. Signal to A0 (analog input 0) Servo to digital Pin Resistors Resistors are the most common electronic component; they are also the simplest. They have one job to do and that is to restrict the flow of current. Resistance is measured in Ohms with the Ω symbol. They range in value from 1 ohm to megohms (MΩ). Resistors are non polar so they have no specific orientation. They are usually marked with coloured bands and these bands have a specific code. It s worth knowing the code and you will probably get to know it with time especially the more common values. You can also check a resistor s value with a multimeter set to read resistance but being able to read the code is a serious time saver. There is much more to know about resistors and how they operate in a circuit and Make:Electronics is a recommended source for more information. RESISTORS COLOUR CODE Most resistors have a colour code to represent their value. There are or coloured bands on the resistor. To one end is a stripe of either gold or silver usually alone. If you orient this to be on the right side then the first two bands from the left represent the value of the resistor. The third band indicates how many zeros to add or its exponent for those that know their maths. 0 The Shed October/November 01 1 1 1 The Shed October/November 01 1 0 000 ±% 10K Ohm ±% Ist Digit nd Digit rd Digit Multiplier 0 0 0 0 0 00 ±1% 10 100 1000 10000 100000 1000000 0.1 Gold 0.01 Silver K Ohm ±1% Tolerance 1% % % Gold 10% Silver

Arduino 101 LED LEDs or Light Emitting Diodes have become universally used in every electronic or electrical device even as replacements for incandescent light. They come in a wide variety of colours from infrared to ultraviolet and most of the visible spectrum in between. There are also special LEDs that can be made to run Red, Green or Blue and we have included one in The Shed starter kit. A diode is a device that allows electricity to flow in one direction only. Power can run through a diode easily but only in one direction. They are also sensitive to current. The anode is the longer leg. The cathode side is shorter and has a flattened edge. Too much current can destroy them. Ideally LEDs prefer a current of only around 0mA (0 Milliamps or 0.0 amps) at around. Volts. Any more and you risk destroying them. That s why we usually apply a current limiting resistor to one leg of the LED. In this case we use a 0Ω resistor. To see what current flow 0Ω provides on V use Ohms Law where I=V/R = V/0Ω =0.0A or ma. LED s have a positive and a negative leg or anode and cathode. The positive leg that is connected to the +v line is the longer leg. The negative leg is shorter. It is also identified by a flat spot ground on the side of the casing rim. LEDs come in every colour, shape and size imaginable. can also be used as pullup resistors keeping the circuit high when open. You will also notice the addition of the two 0Ω current limiting resistors for the LEDs (see LED panel). We didn t need this previously because the Yourduino has one built in to Pin 1. Analog In So far we have covered digital signals out (digitalwrite) and digital in (digital Read). But Arduino also has analog inputs. Analog inputs are far more common than digital (although that is rapidly changing). We have incorporated several into the starter kit. Digital has two values either on or off but analog has an infinite number of values. One example of an analog in the starter kit is the potentiometer. A potentiometer (or Pot) is a variable resistor. The Pot has three connections, the outer two left and right are connected to the +V and respectively and the centre connection is the signal. From the schematic you can see that the pot is basically a surround of resistive material and a wiper that contacts it. As we move the pot, the output voltage going to Arduino varies from 0 to Volts and all the values in between. Arduino reads these as values from 0-10 where 0 is the GRD and 10 is +V. In this sketch we will use the input signal from the pot to control a servomotor. A servomotor is motor that can move to any position through 10. They are widely used for controlling things like steering, for example, but any purpose that requires incremental operation of a mechanical device is suitable for a servo. The stepper motor in The Shed Start Kit has three wires running to a threepin female connector. These three connections are (Brown) +V (Red), and Signal (Orange) respectively. You will see on the Yourduino board that there are a number of three pin connectors in both the digital and analog connectors. The digital connections in the top block are coloured white, red and black. The black is GDN, the red +V and the white is the Signal. This is the connection for the three-pin connectors. If you have a different arduino you will have to improvise this connection on the breadboard. Find the sketch called ServoPot in the sketch depository in The Shed website. Copy and paste it directly into your IDE. Set up the circuit as described on your breadboard and the arduino and upload the sketch to YourDuino. As you move the pot the servo should turn back and forth. What s happening here? An Analog Input Device (the Pot) is feeding a varying voltage into an Arduino Analog input. The Arduino sketch is making decisions based on that value to send an Output Signal to the Servomotor. Arduino is reading the position of the Pot wiper scaling that into a digital signal and sending that signal to the servo. To ensure that the servo actually has time to move to the position there is a delay of milliseconds before it reads again. The Shed October/November 01 1