100 likes | 197 Views
Working with Arduino: Lesson #3: Force Sensitive Resistors. EGN1007. Learning Goals. Learning Goals: The student will be able to: Build a complete circuit using the Arduino microprocessor Identify important electrical components in a circuit and explain their use
E N D
Working with Arduino:Lesson #3: Force Sensitive Resistors EGN1007
Learning Goals Learning Goals: The student will be able to: Build a complete circuit using the Arduino microprocessor Identify important electrical components in a circuit and explain their use Identify and apply specific elements in “C” code used to run a program in conjunction with how a circuit is built
Force Sensitive resistors An FSR is identical to a potentiometer, except rather that varying its resistance relative to shaft position its resistance varies with pressure. A force sensing resistor is made up of two parts. The first is a resistive material applied to a film. The second is a set of digitating contacts applied to another film. The figure shows this configuration. The resistive material serves to make an electrical path between the two sets of conductors on the other film. When a force is applied to this sensor, a better connection is made between the contacts, hence the conductivity is increased. The schematic symbol is that of a regular resistor with an arrow through it. And “f” net to the arrow is indicative of FORCE.
Let’s Begin • Place FSR on G5 & G6 • Run a red wire from the 5V on the Arduino to H5. This will supply the FSR with 5V. • Run a wire from Analog 2 to H6. • Place a 10KW resistor(Br-BL-O) in I6 and I12. • Place the LED on G15 and G16 with the longer lead(+) of the LED in G15. • Place a 560W resistor on H16 and H22. Notice that both the resistor and LED share row 16 • Run a red wire from Digital 9port on Arduino to H15. • Run a black wire from H22 to the ground(GND). • Run a black wire from H12 to I22.
Programming our sketch Let’s define 2 variables as integers. These will tell us which ports our LED and FSR are in.
Programming our sketch Just like before we need to set our LED as an output. We have a new piece of code here: Serial.begin ( ) Sets the data rate in bits per second (baud) for serial data transmission. So basically we are going to transfer 9600 bits per second to the computer. Old modems attached to our phone lines used to work at this speed. This was considered FAST back in the day, until 14400 finally came out.
Programming our sketch We begin by creating a variable called “value” which will read the value on the FSR and divide it by 4. This will then be written to the LED and ALSO sent as a piece of data and displayed in a Debugger Window. When “println” is used after the Serial command it takes the reading from the FSR and displays it in a window(debugger) for inspection. Compile, download, and test. Does the LED light up.
Your turn! Using what you have learned in this lesson AND the last lesson, write a short program that is BETTER than the one we wrote. Hint: Use the debugger to get the values you need and use information previously learned. The response from the LED should be a bit smoother. Write your code on the lesson worksheet and explain your code.
Challenge Can you write a program that lights more than one LED using the FSR so that they light in a sequence or other pattern? Write your code on the lesson worksheet and explain your code.