80 likes | 180 Views
ESC100 Design Studio. Session 2: Arduino & Distance Sensing Prof Anderson, Section 2. PreLab Check . End. You have 5 minutes to get your circuit running. Have the LCD display your First and Last Name. Go…. Today’s Exercise. theawesomeboston.com. Use a distance Sensor…Why?
E N D
ESC100 Design Studio Session 2: Arduino & Distance Sensing Prof Anderson, Section 2
PreLab Check End www.A6training.co.uk You have 5 minutes to get your circuit running. Have the LCD display your First and Last Name. Go….
Today’s Exercise theawesomeboston.com • Use a distance Sensor…Why? • http://www.youtube.com/watch?v=bp9KBrH8H04 • More info: • IEEE.org: How Google's Self-Driving Car Works • NY Times: How an autonomous car gets around
The Distance Sensor Light Emitter Light Detector https://www.sparkfun.com/products/8959
Download the Code (and study it!) #include <LiquidCrystal.h> const char buttonPin=7; //The pushbutton is connected to pin 7. This line creates an 8-bit number that can't be changed and stores "7" in it. const char sensorPin=A0; //The sensor is connects to pin A0. This line creates an 8-bit number that can't be changed and stores "?" in it. intsensorVal=0; //Value read by analog input...will be from 0 to 1023. float sensorVoltage=0.0; //Voltage corresponding to sensorVal booleanbuttonVal; //Boolean variable to record if button has been pushed. LiquidCrystallcd(12,11,5,4,3,2); //creating a LiquidCrystal variable (object) named lcd. void setup() { pinMode(buttonPin,INPUT_PULLUP); //Button Pin is an input and we want it connected to a pull-up resistor. lcd.begin(16,2); //Get RedBoard ready to talk to the lcd (this is an lcd with 16 cols and 2 rows) lcd.clear(); //Clear the lcd screen; Serial.begin(9600); //Get Redboard ready to talk to your computer over the usb cable }
Analysis and Discussion • Using Excel, make a plot of your average sensor output (x-axis) versus distance measured (y-axis). Be sure to carefully label axes. You might want to refer to the LabWrite website resource on making graphs: http://labwrite.ncsu.edu/res/res-homepage.htm. • Develop a calibration curve for your sensor using the Excel trendline function. This should yield an equation for the distance as a function of the sensor output. • Use your equation to estimate the size of objects A, B and C. Report the values with an estimate of each measurements variability (i.e. the size of A was found to be 10 ± 1 m).
Reporting Style Individual Memo Lab Report – Due at start of lab next week. Review guidelines, see me to discuss