I used infrared distance sensor to build the circuit. This is actually the same as what we’ve built in class but I think about where could it be used. Here’s the code:
#include <Servo.h> Servo myservo; int potpin = 0; int val; void setup() { myservo.attach(9); } void loop() { val = analogRead(potpin); val = map(val, 0, 1023, 0, 180); myservo.write(val); print(val); delay(15); } The video:
Question 1:
Actually I didn’t know how infrared distance sensor works exactly. I though it just change its output when something move in front of it (Now I know this is actually the function of light sensor: Output and electronic potential when there’s light and another when there’s no light). Now I know that the output of infrared distance sensor would constantly changing with the change of the distance of items in front of the sensor. I think this could be used as automatic garage gate. When the car get close to the gate, the sensor would receive the signal and another camera connected to computer would detect whether it is the right car. Then the door would gradually open as the car getting close.
Question 2:
According to the code, we can build our circuit (though sometimes these two should work together). For example, I set D9 as output. So when I’m building the circuit, I should make sure that I use output from D9, not others like D1,D2, … So the place where each pin should put is strictly confined by code or terrible thing would happen.
Question 3:
- Computer definitely brings much convenience to people’s life. Originally, it greatly increased the speed of calculating, saving a lot of times for people. And then, after the technology getting more advanced, people use computers to work (like us student) and for daily amusement like playing game and watching videos.
- But since the function of computer is so great, people might just get addicted to it. Not only their time is wasted, their health is also challenged because they are looking at the screen and sitting on the chair or sofa for too long.
Leave a Reply