diff --git a/public/assignments/week11.html b/public/assignments/week11.html index ce781dde2e941ee8cebbfede0c2f0944a03727d4..e5796f86d967d45926e800a3cfb95a5250cdc0df 100644 --- a/public/assignments/week11.html +++ b/public/assignments/week11.html @@ -54,7 +54,7 @@ <section> <h3>Group Assignment</h3> - <h4>Measuring Ultrasonic Distance Sensor (infos from <a href="https://components101.com/sensors/ultrasonic-sensor-working-pinout-datasheet" target="_blank">Components 101</a>)</h4> + <h4>Measuring HC-SR04 Ultrasonic sensor (infos from <a href="https://components101.com/sensors/ultrasonic-sensor-working-pinout-datasheet" target="_blank">Components 101</a>)</h4> <p>This sensor is a very popular sensor used in many applications where measuring distance or sensing objects are required.</p> @@ -81,6 +81,53 @@ </ul> + <h5>Test with the Ultrasonic Sensor (from <a href="https://projecthub.arduino.cc/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-7cabe1" target="_blank">Project Hub Arduino</a>)</h5> + + <pre> + <code> + /* + * HC-SR04 example sketch + * + * https://create.arduino.cc/projecthub/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-036380 + * + * by Isaac100 + */ + + //define the pins that Trig and Echo are connected to + const int trigPin = 2; + const int echoPin = 1; + + //declare 2 floats, duration and distance, which will hold the length of the sound wave and how far away the object is + float duration, distance; + + void setup() { + pinMode(trigPin, OUTPUT); //declare the Trig pin as an output + pinMode(echoPin, INPUT); //declare the Echo pin as an input + Serial.begin(9600); //start Serial communications + } + + void loop() { + digitalWrite(trigPin, LOW); //set the trigPin low for 2 microseconds just to make sure + delayMicroseconds(2); //that the pin in low first + digitalWrite(trigPin, HIGH); + delayMicroseconds(10); + digitalWrite(trigPin, LOW); + + duration = pulseIn(echoPin, HIGH); + distance = (duration*.0343)/2; + Serial.print("Pulse: "); + Serial.print(duration); + Serial.println("micro seconds"); + Serial.print("Distance: "); + Serial.print(distance); + Serial.println("cm"); + Serial.println(" "); + + delay(1000); + } + </code> + </pre> + <p>Link to our <a href="https://fabacademy.org/2024/labs/fabc/group-assignment/week011/" target="_blank">Group page</a></p> </section> @@ -147,7 +194,7 @@ <span class="object"> <video width="600" height="300" controls> - <source src="../images/...mp4" type="video/mp4"> + <source src="../images/humidity-and-temperature.mp4" type="video/mp4"> </video> </span> diff --git a/public/images/humidity-and-temperature.mp4 b/public/images/humidity-and-temperature.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e00ddf4a57cf9f0ec2cff9fecd566fe1275998fc Binary files /dev/null and b/public/images/humidity-and-temperature.mp4 differ