Physical computing

Physical computing week3: Labs!

I have a question for the labs. I know that analog input should range from 0-1023, and the analog output should range from 0-255. I don't know the reason why. I suppose it has something to do with the bit and byte, but I don'd know it clearly. -----Oh, I know the reason now. Because the analog input takes up 10 bits memory, the 10th power of 2 is 1024.

During the labs, I made two mistakes.

The first one is my servo motor didn't work. I checked the circuits and check the program for several times, but the motor just didn't work. And I asked a second-year student for help. She told me before I use the motor in my program, I should test the motor alone, using the example code in Arduino to see if it works. It turns out my motor is broken, so I changed it, it works. Thanks my classmate!

The second problem is I did not import the pitches.h library. When I compile the code, Arduino can not recognize the "Note" and the pitches.h. So I looked up in the Arduino website, and found out I should import the pitches.h myself, by adding a new tab and copy the pitches.h code in it. The link about how to import pitches.h is here.

1. Lab: Servo motor control

Here's my code.

lab1

 

 

 

 

 

 

 

 

 

 

 

 

Here's a video:

[embed]https://vimeo.com/106985065[/embed]

2. Lab: Tone output

here's my code.

屏幕快照 2014-09-20 下午9.14.19

[embed]https://vimeo.com/106985067[/embed]

I imported the pitches.h to make a little piece of music.

屏幕快照 2014-09-20 下午9.13.54

https://vimeo.com/106985068

 

I didn't find the force sensor, so I replaced them with flex sensors. to touch each sensor to make different note.

屏幕快照 2014-09-20 下午10.25.50

https://vimeo.com/106985066