Recitation 006: Sensors by Stephanie Anderson

Introduction: on with ultra and buzzer

This recitation on this delightful Sunday afternoon focused on the introduction to sensors: incorporating them into circuits, coding with them, and practically using their function.

Objectives:

  1.  Create a working circuit with a sensor 
  2. Develop code that allows you to interact with the sensor and thus affect a LED, buzzer, or Servo 

Materials (as listed on the IMA website):

1 * Arduino Uno
1 * USB A to B cable
1 * breadboard
1 * buzzer
1* AKA Ultrasonic Sensor OR  HC-SR04
A handful of jumper cables

Process:

Today I worked with Emily on this recitation and we chose to use an ultrasonic sensor. We began with pulling up the suggested schematic for incorporating just the ultrasonic sensor and then made sure it was working properly

This image requires alt text, but the alt text is currently blank. Either add alt text or mark the image as decorative. Circuit with just the Ultrasonic

Emily then proceeded to incorporate the buzzer into our circuit while I created the code by using the foundation of the ‘ping’ code and adding in some lines with tone() in order to get an action from the buzzer because of the interaction with the ultrasonic sensor.

.
The Circuit diagram for the circuit with the sensor and buzzer

I found this website to be particularly helpful when I was refreshing myself on how to write tone()

Use tone() with Arduino for an Easy Way to Make Noise

Here is the code we came up with:

int sound = 7;
const int pingPin = 7;

void setup() {

Serial.begin(9600);
}
void loop() {

long duration, inches, cm;

pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);

inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

Serial.print(inches);
Serial.print(“in, “);
Serial.print(cm);
Serial.print(“cm”);
Serial.println();

delay(100);

if (cm >= 20)
{
tone(sound, 1000, 1000);
delay(1000);

}
else {
tone(sound, 2000, 1000);
delay(1000);
}

}

long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}

Here is a link to the final working product. I narrate in the video, but you can see Emily’s hand moving closer and farther away from the sensor and the resulting change in tone from the buzzer due to her interaction with the ultrasonic sensor.

https://drive.google.com/file/d/1Bdc9exdpjyWZxH6BdQTjNo0KxiO1H4dZ/view?usp=sharing

Reflection:

The process of creating the code probably took a little longer than necessary because I originally was trying to build one from scratch and I was merging the wrong two files meaning I was trying to merge ‘ping’ with ‘toneMelody’ which was just extra. I did have a lot of fun with this recitation, however, because this was our first day writing our own code!

Questions:

1 )What did you intend to assemble in the recitation exercise? If your sensor/actuator combination were to be used for pragmatic purposes, who would use it, why would they use it, and how could it be used?

We used the ultrasonic sensor and saw how the values changed when we would move objects at certain distances away from it.  Because we built this sensor in a circuit with a buzzer, this technology could be used to deter intruders into a property. For example, if you had the ultrasonic sensor pointed out into the distance in the other direction of the door of the complex –  and when someone comes within a certain distance of the house – then the buzzer will go off; thus, deterring the intruder.

2) Code is often compared to following a recipe or tutorial.  Why do you think that is?

Code is defiantly like a recipe because it tells the computer at a specific time when to do what, where to do it, how to do it, and for how long. Without the specific steps completed in the recipe, then the final product would not be finished, just as is the case with code.

3) In Language of New Media, Manovich describes the influence of computers on new media. In what ways do you believe the computer influences our human behaviors?

Manovich brings up a interesting point on page 16 of his writing where he synthesizes that by the end of the 20th century, the problem was not how to create a new media object such as an image, but rather where to find the object that already exists. While we have the seemingly infinite knowledge of the world at our very fingertips (granted, when we are connected to wifi), we are not always the most productive of people and – instead of creating our own media – we  search for that which has already been made, thus, making us lazy.  In a way, with the support of Manovich’s implied messages, I agree and concur that computers negatively influence our human behavior. 

Leave a Reply