Categories
Assignments

Lab 2. Sensors

This lab has four parts. First, you’ll learn about libraries and how to open your serial monitor. Then, you’ll work with two new sensors: temperature/humidity and distance. Next, you’ll link sensing and response with the distance sensor and a buzzer. Lastly, you’ll look around the internet for other types of sensors—which sensors are you most interested in?

1. Follow Lesson 1, Add Libraries and Open Serial Monitor.

2. Follow the exercise for Lesson 11, DHT11 Temperature and Humidity Sensor. Note that at the top of the code you’re including the library with the statement “#include <dht_nonblocking.h>”. This statement allows you to access functions made for this sensor.

3. Open the serial monitor and watch the data stabilize. Put your hand over it and watch it change. (Or you could do something else to make it change — put an ice pack on it, what else?). Make a video of this serial monitor scrolling, show you are changing the environment, and show the data change in the serial monitor. (1 point)

4. Do Lesson 10, Ultrasonic Sensor Module.

5. Do Lesson 7, Passive Buzzer. In this code, there is an array, which is something you may not have seen before. The array is called melody and it stores 8 integers. The first integer in the array is at position 0, or is said to have an index value of 0. To access the note stored at position 0 you would use the term “melody[0].” Spend some time looking at the for loop. What’s happening here?

6. Create a new sketch that pulls together the ultrasonic distance sensor and the passive buzzer. Make the buzzer buzz if you pass a distance threshold. Submit your code (2 points), a picture of the wired board (2 point), and a video of it working (2 points). Be sure your code is clean, well commented, has a descriptive header, and cites all sources (as described in Lab 1).

  • Tip 1. It might be helpful to start with a BareMinimum sketch (under File>Examples>01.Basics), and then copy and paste in the elements of the Ultrasonic and Passive buzzer sketches that are relevant.
  • Tip 2. if, else if, else might be useful for you. (You’ve already seen if statements—this is a small extension of the concept.)

7. Create a wiring diagram for your distance sensor/passive buzzer project. (1 point) You can use circuito.io again or you can use another platform that offers more ability to customize your diagram. Fritzing is my favorite (look under Canvas > Files > Resources for a free older version). You can also use Illustrator or another drawing app — it doesn’t have to be made in a circuit-based program.

8. Search the internet for more Arduino sensors. You may want to start by scrolling through Adafruit. Find a sensor that you would be interested in using with Arduino. (Note that a lot of them are on breakout boards — what is a breakout board?) Submit a short (approximately 2 sentence) description of your sensor and a link to it. (2 points)

9. Respond to everything that’s followed by (__ points)—found in steps 3, 6, 7, and 8. Please ensure your Arduino sketch does not have any symbols (other than underscores) in the path name. Submit the pictures and answers to questions in one PDF. Post your pdf, code, and video to Canvas under Lab 2.

Leave a Reply

Your email address will not be published. Required fields are marked *