Line Following Tips photoresistor circuit

Slides:



Advertisements
Similar presentations
temperature system wiring
Advertisements

Using the servo library living with the lab Libraries are computer programs written to add functionality to Arduino programs. A library to control hobby.
Conductivity sensor implementation living with the lab © 2011 LWTL faculty team.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2012 David Hall.
Waterproofing a thermistor ENGR 121 living with the lab © 2013 David Hall.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
User-defined functions in Arduino sketches living with the lab © 2012 David Hall.
Cascaded switching of a solenoid valve living with the lab transistor relay solenoid valve © 2012 David Hall.
Switches & whiskers on the Arduino living with the lab lever arm switches mounted to Arduino © 2012 David Hall.
220  470  Gnd5V Currents Through Parallel Resistors 1 living with the lab © 2012 David Hall.
Using Hobby Servos with the Arduino living with the lab © 2012 David Hall.
Voltage Drops Around Closed Loops 470  220  5V   220  living with the lab © 2012 David Hall.
Navigating the engineering disciplines robot challenge living with the lab © 2012 David Hall.
Kirchoff’s Current Law (KCL) living with the lab University of Pennsylvania Library and Wikipedia Gustav Kirchoff (left) and Robert Bunsen (right) Bunsen.
Line following tips photoresistors positioned near floor photoresistor circuits © 2011 LWTL faculty team living with the lab.
Using for loops to control LEDs living with the lab 1 1 arduino.cc the for statement allows us to repeat a block of commands a limited number of times.
Building Circuits.
Pump Fabrication Day Group A will draw their pump
Controlling Servos with the Arduino
Connecting Switches.
Series and Parallel Resistors
Pump Project Requirements
Introduction to the Arduino
Why Won’t My Arduino Work?
Robot Challenge Introduction
Troubleshooting Your Multimeter
Using servos.
Servo Library and Functions
Line Following Tips photoresistor circuits
What’s in your kit?.
Robot Assembly.
How to Use Dial Calipers
Controlling a Motor with Cascading Switches
Introduction to Transistors
Introduction to the Fishtank
RGB LEDs.
Conservation of Mass Problem
Maxbotix Ultrasonic Distance Sensor
Conductivity Sensor.
Introduction to Transistors
Servo Library and Functions
Troubleshooting Your Multimeter
a few of my favorite sensors
Relays.
using for loops to control LEDs
using the Arduino to make LEDs flash
Acquiring Data from an ADXL335 Accelerometer
Using Photoresistors with an Arduino
Torque and RPM of Gears
Conservation of Mass Problem
Data Types.
analog and digital measurements
Using “if” statements.
Controlling the Heater
Digital Input from Switches
Cash Flow Diagrams <in> <out> $200 $300 $150 $100
Implementing Switches Using Interrupts
Arduino: For Loops.
Non-Concurrent Force Systems
IR Object Detection IR detector IR LED IR light reflected off object
Radio Frequency Transmitter and Receiver
Interfacing a Rotary Encoder with an Arduino
Conservation of Mass Problem
Non-Concurrent Force Systems
Evaluating Design Alternatives
Counting Servo Gear Teeth (FS90R Servos)
Static Equilibrium Problem
Reservoir Loop.
Freshman Design Expo Presentations
Gearmotor Efficiency W table top gearmotor pulley string.
Presentation transcript:

Line Following Tips photoresistor circuit photoresistor positioned near floor

DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms

Add extensions to photoresistors while you may eventually choose to use two photoresistors, you only need one to get started.

Review of photoresistor implementation int analogPin = 2; // middle terminal of voltage divider circuit int val = 0; // variable to store the value read void setup() { Serial.begin(9600); // setup serial display } void loop() { val = analogRead(analogPin); // read the input pin Serial.println(val); // print value to serial monitor 5V analog input 2 photoresistor 10kW The “voltage” sensed at analog pin 4 is sent to the Serial Monitor for viewing. Here, an output of 0 represents 0V and 1023 represents 5V.

Try different resistors to see which value gives the best response Experiment with circuit & photoresistor placement void setup() { Serial.begin(9600); } void loop() { int val = analogRead(2); Serial.println(val); 5V analog input 2 photoresistor R Move the robot with your hand so that the active photoresistor is over white and then over the black stripe. Make a note of the values sent to the serial monitor. Does it matter how far the photoresistor is from the ground level? Try different resistors to see which value gives the best response

Photoresistor output variation void setup() { Serial.begin(9600); } void loop() { int val = analogRead(2); Serial.println(val); Consider the possible output values of your photoresistor setup: Experimenting with your photoresistor in well lit conditions may result in consistent “white” and “black” output values. However, if you move to another environment, such as a dimly lit room, your “white” and “black” values would likely decrease (the way we have the circuit configured). To compensate for this variation, it is common practice to measure “white” and “black” values “on the fly” as your robot begins its mission. You could write a function that determines the “threshold” values for your robot.

Following the Left Edge of a Line Consider the case where we are following the left edge of a black line on a white background. One way to navigate along the edge of the line is to . . . Go forward and to the left when the photoresistor is over black Go forward and to the right when the photoresistor is over white Considerations: Robot path: how sharp should the robot turn as it moves forward? Would it be possible to go straight when you are on the edge of the line? Possible Algorithm: Go right if output > 520 Go straight if 440 < output < 520 Go left if output < 440 1 2 3 4

Simple left-edge line following program #include <Servo.h> Servo myservo1; Servo myservo2; int white=520; // this number probably won't work for you int black=440; // this number probably won't work for you void setup() { myservo1.attach(2); myservo2.attach(3); Serial.begin(9600); } void loop() { int val = analogRead(5); Serial.print("white = "); Serial.print(white); Serial.print(" black = "); Serial.print(black); Serial.print(" val = "); Serial.println(val); if (val>white) {slow_right(); } // over white else if (val<black) {slow_left(); } // over black else {slow_forward(); } // over gray void slow_forward() { myservo1.writeMicroseconds(1550); myservo2.writeMicroseconds(1450); } void slow_right() { myservo2.writeMicroseconds(1520); } void slow_left() { myservo1.writeMicroseconds(1480);

Hints/tips to get you started: Class Problem: Using the mats provided program your Arduino to travel forward until the photoresistor detects the black line. Once the black line is detected, program your Arduino to immediately stop. Hints/tips to get you started: What is the analog value read by your Arduino when it sees the mat versus the black line? Use the servo library and/or functions to help with motion.