Recitation 3-Sensors (Professor Marcela)

Yitong Xu

22 Feb 2018

Professor Marcela


Ellen Ying and I decided to assemble a device that can change the light of LEDs as it moves. Thus, we chose the 3-Axis Analog Accelerometer in the Recitation class since both of us are quite interested in the change of speed. To make our tentative plan work, along with 3-AxisAnalog Accelerometer, we choose wires, 3 LEDs and a 220-ohm resistor as the material for this circuit. We referred to the circuit we used in the last recitation since the structure is quite similar. We started coding with the help of the sources attached to the recitation requirements as well as some examples in the Arduino. Since sources differ from our plan, we add more lines and changed according to the circuit we have. We used “analog writes” at first and refined the range but it didn’t work. Since the circuit is linked correctly, it must be the problem of our code. With the help of the professor nearby, we managed to let it work after changing the “analog writes” to “digital writes”. However, we still spent met some problems in defining the suitable range to control the LEDs since the data of x, y, z displayed in the Arduino kept changing randomly. Eventually, we conquered the obstacle after trying various numbers. I learned from this experience that how the input and output can be connected in many different ways and how important it is to understand the meaning behind every code so that we can better understand the working principle which makes it easier for us to deal with every project. I’m happy to see my improvements in making the circuit and coding, but I still have a long way to go.

Reviewing this experience, I found that the experience building this circuit is quite similar to a special bicycle which can produce electricity and power the light bulb while people are riding it. If I have the chance to continue experimenting it, I would try the design shown in the picture below:



  • How is writing code similar to making dumplings?

The input in computer coding is similar to the kitchen taking an order. The preparations for making such as getting meat and vegetables is similar to the preparations in the computer coding. For example, we often first define some certain words or integers when we are coding. Besides, every step between the input and output are working separating based on the preparation which is similar to making dumplings. And the serving of the dumplings can be regarded as the output in computer coding.

  • As Manovich describes in the Language of New Media, the influence of computers on new media is clear. In what ways do you believe the computer influences our human behaviors?

With the rapid development and the wide coverage of the use of computers in modern lives, it is no doubt that human behaviors have been changed accordingly. Paper products including books, newspapers and even papers have been threatened by the use of computers since people are more willing to use computers, to take notes, to read and to write. People don’t remember information very often since we know that it can be easily found somewhere on the computer. People seldom met and talk to each other in real life since using emails and WeChat have become our way to communicate with each other. We do not go out very often since we can order everything we need from the computer. Though it is true that the use of computer help us conquer the obstacles of time and space, people have become so dependent to the computer that we, including me sometimes, believe that our life cannot function properly without it.


 // these constants describe the pins. They won't change:
const int xpin = A0;                  // x-axis of the accelerometer
const int ypin = A1;                  // y-axis
const int zpin = A2;                  // z-axis (only on 3-axis models)

int LED1 = 8;
int LED2 = 12;
int LED3 = 13;

int bright1 = 0;
int bright2 = 0;
int bright3 = 0;

const int buzzer = 9; //buzzer to arduino pin 9
void setup() {
  // initialize the serial communications:
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output

void loop() {
  // print the sensor values:
  // print a tab between values:
  // print a tab between values:
  // delay before next reading:

  if (analogRead(zpin) < 308) {
    digitalWrite(LED1, HIGH);
  } else {
    digitalWrite(LED1, LOW);

   if ( analogRead(zpin) < 308) {
    digitalWrite(LED2, HIGH);
  } else {
    digitalWrite(LED2, LOW);

   if ( analogRead(zpin) < 308) {
    digitalWrite(LED3, HIGH);
  } else {
    digitalWrite(LED3, LOW);
  if ( analogRead(zpin) < 308) {
       digitalWrite(buzzer, HIGH);

One thought on “Recitation 3-Sensors (Professor Marcela)

Leave a Reply