RAPPAHANNOCK COMMUNITY COLLEGE STEM CAMP
  • Home
  • Health-STEM Coding Camp
    • PreAcademy prep
    • Day 1: Basics and Lights >
      • Multicolor LED
      • Button Control
    • Day 2: Ultrasound >
      • Ultrasound Health Lesson
      • Supplement Melody
      • Supplement: Servo >
        • Potentiometer and Motors
        • 2 servo control
    • Day 3: Measuring Pulse >
      • How the body absorbs light
      • OLED Screen Basics >
        • Scrolling Screen Graph
    • Day 4 Making an ECG/EKG! >
      • ECG Health Lesson
      • Pictures to OLED
      • BPM on OLED
    • Day 5: Finishing up/Show >
      • CO2 Sensor
      • IR Light Proximity Sensor
  • 3D Design Camp
    • Prep
    • Day 1: 2D design
    • Day 2: 3D design basics
    • Day 3: Constraints
    • Day 4: Designing a Rocket
    • Day 5: Finishing, launching rockets
  • The Teachers
  • Archive
    • Pictures from prior years
    • 2021 STEM Camp (HS) >
      • The Teachers (2021)
      • PreAcademy prep
      • Day 1: Basics, Lights, and Temperature Sensor >
        • Day 1 Supplement: Measure Temperature
        • Day 1 Supplement: IR Temp Sensor
        • Day 1 Supplement: Identifying Resistors
        • Supplement: Controlling Buttons
        • Supplement: Controlling A Servo
      • Day 2: Measuring Pulse >
        • How the body absorbs light
        • Day 2 Supplement: IR Light Proximity Sensor
        • Day 2 Supplement: Motion Sensor
        • Code to start later on plotter
      • Day 3 Supplement: OLED Screen Basics >
        • Display Screen Temperature
        • IR Temp Sensor And Screen
        • Scrolling Screen Graph
      • Day 4: Finishing up/Show >
        • Pictures to OLED
        • BPM Pulse Sensor
        • Multimeter
    • 2021 STEM Camp (MS) >
      • Home (2021)
      • PreAcademy prep
      • Day 1: Basics, Lights, and Temperature Sensor >
        • Day 1 Supplement: Identifying Resistors
        • Day 1 Supplement: Measure Temperature
        • Day 1 Supplement: IR Light Proximity Sensor
      • Day 2: Ultrasound >
        • Day 2 Supplement: IR Temp Sensor
        • Day 2 Supplement: Controlling A Servo
      • Day 3: Measuring Pulse >
        • Day 3 Supplement: Motion Sensor
      • Day 4: OLED Screen Basics >
        • Temperature Screen Display
        • IR Temp Sensor And Screen
      • Day 5 Friday: Finishing up/Show
    • 2020 STEM Camp >
      • Home (2020)
      • The 2020 Teachers
      • PreAcademy prep
      • Day 1 Monday: Basics and Lights >
        • Day 1 Supplement Activity
      • Day 2 Tuesday: Servos >
        • Day 2 (Suppliment Activities)
      • Day 3 Wednesday: Making an ECG/EKG! >
        • Day 3 (Supplement Page)
      • Day 4 Thursday: Controlling Servos with EMG >
        • Day 4 Supplemental Activity
      • Day 5 Friday: Finishing up/Show >
        • Unused lessons/content
    • 2018 Lessons >
      • Day 1: Basic Coding
      • Day 2: Motors
      • Day 3: Build Robot Claw
      • Day 4: Saving Positions
      • Day 5: Presentations
    • 2017 Camp >
      • Day 1 (Monday)
      • Day 2: Multicolor LED and Keypad
      • Day 3: Servo and Keypad
      • Day 4: Multiple Motors/Stepper Motor
      • Day 5: Presentations
    • Pictures archive for lessons (some graphic images)
  • Contact Us!

Materials for this activity: 


Ultrasound Sensor
Picture
Jumper Wires
Picture
Arduino and USB Connector
Picture

These are for part 2

LEDs 
Picture
Buzzer
Picture
Breadboard
Picture

What is Ultrasound?

Picture
Picture
Picture
Several animals send out high-frequency sound that reflects off of other objects. A sound that is a higher pitch than humans can hear is called ultrasound. They then sense their own reflected sound when it comes back. The loudness and time it takes to come back depends on the distance to the object. 

Ultrasound sensor wiring and coding basics

Wire up your ultrasonic sensor like this picture. 

VCC is connected to the 5V Arduino pin 
Trig is connected to Arduino pin 3 
Echo is connected to Arduino pin 2 
Gnd is connected to an Arduino GND pin
Picture
Now that you have it wired, you are ready to type in the example code. 
Picture
Here is the code with descriptions of what each line does. 
Picture

Verify and upload the code to the board


Test it: Serial Monitor

After you upload it to board, see if it works. The text for how far away objects are from the ultrasound sensor is being sent to the serial monitor. To see that, you have to open the monitor by clicking its button. Here is where that button is and what the monitor looks like. 
Picture
Picture

Making the Arduino Light Up if you get to close

We will now add a little bit to our code so that when you get closer than three feet to something, a light will turn on. Three feet is 91 centimeters, we need that number later. You can pick a different difference if you want. Every foot is about 30.5 cm. 

To do this, we have to add what is called a condition. This can be done with an "if/else" statement. 
Here is an example of an if/else we can add. 
Picture
Put this right after the last code's Serial Prints. This makes the light turn on if distances are between 0 and 91 cm, otherwise the light is off. 
We also need to define the LED's location and to define that pin would as an output. Add that to the ultrasound code following this example. 
Picture

Example Wiring

Full Example Code

The only thing we are adding is the LED to GND and pin 13. Depending on the color, you will need to add a resistor. The 220 or 330 Ohm resistor works well for Red or Yellow. Ask your teacher about how to do this if you need to. 
Picture
Picture

Verify and Upload Code to the Board, Does it Work?  

Is the code working, what is happening? Ask your teacher for help if you need it. 

Trying the Buzzer

If you got your light to shine when you got too close to the sensor, then you can do the same thing with the buzzer instead.

Replace the light with a buzzer and see if it now buzzes when you get too close! 

After that works, use your breadboard by connecting a wire to GND to - and pin 13 to the + rail. Then you can plug as many lights and buzzers in parallel to the breadboard rail. See if you can control multiple things at once with the ultrasound sensor. Remember to use resistors for the lights. 
Picture

This lesson was inspired by a Dr.Duino lesson: ​ www.drduino.com

hackaday.com/2020/04/09/ultrasonic-sensor-helps-you-enforce-social-distancing/
Picture
Proudly powered by Weebly
  • Home
  • Health-STEM Coding Camp
    • PreAcademy prep
    • Day 1: Basics and Lights >
      • Multicolor LED
      • Button Control
    • Day 2: Ultrasound >
      • Ultrasound Health Lesson
      • Supplement Melody
      • Supplement: Servo >
        • Potentiometer and Motors
        • 2 servo control
    • Day 3: Measuring Pulse >
      • How the body absorbs light
      • OLED Screen Basics >
        • Scrolling Screen Graph
    • Day 4 Making an ECG/EKG! >
      • ECG Health Lesson
      • Pictures to OLED
      • BPM on OLED
    • Day 5: Finishing up/Show >
      • CO2 Sensor
      • IR Light Proximity Sensor
  • 3D Design Camp
    • Prep
    • Day 1: 2D design
    • Day 2: 3D design basics
    • Day 3: Constraints
    • Day 4: Designing a Rocket
    • Day 5: Finishing, launching rockets
  • The Teachers
  • Archive
    • Pictures from prior years
    • 2021 STEM Camp (HS) >
      • The Teachers (2021)
      • PreAcademy prep
      • Day 1: Basics, Lights, and Temperature Sensor >
        • Day 1 Supplement: Measure Temperature
        • Day 1 Supplement: IR Temp Sensor
        • Day 1 Supplement: Identifying Resistors
        • Supplement: Controlling Buttons
        • Supplement: Controlling A Servo
      • Day 2: Measuring Pulse >
        • How the body absorbs light
        • Day 2 Supplement: IR Light Proximity Sensor
        • Day 2 Supplement: Motion Sensor
        • Code to start later on plotter
      • Day 3 Supplement: OLED Screen Basics >
        • Display Screen Temperature
        • IR Temp Sensor And Screen
        • Scrolling Screen Graph
      • Day 4: Finishing up/Show >
        • Pictures to OLED
        • BPM Pulse Sensor
        • Multimeter
    • 2021 STEM Camp (MS) >
      • Home (2021)
      • PreAcademy prep
      • Day 1: Basics, Lights, and Temperature Sensor >
        • Day 1 Supplement: Identifying Resistors
        • Day 1 Supplement: Measure Temperature
        • Day 1 Supplement: IR Light Proximity Sensor
      • Day 2: Ultrasound >
        • Day 2 Supplement: IR Temp Sensor
        • Day 2 Supplement: Controlling A Servo
      • Day 3: Measuring Pulse >
        • Day 3 Supplement: Motion Sensor
      • Day 4: OLED Screen Basics >
        • Temperature Screen Display
        • IR Temp Sensor And Screen
      • Day 5 Friday: Finishing up/Show
    • 2020 STEM Camp >
      • Home (2020)
      • The 2020 Teachers
      • PreAcademy prep
      • Day 1 Monday: Basics and Lights >
        • Day 1 Supplement Activity
      • Day 2 Tuesday: Servos >
        • Day 2 (Suppliment Activities)
      • Day 3 Wednesday: Making an ECG/EKG! >
        • Day 3 (Supplement Page)
      • Day 4 Thursday: Controlling Servos with EMG >
        • Day 4 Supplemental Activity
      • Day 5 Friday: Finishing up/Show >
        • Unused lessons/content
    • 2018 Lessons >
      • Day 1: Basic Coding
      • Day 2: Motors
      • Day 3: Build Robot Claw
      • Day 4: Saving Positions
      • Day 5: Presentations
    • 2017 Camp >
      • Day 1 (Monday)
      • Day 2: Multicolor LED and Keypad
      • Day 3: Servo and Keypad
      • Day 4: Multiple Motors/Stepper Motor
      • Day 5: Presentations
    • Pictures archive for lessons (some graphic images)
  • Contact Us!