Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas

apostlia - introduction to arduino, Notas de estudo de Engenharia Elétrica

apostlia - introduction to arduino

Tipologia: Notas de estudo

2013

Compartilhado em 18/06/2013

tobias-tavares-de-luna-11
tobias-tavares-de-luna-11 🇧🇷

5

(4)

10 documentos

1 / 44

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
Installation:
•Arduino: http://www.arduino.cc/en/Guide/HomePage
•Fritzing: http://fritzing.org/download/
Support:
•Arduino: http://www.arduino.cc, http://www.freeduino.org, google.com
•Fritzing: http://www.fritzing.org/learning/
Forums:
•Arduino: http://forum.sparkfun.com/viewforum.php?f=32
•Fritzing: http://fritzing.org/forum/
Intro to ArduIno //1
Introduction to Arduino
// Basic Arduino reference sheet:
© 2012 SparkFun Electronics, Inc. SparkFun Electronics Educational Materials are Licensed under Creative Commons Attribution -ShareAlike, CC BY-SA
SparkFun Electronics Introduction to Arduino is a trademark of SparkFun Electronics, Inc. All other trademarks contained herein are the property of their respective owners.
SparkFun Electronics Introduction to Arduino Educational Material
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c

Pré-visualização parcial do texto

Baixe apostlia - introduction to arduino e outras Notas de estudo em PDF para Engenharia Elétrica, somente na Docsity!

Installation:

• Arduino: http://www.arduino.cc/en/Guide/HomePage

• Fritzing: http://fritzing.org/download/

Support:

• Arduino: http://www.arduino.cc, http://www.freeduino.org, google.com

• Fritzing: http://www.fritzing.org/learning/

Forums:

• Arduino: http://forum.sparkfun.com/viewforum.php?f=

• Fritzing: http://fritzing.org/forum/

Introduction to Arduino

// Basic Arduino reference sheet:

© 2012 SparkFun Electronics, Inc. SparkFun Electronics Educational Materials are Licensed under Creative Commons Attribution -ShareAlike, CC BY-SA SparkFun Electronics Introduction to Arduino is a trademark of SparkFun Electronics, Inc. All other trademarks contained herein are the property of their respective owners.

SparkFun Electronics Introduction to Arduino Educational Material

  • setup( ): A function present in every Arduino sketch. Run once before the loop( ) function. Often used to set pinmode to input or output. The setup( ) function looks like: void setup( ){ //code goes here }
  • loop( ): A function present in every single Arduino sketch. This code happens over and over again. The loop( ) is where (almost) everything happens. The one exception to this is setup( ) and variable declaration. ModKit uses another type of loop called “forever( )” which executes over Serial. The loop( ) function looks like: void loop( ) { //code goes here }
  • input: A pin mode that intakes information.
  • output: A pin mode that sends information.
  • HIGH: Electrical signal present (5V for Uno). Also ON or True in boolean logic.
  • LOW: No electrical signal present (0V). Also OFF or False in boolean logic.
  • digitalRead: Get a HIGH or LOW reading from a pin already declared as an input.
  • digitalWrite: Assign a HIGH or LOW value to a pin already declared as an output.
  • analogRead: Get a value between or including 0 (LOW) and 1023 (HIGH). This allows you to get readings from analog sensors or interfaces that have more than two states.
  • analogWrite: Assign a value between or including 0 (LOW) and 255 (HIGH). This allows you to set output to a PWM value instead of just HIGH or LOW.
  • PWM: Stands for Pulse-Width Modulation, a method of emulating an analog signal through a digital pin. A value between or including 0 and 255. Used with analogWrite.

// Basic Arduino code definitions:

SIK Worksheets v. 1.0 Name:

Date:

Often resistor # 1 is a resistor with a value that changes, possibly a sensor or a potentiometer. Resistor # 2 has whatever value is needed to create the ratio the user decides is acceptable for the voltage divider output. The Voltage In and Ground portions are just there to establish which way the electrical current is heading, there can be any number of circuits before and after the voltage divider. Here is the equation that represents how a voltage divider works:

If both resistors have the same value then Voltage Out is equal to ½ Voltage In.

Ok, how is this voltage divider information used? It depends on what you want to do with it really. There are two different purposes outlined above for the voltage divider, we will go over both.

If you wish to use the voltage divider as a sensor reading device first you need to know the maximum voltage allowed by the analog inputs you are using to read the signal. On an Arduino this is 5V. So, already we know the maximum value we need for Vout. The Vin is simply the amount of voltage already present on the circuit before it reaches the first resistor. You should be able to find the maximum voltage your sensor outputs by looking on the Datasheet, this is the maximum amount of voltage your sensor will let through given the voltage in of your circuit. Now we have exactly one variable left, the value of the second resistor. Solve for R2 and you will have all the components of your voltage divider figured out! We solve for R1’s highest value because a smaller resistor will simply give us a smaller signal which will be readable by our analog inputs.

Powering an analog Reference is exactly the same as reading a sensor except you have to calculate for the Voltage Out value you want to use as the analog Reference.

Given three of these values you can always solve for the missing value using a little algebra, making it pretty easy to put together your own voltage divider. The S.I.K. has many voltage dividers in the example circuits. These include: Circuits # 7, 8, 9, 13 and 14.

// Voltage Dividers:

What is a voltage divider? Voltage dividers are a way to produce a voltage that is a fraction of the original voltage.

Why is a voltage divider useful? One of the ways this is useful is when you want to take readings from a circuit that has a voltage beyond the limits of your input pins. By creating a voltage divider you can be sure that you are getting an accurate reading of a voltage from a circuit. Voltage dividers are also used to provide an analog Reference signal.

What is in a voltage divider? A voltage divider has three parts; two resistors and a way to read voltage between the two resistors.

How do you put together a voltage divider? It’s really pretty easy. Here is a schematic and explanation detailing how:

SIK Worksheets v. 1.0 Name:

Date:

SIK Worksheets v. 1.

// Digital:

Date:

All of the electrical signals that the Arduino works with are either Analog or Digital. It is extremely important to understand the difference between these two types of signal and how to manipulate the information these signals represent.

Digital

An electronic signal transmitted as binary code that can be either the presence or absence of current, high and low voltages or short pulses at a particular frequency.

Humans perceive the world in analog, but robots, computers and circuits use Digital. A digital signal is a signal that has only two states. These states can vary depending on the signal, but simply defined the states are ON or OFF, never in between.

In the world of Arduino, Digital signals are used for everything with the exception of Analog Input. Depending on the voltage of the Arduino the ON or HIGH of the Digital signal will be equal to the system voltage, while the OFF or LOW signal will always equal 0V. This is a fancy way of saying that on a 5V Arduino the HIGH signals will be a little under 5V and on a 3.3V Arduino the HIGH signals will be a little under 3.3V.

To receive or send Digital signals the Arduino uses Digital pins # 0 - # 13. You may also setup your Analog In pins to act as Digital pins. To set up Analog In pins as Digital pins use the command: pinMode(pinNumber, value); where pinNumber is an Analog pin (A0 – A5) and value is either INPUT or OUTPUT. To setup Digital pins use the same command but reference a Digital pin for pinNumber instead of an Analog In pin. Digital pins default as input, so really you only need to set them to OUTPUT in pinMode. To read these pins use the command: digitalRead(pinNumber); where pinNumber is the Digital pin to which the Digital component is connected. The digitalRead command will return either a HIGH or a LOW signal. To send a Digital signal to a pin use the command: digitalWrite(pinNumber, value); where pinNumber is the number of the pin sending the signal and value is either HIGH or LOW.

The Arduino also has the capability to output a Digital signal that acts as an Analog signal, this signal is called Pulse Width Modulation (PWM). Digital Pins # 3, # 5, # 6, # 9, # 10 and #11 have PWM capabilities. To output a PWM signal use the command: analogWrite(pinNumber, value); where pinNumber is a Digital Pin with PWM capabilities and value is a number between 0 (0%) and 255 (100%). For more information on PWM see the PWM worksheets or S.I.K. circuit 12.

Examples of Digital:

Values: On/Off, Men’s room/Women’s room, pregnancy, consciousness, the list goes on.... Sensors/Interfaces: Buttons, Switches, Relays, CDs, etc....

Things to remember about Digital:

  • Digital Input/Output uses the Digital pins, but Analog In pins can be used as Digital
  • To receive a Digital signal use: digitalRead(pinNumber);
  • To send a Digital signal use: digitalWrite(pinNumber, value);
  • Digital Input and Output are always either HIGH or LOW

SIK Worksheets v. 1.

// Output:

Date:

All of the electrical signals that the Arduino works with are either input or output. It is extremely important to understand the difference between these two types of signal and how to manipulate the information these signals represent.

Output Signals

A signal exiting an electrical system, in this case a microcontroller.

Output to the Arduino pins is always Digital, however there are two different types of Digital Output; regular Digital Output and Pulse Width Modulation Output (PWM). Output is only possible with Digital pins # 0 - # 13. The Digital pins are preset as Output pins, so unless the pin was used as an Input in the same sketch, there is no reason to use the pinMode command to set the pin as an Output. Should a situation arise where it is necessary to reset a Digital pin to Output from Input use the command: pinMode(pinNumber, OUTPUT); where pinNumber is the Digital pin number set as Output. To send a Digital Output signal use the command: digitalWrite(pinNumber, value); where pinNumber is the Digital pin that is outputting the signal and value is the signal. When outputting a Digital signal value can be either HIGH (On) or LOW (Off).

Digital Pins # 3, # 5, # 6, # 9, # 10 and #11 have PWM capabilities. This means you can Output the Digital equivalent of an Analog signal using these pins. To Output a PWM signal use the command: analogWrite(pinNumber, value); where pinNumber is a Digital Pin with PWM capabilities and value is a number between 0 (0%) and 255 (100%). For more information on PWM see the PWM worksheets or S.I.K. circuit 12.

Output can be sent to many different devices, but it is up to the user to figure out which kind of Output signal is needed, hook up the hardware and then type the correct code to properly use these signals.

Things to remember about Output:

  • Output is always Digital
  • There are two kinds of Output: regular Digital or PWM (Pulse Width Modulation)
  • To send an Output signal use analogWrite(pinNumber, value); (for analog) or digitalWrite(pinNumber, value); (for digital)
  • Output pin mode is set using the pinMode command: pinMode(pinNumber, OUTPUT);
  • Regular Digital Output is always either HIGH or LOW
  • PWM Output varies from 0 to 255

Examples of Output:

Light Emitted Diodes (LED’s), Piezoelectric Speakers, Servo Motors

SIK Worksheets v. 1.

// Input:

Date:

All of the electrical signals that the Arduino works with are either input or output. It is extremely important to understand the difference between these two types of signal and how to manipulate the information these signals represent.

Input Signals

A signal entering an electrical system, in this case a microcontroller. Input to the Arduino pins can come in one of two forms; Analog Input or Digital Input.

Analog Input enters your Arduino through the Analog In pins # 0 - # 5. These signals originate from analog sensors and interface devices. These analog sensors and devices use voltage levels to communicate their information instead of a simple yes (HIGH) or no (LOW). For this reason you cannot use a digital pin as an input pin for these devices. Analog Input pins are used only for receiving Analog signals. It is only possible to read the Analog Input pins so there is no command necessary in the setup( ) function to prepare these pins for input. To read the Analog Input pins use the command: analogRead(pinNumber); where pinNumber is the Analog Input pin number. This function will return an Analog Input reading between 0 and 1023. A reading of zero corresponds to 0 Volts and a reading of 1023 corresponds to 5 Volts. These voltage values are emitted by the analog sensors and interfaces. If you have an Analog Input that could exceed Vcc + .5V you may change the voltage that 1023 corresponds to by using the Aref pin. This pin sets the maximum voltage parameter your Analog Input pins can read. The Aref pin’s preset value is 5V.

Digital Input can enter your Arduino through any of the Digital Pins # 0 - # 13. Digital Input signals are either HIGH (On, 5V) or LOW (Off, 0V). Because the Digital pins can be used either as input or output you will need to prepare the Arduino to use these pins as inputs in your setup( ) function. To do this type the command: pinMode(pinNumber, INPUT); inside the curly brackets of the setup( ) function where pinNumber is the Digital pin number you wish to declare as an input. You can change the pinMode in the loop( ) function if you need to switch a pin back and forth between input and output, but it is usually set in the setup( ) function and left untouched in the loop( ) function. To read the Digital pins set as inputs use the command: digitalRead(pinNumber); where pinNumber is the Digital Input pin number.

Input can come from many different devices, but each device’s signal will be either Analog or Digital, it is up to the user to figure out which kind of input is needed, hook up the hardware and then type the correct code to properly use these signals.

Things to remember about Input:

  • Input is either Analog or Digital, make sure to use the correct pins depending on type.
  • To take an Input reading use analogRead(pinNumber); (for analog)
  • Or digitalRead(pinNumber); (for digital)
  • Digital Input needs a pinMode command such as pinMode(pinNumber, INPUT);
  • Analog Input varies from 0 to 1023
  • Digital Input is always either HIGH or LOW

Examples of Input:

Push Buttons, Potentiometers, Photoresistors, Flex Sensors

SIK Worksheets v. 1.

// Circuit 1, How the Circuits Work:

Date:

This first circuit is the simplest form of output in the kit. You can use the LED to teach both analog and digital output before moving on to more exciting outputs. There is an LED built into your Arduino board which corresponds to Digital Pin # 13.

Circuit 1

Explanation:

This circuit takes electricity from digital Pin # 9 on the Arduino. Pin # 9 on the Arduino has Pulse Width Modulation capability allowing the user to change the brightness of the LED when using analogWrite. The LED is connected to the circuit so electricity enters through the anode (+, or longer wire) and exits through the cathode (-, or shorter wire). The resistor dissipates current so the LED does not draw current above the maximum rating and burn out. Finally the electricity reaches ground, closing the circuit and allowing electricity to flow from power source to ground.

Schematic:

Components:

Arduino Digital Pin # 9: Power source, PWM (if code uses analogWrite) or digital (if code uses digitalWrite) output from Arduino board.

LED: As in other diodes, current flows easily from the + side, or anode (longer wire), to the

  • side, or cathode (shorter wire), but not in the reverse direction. Also lights up!

330 Ohm Resistor: A resistor resists the current flowing through the circuit. In this circuit the resistor reduces the current so the LED does not burn out.

Gnd: Ground

Code:

int ledPin = 3;

void setup() { pinMode(ledPin, OUTPUT); }

void loop() { digitalWrite(ledPin, HIGH); //LED on delay(1000); // wait second digitalWrite(ledPin, LOW); //LED off delay(1000); // wait second }

or for PWM output loop could read : int ledPin = 3;

void setup() { pinMode(ledPin, OUTPUT); }

void loop() { analogWrite(ledPin, 255); // LED on delay(1000); // wait second analogWrite(ledPin, 0); // LED off delay(1000); // wait second

SIK Worksheets v. 1.

// Circuit 8, How the Circuits Work:

Date:

This is another example of input, only this time it is Analog. Circuits 7 and 8 in the S.I.K. introduces you to the two kinds of input your board can receive: Digital and Analog. Not sure what a voltage divider is? Check the Voltage Divider page towards the back of this section.

Circuit 8

Explanation:

This circuit is actually two different circuits. One circuit for the potentiometer and another for the LED. See How the Circuits Work, Circuit 1 for an explanation of the LED circuit. The potentiometer circuit gets electricity from the 5V on the Arduino. The electricity passes through the potentiometer and sends a signal to Analog Pin # 0 on the Arduino. The value of this signal changes depending on the setting of the dial on the potentiometer. This analog reading is then used in the code you load onto the Arduino and effects the power signal in the LED circuit. Finally the electricity reaches ground, closing the circuit and allowing electricity to flow from power source to ground.

Schematic:

Components:

Arduino Digital Pin # 13: Power source, PWM (if code uses analogWrite) or digital (if code uses digitalWrite) output from Arduino board.

Arduino Analog Pin # 0: Analog input to Arduino board.

330 Ohm Resistor: A resistor resists the current flowing through the circuit. In the LED circuit it reduces the current so the LED in the circuit does not burn out.

LED: As in other diodes, current flows easily from the + side, or anode (longer wire), to the - side, or cathode (shorter wire), but not in the reverse direction.

Potentiometer: A voltage divider which outputs an analog value.

+5V: Five Volt power source.

Gnd: Ground

Code:

int sensorPin = 0; int ledPin = 13; int sensorValue = 0;

void setup() { pinMode(ledPin, OUTPUT); }

void loop() {

//this line assigns whatever the //Analog Pin 0 reads to sensorValue

sensorValue = analogRead(sensorPin);

digitalWrite(ledPin, HIGH); delay(sensorValue); digitalWrite(ledPin, LOW); delay(sensorValue); }

SIK Worksheets v. 1.

// Circuit 4, How the Circuits Work:

Date:

Circuit 4

Explanation:

The servo in this circuit takes electricity from 5V on the Arduino. Pin # 9 on the Arduino supplies a PWM signal which sets the position of the servo. Each voltage value has a distinct correlating position. Finally the electricity reaches ground, closing the circuit and allowing electricity to flow from power source to ground.

Schematic:

Components:

Arduino Digital Pin #9: Signal power source for servo.

Servo: Sets the position of the servo arm depending on the voltage of the signal received.

+5V: Five Volt power source.

Gnd: Ground

Code:

//include the servo library for use #include <Servo.h> Servo myservo; //create servo object

int pos = 0;

void setup() { myservo.attach(9); } void loop() { //moves servo from 0° to 180° for(pos = 0; pos < 180; pos += 1) { myservo.write(pos); delay(15); } // moves servo from 180° to 0° for(pos = 180; pos>=1; pos-=1) { myservo.write(pos); delay(15); } }

Servo Signal Energy Source

Direction of current Electricity starts hereand varies

KEY:

Arduino9 Pin

Signal(white)

(black)gnd

+5v(red)

+5v Servo Energy Source

(ground)(-)GND Electricity ends

Mini Servo

~ Electricity starts here

~

SIK Worksheets v. 1.

// Circuit 5, How the Circuits Work:

Date:

Circuit 5

Explanation:

The shift register in this circuit takes electricity from 5V on the Arduino. Pin # 2, # 3 and # 4 on the Arduino supply a digital value. The latch and clock pins are used to allow data into the shift register. The shift register sets the eight output pins to either HIGH or LOW depending on the values sent to it via the data pin. The LEDs are connected to the circuit so electricity enters through the anode (+, or longer wire) and exits through the cathode (-, or shorter wire) if the shift register pin is HIGH. The resistor dissipates current so the LEDs do not draw current above the maximum rating and burn out. Finally the electricity reaches ground, closing the circuit and allowing electricity to flow from power source to ground.

Schematic:

Components:

Arduino Digital Pin # 2, # 3 and # 4: Signal power source for data, clock and latch pins on shift register.

Shift register: Allows usage of eight output pins with three input pins, a power and a ground. Link to datasheet.

LED: As in other diodes, current flows easily from the + side, or anode (longer wire), to the

  • side, or cathode (shorter wire), but not in the reverse direction. Lights up!

330 Ohm Resistor: A resistor resists the current flowing through the circuit. In this circuit the resistor reduces the current so the LED does not burn out.

+5V: Five Volt power source.

Gnd: Ground

Code:

int data = 2; int clock = 3; int latch = 4;

int ledState = 0; const int ON = HIGH; const int OFF = LOW;

void setup() { pinMode(data, OUTPUT); pinMode(clock, OUTPUT); pinMode(latch, OUTPUT); }

void loop(){ for(int i = 0; i < 256; i++) { updateLEDs(i); delay(25); } }

void updateLEDs(int value) { digitalWrite(latch, LOW); shiftOut(data, clock, MSBFIRST, value); digitalWrite(latch, HIGH); }

Data, Clock & Latch Signal Energy Sources

Direction of current

KEY:

Electricity starts here

0 1 2 3 4 5 6 7 data

+5V

+5 volts

LED

(ground)(-)GND Electricity ends here

resistor

Pin 4 Pin 3 Pin 2

Shift Register Energy Source

clock latch

gnd

SIK Worksheets v. 1.

// Resistance:

Date:

Resistance is an important concept when you are creating circuits. Resistance is the difficulty a current encounters when it passes through a component. Everything that electricity passes through provides some measure of resistance, wires, motors, sensors, even the human body! Measuring voltage, current and resistance are all done in different ways. To measure resistance you disconnect (turn off) your circuit and place both multimeter leads on either side of the portion of the circuit you wish to measure. For example: for measuring just a component you would place your leads on the power and ground leads of the component. To measure the resistance of multiple components you leave them connected and place the positive (red) multimeter lead closer to the disconnected power source and the negative (black) multimeter lead closer to the ground. Sometimes you will want to measure the resistance of input and output leads, but more often you will find yourself measuring resistance along the power to ground circuit. It is important to know how much resistance is present in components and circuits for many reasons. Too much resistance and the current will never travel through the whole circuit, too little and the current may fry some of your components! But most importantly you can use resistance to choose the path the current takes through your circuit.

Hook up the circuit to the right using red LEDs. (Don’t hook up the power yet.)

Measure the resistance of each of the possible paths the current can take from power (5v) to ground. There are three possible paths. You will have to measure each component separately and then add the resistance up for the total. You will can add the component’s resistance together because the components are in series, if they were parallel it would require more math. Record the total resistance for each circuit below. (Hint: you won’t be able to measure the LED)

Circuit 1: _______Ω Circuit 2: _________Ω Circuit 3: ___________Ω Now connect the power and, one at a time, press the two buttons. Which circuit makes the LED the dimmest? Circuit # ______ If you press both buttons which path does the current take? Circuit # ______ If the voltage is staying at 5v in this circuit no matter which paths are closed, there is a way to calculate the current given the resistance. Write the name of the law and the equation that solves for resistance below. Label all variables.

Now measure the resistance of a potentiometer when it is dialed all the way up and down. Record the highest and lowest values you get.

Highest:______________________ Ω

Lowest:_____________________ Ω

Redraw the schematic above (use the back of the worksheet if necessary) but use a potentiometer to control the LED brightness instead of the buttons and various resistors. Remember that you must have at least 330Ω of total resistance, otherwise you’ll burn out your LED!

Since a circuit or component does not need a current running through it in order to measure the resistance you can take your multimeter and measure the resistance of anything you can think of. Wander around and measure the resistance of various objects. Start with a penny. Record the most interesting things that have resistance and the value of their resistance below. List at least three.

SIK Worksheets v. 1.

// Voltage Drop:

Date:

Voltage drop is an important concept when you are creating circuits. Voltage drop is the amount that the voltage drops when it passes through a component. The following exercises will show how to measure voltage drop in real life. This is essential when you are fixing your remote control car, electric guitar or even a cell phone. Measuring voltage, current and resistance are all done in different ways. To measure voltage you connect your positive (red) multimeter lead to the side of the circuit that closer to your power source and the negative (black) multimeter lead to the side of the circuit that is closer to the ground. It is important to know how much voltage is going through a circuit for many reasons. The most important reasons being that too much voltage can damage your components and too little voltage may not allow electricity to flow all the way through to ground.

Hook up the circuit to the right using red LEDs.

Close the circuit so only one LED is grounded with the 300Ω resistor. Insert the end of the resistor not plugged into the ground into a hole on the same row as the first LED’s negative lead. The other LEDs don’t light up, why is this?

Measure the voltage drop across just the LED and record. ________________v Measure the voltage drop across the LED and the resistor. ________________v Close the circuit so two LEDs light up. Voltage drop across one LED = _____v Voltage drop across two LEDs = _____v Measure the voltage drop across the whole circuit and record. _____________v Close the circuit so three LEDs light up. Voltage drop across one LED = _____v Voltage drop across two LEDs = _____v Voltage drop for three LEDs = _____v Voltage drop for whole circuit = _____v What happened to the LEDs with the last question? _____________________________


Now hook up the same circuit to the 3.3V power source without the resistor. Why do you think you don’t need the resistor?

Measure the voltage drop across all the LEDs and record. ____________v

Close the circuit so only two LEDs light up.

Voltage drop across one LED = _____v Voltage drop across two LEDs = _____v Hook up the circuit above to the 5V power source but use the 3.3v as ground. Wait a second! You can’t use a power source as a ground! Or can you?

What is the voltage available and how many LEDs can you light up with it?

Voltage available = ________v # of LEDs you can light up = __________ Many people think of Gnd as the ONLY place to connect a ‘negative’ pin, but all you need is a voltage drop from the beginning of a circuit to the end. This difference in voltage is what draws the current in the correct direction.

SIK Worksheets v. 1.

// Voltage Dividers:

Date:

What is a voltage divider? Voltage dividers are a way to produce a voltage that is a fraction of the original voltage.

Why is a voltage divider useful? One of the ways a voltage divider is useful is when you want to take readings from a circuit that has a voltage beyond the limits of your input pins. By creating a voltage divider you can be sure that you are getting an accurate reading of a voltage from a circuit. Voltage dividers are also used to provide an analog reference signal.

What is in a voltage divider? A voltage divider has three parts; 2 resistors and a way to read voltage between the 2 resistors.

How do you put together a voltage divider? It’s really pretty easy. Here is a schematic and explanation detailing how:

Often resistor # 1 is a resistor with a value that changes, possibly a sensor or a potentiometer.

Resistor # 2 has whatever value is needed to create the ratio the user decides is acceptable for the voltage divider output.

The Voltage In and Ground portions are just there to establish which way the electrical current is heading, there can be any number of circuits before and after the voltage divider.

Here is the equation that represents how a voltage divider works:

If both resistors have the same value then Voltage Out is equal to ½ Voltage In.

Ok, how is this voltage divider information used? It depends on what you want to do with it really. There are two different purposes. If you wish to use the voltage divider as a sensor reading device first you need to know the maximum voltage allowed by the analog inputs you are using to read the signal. On an Arduino this is 5V. So, already we know the maximum value we need for Vout. The Vin is simply the amount of voltage already present on the circuit before it reaches the first resistor. You should be able to find the maximum voltage your sensor outputs by looking on the Datasheet, this is the maximum amount of voltage your sensor will let through given the voltage in of your circuit. Now we have exactly one variable left, the value of the second resistor. Solve for R2 and you will have all the components of your voltage divider figured out! We solve for R1’s highest value because a smaller resistor will simply give us a smaller signal which will be readable by our analog inputs. Powering an analog Reference is exactly the same as reading a sensor except you have to calculate for the Voltage Out value you want to use as the analog Reference. Given three of these values you can always solve for the missing value using a little algebra, making it pretty easy to put together your own voltage divider. The S.I.K. has many voltage dividers in the example circuits. These include: Circuits # 7, 8, 9, 13 and 14 to use the input capabilities of the Arduino. Notice the difference in setup( ). You are still using a Digital Pin but you are using it as input rather than output.

SIK Worksheets v. 1.

// Using a Multimeter:

Date:

Often you will have to use a multimeter for troubleshooting a circuit, testing components, materials or the occasional worksheet. This section will cover how to use a digital multimeter, specifically a SparkFun VC830L. We will discuss how to use this multimeter to measure voltage, current, resistance and continuity on the circuits in the S.I.K.

Parts of a multimeter

Settings

There are a bunch of different settings depending on how much of a signal the multimeter is being used to measure. This is a good opportunity to talk about unit conversion.

Display: Where values are displayed. Knob/Setting: Used to select what is being measured and the upper limit of how much is being measured. Positive port 1: Where the positive port connector is plugged in if you are measuring less than 100mA of current. Common/Ground: Where the negative port connector is plugged in no matter what. Positive port 2: Where the positive port connector is pluuged in if you are measuring more than 100mA of current. Probes: The points of contact for measuring electrical signals. Place the positive probe closer to the energy source and the negative probe closer to ground. Port Connectors: Plug them into multimeter.

Important: Sometimes the reading will not remain steady or will display a value that you believe is wrong. If this happens make sure your probes are making firm, constant contact with your circuit on a conductive material.

Voltage: The options for measuring voltage range from 200mV all the way up to 600 Volts.

Current: The options for measuring current range from 20μA all the way up to 10 Amps.

Resistance: The options for measuring resistance range from 200Ω to 20MΩ.

Continuity: This option is for testing to see if there is an electrical connection between two points.

Changing com ports:

Use the first positive com port if you are measuring a signal with less than 100mA of current. Switch to the second positive com port if you are using more. With the Arduino you will usually be using the first positive com port.

Replacing fuses:

If you try to measure more than 100mA of current through the first positive com port you will most likely blow the fuse in your multimeter. Don’t worry, the multimeter isn’t broken, it simply needs a new fuse. Replacing fuses is easy, this tutorial explains it: http://www.sparkfun.com/tutorials/202.