First of all, we try to make LED light on (Digital Out) through we connect the Arduino with the computer.
Then we used the switch to control the LED on or off which is Digital In.
Tilt Sensor
We first use the sample code to feel the two direction when I move and tilt the sensor.
Actually the tilt sensor sense four direction in the Arduino. We rewrite the code and make the tilt sensor can sense four direction when I move the Arduino which are top, left, right and bottom.
Actually this may waste us some time to think about how to rewrite this code by using the if function. We need to calculate different situation such as top which means vol1 equal to 1 and vol2 equal to 0.

沒有留言:
張貼留言