Section outline


    • Turn in All but the Arduino and USB
      Get LCD, Ultrasonic Rangefinder and 4 patch cables

      Demo: Ultrasonic Acoustic Levitation

      Video Explaining Ultrasonic Levitation

      Ultrasonic Range Finders

       



      Install the HC-SR04 Rangefinder
      Note the Pin assignments on the HC-SR04
       
      4 Wires:
       
      HC-SR04 to Arduino
       
      1) Vcc to 5v
      2) Trig to Pin A5 
      3) Echo to Pin A4
      4) Gnd to Gnd

      Copy the program below into a blank Arduino sketch.

      Save as HC-SR04-LCD

      #include <LiquidCrystal.h>
      #define trigPin A5
      #define echoPin A4
      LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
      void setup()
      {
        pinMode(trigPin, OUTPUT);
        pinMode(echoPin, INPUT);
        lcd.begin(16, 2);              // start the library
        lcd.setCursor(0, 1);
        lcd.print("        HC-SR04         ");
      }
      void loop()
      {
      lcd.setCursor(0, 0);    
          int duration, distance;
          digitalWrite(trigPin, HIGH);
          delayMicroseconds(1000);
          digitalWrite(trigPin, LOW);
          duration = pulseIn(echoPin, HIGH);
          distance = (duration/2) / 29.1; 
              lcd.print(distance);
              lcd.print(" cm             ");
              delay (500); 
      }

      Upload the program
      Read distance on LCD Screen
       
      Activities:
      1) Set the HC-SR04 sensor 10 cm from a large flat surface. 
       
      Note the location of 0 cm on the sensor.
       
      (Front Edge?, at PC Board?, 1/2 way to PC Board?...)
       
       
      2) Measure 8 known distances and record sensor reading.
       
      Calculate % error = 100(a-e)/a where a = accepted, e = experimental
      3) What are the shortest and longest distances the Ultrasonic measures accurately?
      4) Are there surfaces that are "invisible" to the sensor?  (absorb the sound and give erroneous readings?)

      5) Extra Credit:
      Create a program to scroll an Appropriate message across the LCD display.

      :-)