Recitation 3: Sensors

Circuit 1: Vibration Sensor

      

Here are my code:

const int ledPin = 13;      // LED connected to digital pin 13
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 100;  // threshold value to decide when the detected sound is a knock or not


int sensorReading = 0;      // variable to store the value read from the sensor pin
int ledState = LOW;         // variable used to store the last LED status, to toggle the light

void setup() {
  pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
  Serial.begin(9600);       // use the serial port
}

void loop() {
  // read the sensor and store it in the variable sensorReading:
  sensorReading = analogRead(knockSensor);

  // if the sensor reading is greater than the threshold:
  if (sensorReading >= threshold) {
    // toggle the status of the ledPin:
    ledState = !ledState;
    // update the LED pin itself:
    digitalWrite(ledPin, ledState);
    // send the string "Knock!" back to the computer, followed by newline
    Serial.println("Knock!");
  }
  delay(100);  // delay to avoid overloading the serial port buffer
}

Using this circuit, we could turn on and off the LED by patting the sensor. While we patted it, the computer would also reflect “Knock!” through the serial monitor. I think the process of patting and turning on the LED is the input and output part, which make up an interaction.

 

Circuit 2: Ultrasonic Ranger

And here are the code:

#define echoPin 2 // attach pin D2 Arduino to pin Echo of HC-SR04
#define trigPin 3 //attach pin D3 Arduino to pin Trig of HC-SR04

// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement

void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
  Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
  Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
  Serial.println("with Arduino UNO R3");
}
void loop() {
  // Clears the trigPin condition
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
  // Displays the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
}

We could use this ultrasonic ranger to measure the length. Beside this simple circuit, we also tried to use this sensor to control the brightness of the LED, but we failed to build it.

 

Question 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?

Although I failed to make it, I would like to combine the ultrasonic ranger with a speaker or a LED. I design that while the ultrasonic ranger finds that the distance ahead is getting closer and closer, the speaker should be louder and the LED should be lighter.

I think these kind of facilities can be used by some unable people, such as the blind people. As blind people don’t have sight, this equipment can be their “sight” sensor. For example, when the blind person is walking on the street, he can judge his distance around him by paying attention on whether the speaker’s sound is getting louder or not.

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

If I didn’t misunderstand this sentence, I think it is talking about that code has some basic logics and examples which can be used frequently with some small changes.

I think this phenomenon is normal, for we can consider code into a digital language. Learning it is same like learning any other kind of languages. We can use the basic rules of this language to create beautiful articles, and so does coding. After follow the recipe or tutorial and use them in flexible ways, we will be familiar with the basic rules of the code language, and then it will be possible for us to create more complicated project.

Question 3: In The 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?

First of all, computers bring a lot of convenience for human. People can travel or watch movies without going out, but just through a screen and they can attach to almost everything in this world.

In this way, it brings more possibilities for people. Some people publish videos to make their lives; some people use the internet to develop the industry of social network; some people build up their life-long interests while they wandering on computer…

However, computers can also bring disadvantages. For example, more and more teenagers are addicted to playing computer games and have less chances to build links with natural world. It may influence their abilities to make friends and use normal languages. Not only teenagers, but also the adults’ lives can be influenced notably. They have to catch up with the technology developing pace so that they can live more convenient.

All of these examples show that human is more and more dependent on computer such high-technology things. We can’t tell whether it’s good or not, but we really should pay attention to how we can live harmonious with the technological creations.

Leave a Reply

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