This time, I worked with Jessica to build a circuit that can control the movement of a servo by using a lighter sensor sensing the light. In our ideal situation, the “fan” on the servo should turn, for a big or small angle according to the brightness the sensor sensed.
We connected the servo to the Arduino according to this picture (except that we changed the analog output pin into 3).
And we also connected the light sensor to the breadboard as well as the Arduino according to this picture.
After this, we went to the Arduino software and used the sample-servo-knob code, and we changed some numbers to our circuit accordingly. Then I found the code for the light sensor and combined these two codes together. However, at first, the servo didn’t turn differently according to different brightness. And for the second time, the servo turned like it’s crazy.
However, we tried multiple ways to fix this, we checked the code, and then we found some useless codes that come with the sample and some numbers haven’t been changed accordingly. After we fixed that, we played the code again. The fan was reacting accordingly, but in a really tiny range, and the difference between strong lighting and darkness was very vague. After asking LA presented, we found that it was because for the lines:
servo.write(val);
delay(500);
servo.write(val);
delay(500);
we should change the third line into “servo.write(-val);” for the servo to obtain a bigger turning angle. And after we changed this, it worked.
Here is my code:
/* Controlling a servo position using a potentiometer (variable resistor) by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> modified on 8 Nov 2013 by Scott Fitzgerald http://www.arduino.cc/en/Tutorial/Knob */ #include <Servo.h> Servo servo; int potpin = A1; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin; const int Vresistor=A1; int potval; void setup() { Serial.begin(9600); servo.attach(3); // attaches the servo on pin 9 to the servo object } void loop() { val=analogRead(A1); val=map(val, 0, 1023, 0,180); potval=analogRead(Vresistor); Serial.print("light"); Serial.println(potval); servo.write(val); delay(500); servo.write(-val); delay(500); // waits for the servo to get there }
Here is my circuit:
Question1: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 assembled a light sensor with a servo that turns a fan, fast or slow according to the brightness. I think it can be turned into a light-sensing air-conditioner. We can polish the system to sense daylight instead of indoor lights. So that when the sun is shining, which leads to the rise of temperature, the fan will spin fast to cool the temperature. And when the sunlight declines, the fan will slow down accordingly. Everyone can use it. It’s environmental-friendly and convenient too for it all functions automatically.
Question2:Code is often compared to following a recipe or tutorial. Why do you think that is?
I think it’s a vivid metaphor. For recipe and tutorial mean something you can follow and use in order to achieve the result you want, that’s what codes do. Certain codes serve certain needs, and by choosing the proper code can help achieve the exact result you are looking forward to. So I do agree with this comparison.
Question3: 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?
Computer has already integrated in our daily lives. It provides a lot of convenience to us, for example, we no longer need to go into books to look for a certain reference, instead, we can do it simply by looking it up online, which saves a lot of time. Also, by having computer, it’s a lot more easier for us to keep in touch with friends and families. We don’t need to physically see them to greet them or to have conversations. However, it is not always a good thing. The decline of meeting friends and families physically does harm to the relationship to some extend. Also, with computer, computer games especially, people tend to avoid offline contacts, and that is really harmful to people’s social abilities.