Week 2
Digital and Analog Input and Output
The things I have:
![](https://freight.cargo.site/t/original/i/db3de4bf8b2737109952005853d1ca7854a05c907bc8821af6f6be54e5eb54c4/IMG_3852.jpg)
![](https://freight.cargo.site/t/original/i/6c608cc75a16212e20f02e17b0dcdeee3b327c24365b5a6b3d1db8aeec6e6c5f/IMG_3850.jpg)
![](https://freight.cargo.site/t/original/i/74113da166242502b410eec01ef7cd33ae37b54c878223d1161ae87077f66289/IMG_3851.jpg)
![](https://freight.cargo.site/t/original/i/d6d23b3f6f7d8b1906e7659cb2570063237f64dc2ef551c13db945b51d525800/IMG_3849.jpg)
![](https://freight.cargo.site/t/original/i/e02f4e58350cead8d873eac83bd81bdea3ed10663c3d3193db12189375803baa/IMG_3886.jpg)
![](https://freight.cargo.site/t/original/i/331212cd2df70de6ad2c81a862c13e851537a5c3539b7f0fa37e3ad47740426b/IMG_3914.jpg)
![](https://freight.cargo.site/t/original/i/aa4ff2611363c3f1efdd3fe49c2f559602adbac63a986263b68bd1759ea05a1a/IMG_4243.jpg)
Force sensor
![](https://freight.cargo.site/t/original/i/0f7dd39c4724de4de6b12009bcf57463fcf1fb0f3d34d2d92fabc28bd1531483/IMG_4307.jpg)
Speaker
![](https://freight.cargo.site/t/original/i/22d9d1561a631c42ce759c492e4e2a49a5f7d810ce2db8883da5ffdb7b8fc71f/IMG_4315.jpg)
MOFSET
![](https://freight.cargo.site/t/original/i/b2939aaeb7f6b362463c11f4476611b2f91a5339b7a9eb8f23614bcfea9f5e0d/IMG_4316.jpg)
Right angle gear motor
![](https://freight.cargo.site/t/original/i/6d48bbe074403180ed4dc5c248fbf6184b3d9fd70c8f0736931dc7ce711bcc8a/Digital-AnalogInput_bb.png)
![](https://freight.cargo.site/t/original/i/95c02245da0ff995c6e3dbc246f9adc861857ef848487ccfdc5511c3a6714684/forcesensor.gif)
![](https://freight.cargo.site/t/original/i/76b2dde75b80c868161de1c382988831c1c0ad9d07876aca5a5789eb9d156b1a/2021-09-18-23.29.41.png)
![](https://freight.cargo.site/t/original/i/70b873d7664b2f1d71fb4d88ab3d4b17d1ae7dffe747bc50109b63f613acd668/DigitalAnalog.gif)
![](https://freight.cargo.site/t/original/i/1d37c36410375c4965102265ecc4311d498bf5ffbdd9b836faaaca9562428576/tone.png)
![](https://freight.cargo.site/t/original/i/aa3563ee4fd325cbb93f2e54ea55399a0f60f2e209b0eed6523a0e1701781056/2021-09-19-20.44.12.png)
![](https://freight.cargo.site/t/original/i/d094127527a390156038a9d811812b445c53f401d3a59f5a6d50b1b4a41ed2d2/IMG_4306.jpg)
I tested the force sensor, potentiometer for analog input and pushbutton for the digital input. Then I added the speaker to illustrate the tone floating with potentiometer.
![](https://freight.cargo.site/t/original/i/24514dc9244de7e0902e6813490f1942ebdf42f0a844c302d74ffff81c2f7730/servo.png)
![](https://freight.cargo.site/t/original/i/b28ac785abc582d9507c082aa84a342a1bc3d5603776a36399e39e7b594b2470/2021-09-19-21.13.25.png)
![](https://freight.cargo.site/t/original/i/a8518c9d9fd58d569e9e611944324367449f1e798c1930a8fe3bdfa322341dec/Servo.gif)
I read the analog output of force sensor and map the value to the rotation state of microservo.
![](https://freight.cargo.site/t/original/i/e641cff48516d41bf7e421d97c12683b28453fc02c9e2116e1278ad91c6f2d18/Hightcurrent_bb.png)
![](https://freight.cargo.site/t/original/i/c2fe5e0ce8dec45cf7b2315d5ffe38942bb267e267da9e38b0e1198067e83333/2021-09-19-22.29.33.png)
![](https://freight.cargo.site/t/original/i/a5c1fd1489cf395d5ec246edd81ccfe13f19cbde9f2fb4ca130640a7c8097a19/DCmotor.gif)
I use the potentiometer to control the right angle gear motor of 12V to experiment with the power supply other than laptop. The tansistor can only by TIP120 or MOFSET, I have used the 2N 3906 and the motor can’t work until I temporarily charge it at full voltage.
Sensor Change Detection
![](https://freight.cargo.site/t/original/i/952267f03375925d754234ed473dd5415d259e16b54c7c37c7954c642c8e6306/2021-09-20-10.29.37.png)
![](https://freight.cargo.site/t/original/i/8a10c98b702762cd9980c97b93ec75a05560165fb00a7a5b5cffedb09aa10934/readbuttonchange.gif)
![](https://freight.cargo.site/t/original/i/28fce3101eeb0417a29f3bed64c01ce73d186fffa42bddbd4920e965b02173eb/2021-09-20-10.34.07.png)
![](https://freight.cargo.site/t/original/i/e132f46bcb86b15904aa65808fa9e0321b56087a4d656c9ac0d7d3c3bb05e8d4/buttoncounting.gif)
![](https://freight.cargo.site/t/original/i/d9e332946e3e83ed5f831237933e89d0c92e46d3faf4e186d150d17370814b39/2021-09-20-11.08.10.png)
![](https://freight.cargo.site/t/original/i/1becf5d1fe7e7ff8acf07118b210ed6a9a72dabf88a0208189435e140ccec841/pressdetection.gif)
![](https://freight.cargo.site/t/original/i/bcf2aeb61cfb1ac9dc681ac9a324550614292e0b19074dcd9b72a31811d44af3/2021-09-20-11.19.16.png)
![](https://freight.cargo.site/t/original/i/ef244d86c11dae37a4e2f0707121f539f56df89c51e2c2265a3f825a0f0b2cbf/forcethreshold.gif)
![](https://freight.cargo.site/t/original/i/39669f0a9c4775b5678c6b4d1fb373d03ccd1722ab14af54ef738b44ce57d2c0/2021-09-20-12.14.30.png)
![](https://freight.cargo.site/t/original/i/e97914fdce22930918c97ebf9aadbaf30d4a387cdb92c21329c7115db21d390d/forcePeak.gif)
1. Detect button state changes
2. Count button presses
3. Long press, Short press
4. Sensor threshold detection
5. Detecting a peak
2. Count button presses
3. Long press, Short press
4. Sensor threshold detection
5. Detecting a peak