Recitation3: Johnny

A to Q1

The sensor I picked up is a joystick module. I intend to use it to assemble a circuit that can read the index on x_pin and y_pin so that the brightness of the LED can be controlled by them. To do that, I write the following codes and draw a diagram.

This is the physical picture of the circuit after finishing building it.

Here is my code to read the x_pin of the joystick to control the brightness of the LED.

const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = 0; // analog pin connected to X output
const int Y_pin = 1; // analog pin connected to Y output

int Sensorvalue=0;


void setup() {
  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  Serial.begin(9600);
}

void loop() {
  Serial.print("Switch:  ");
  Serial.print(digitalRead(SW_pin));
  Serial.print("\n");
  Serial.print("X-axis: ");

  Sensorvalue = analogRead(X_pin);

  Serial.print(Sensorvalue);
  Serial.print("\n");
  Serial.print("Y-axis: ");
  Serial.println(analogRead(Y_pin));
  Serial.print("\n\n");
  delay(500);
}

There is one more thing I want to add at the end of this circuit, which is a strange phenomenon. After noticing that for the joystick module, rather than analog read will range from 0 to 1023, it is actually in a smaller range of around 200 to around 800. While I try to use the map function to make the range in 0 and 255, a weird thing happens. When I push the button down, the x_pin will always be 255 and even I change the direction of the button, the stats remain the same. But referring back to the code, I don’t think there is a function there to stop the x_pin from changing. I asked one of the LA and she suggests that maybe the joystick itself has some inner problem. So she helps me to change one. But that one even turns out to be more ridiculous, the stats are even beyond 255, out of the range, which makes me very confused. I guess one of the reasons why the stats remain tobe 255 is that it indicates the status of the button is pushed. And that’s it, it will not give any feedback once the button is pushed down.

And thinking of the practical use of this sensor, I think companies like Microsoft and Sony will use it a lot. For me, I am a console game fan. I enjoy the games released on both platforms, Xbox and PS series. While the controller of these consoles has two or more joystick modules. They are used to help the player to control the game character’s direction and the direction of the whole screen. Personally speaking, I prefer these controllers using joysticks to keyboards because they are more convenient and the design is more ergonomic. Unlike keyboards, sometimes we will be bothered by the problem of not being able to press a certain key because of the size of our palm. So I think we keep really close to the use of the joystick module.

A to Q2

Yes, I agree with the point that reading codes are similar to following a recipe or a tutorial. One important thing about the property of the code is logic. If we follow the codes, we can easily tell the function of each part. For example, at the beginning of every coding is the definition part, which means that you have to define every variable used in this coding system. Next, these are the codes written to satisfy your demand. It is similar to the recipe or the tutorial because if you follow it step by step, the logical relationship between each one is very obvious and the whole process is easy to follow.

A to Q3

As far as concerned, the computer is an invention making human behavior more “freely”. Freedom is like a coin, has two sides, one is good and another one is bad. On one hand, we all agree that computers make our lives more easily. To be more precise on human behavior, it helps us to move or make decisions more logically. For instance when we run into an argument of which side is wrong. Instead of arguing with each other with no point but wasting time, we can turn on our computer and then uses it to generate a correct answer or another’s suggested answer on this topic. As a result, we have saved a lot of time here. It’s logical for us to put aside the dispute for now and then turn to others for help rather than stuck there for days. In this way, the computer is saving us time, enabling us to have more freedom to handle by ourselves. On the other hand, the invention od computer might crate many legal grey areas. We all have heard about the news that a hack has stolen millions of personal information from a huge company. In the past, without the help of the computer, it is almost an impossible mission because it’s hard for storing millions of information and it’s even harder to break into a place with so many security guards. But with the computer, we have the tool to do so. It gives us the freedom to conduct bad things as well as those good ones. In this way, I want to describe the computer as an amplifier, exposing the nature of human beings more clearly to us, providing us with an increased degree of freedom to do anything.

Leave a Reply

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