top of page

My final project recording 3

Updated: Jan 12, 2021




1. Thinking the structure


These are my first two ideas on the structure, but both of them have some loopholes.


My reference structure


After I discover a mirror's structure.

This structure inspired me. I can use the same structure to install two servers on both sides of the fruit tray. This structure allows the server to drive the fruit tray to tilt.





2. Test the circuit on the breadboard.


There are two experiments I need test.

a. the circuit of 'force sensitive resistor controls

b. the circuit of 'the tilt sensor to control the buzzer'



Record the iterative process of code

-T1


Record:This code includes my two circuits (‘pressure sensor control servo’ and

‘tilt sensor control buzzer’). I use the timer function as a timer. The remindTime is

used to record the number of times the system rotates to define the time of 5 seconds, 10 seconds, and 15 seconds ...


Learn: Use the timer function to control the angle change of the pressure sensor control server within a certain period of time, and sort out the logic of timer control time.




-T2


Record:After I finished the initial preparation of the code, I thought about how to install the components on the fruit tray. The key is how the ‘rotation of the server’ drives the ‘tilt sensor’ to tilt.This should be two independent circuits.I can change

the position of the tilt sensor through the rotation of the server through the physical structure. Then the tilt sensor can be connected in series with the buzzer. I removed the touchPin and tiltPin parts of the code, leaving only the timer function to define the circuit of the ‘pressure sensor control server’, which made my code structure more concise.


Learn: According to the actual physical structure, optimize the instructions to simplify the writing of the code.




-T3


Record:In order to verify whether the tilt sensor and buzzer can be physically structured independent of the pressure sensor and servo code, I chose to test the circuit of the ‘tilt sensor controls the buzzer’.When I tested this simple series circuit for the first time, it failed... I checked the circuit.I can connect these two components in series without digital pins.


Learn: The tilt sensor does not need to write a separate code to control its time, because the tilt sensor only displays HIGH when it is turned to 90, and it is open

when it is turned 10 degrees or 20 degrees.




-T4


Record:remindtime=10, the parameter is too small, and the program running too

fast is displayed through the serial monitor.Then I changed remindtime to = 50000,

the server still turned 90 degrees immediately when the program was running.




-T5


Record:Presumably, the value in the if condition is not suitable. Change the parameters of the if conditional sentence and change the minimum pressure

value of the pressure sensor.

It is found that when remindtime = 30000, the timer takes about 60 seconds.




-T6


Record:Continue to test, remindtime=100, the server turns 90 degrees within 1 second, and the stay is too short.remindtime=3000, the server rotates to 90 degrees

in about 10 seconds.

New problem - The server went directly from 0 degrees to 90 degrees within the prescribed 30 seconds, and did not stay at 10 degrees at 5 seconds, nor did it stay at 20 degrees at 10 seconds.

The reason is speculated - it may be that 5s and 10s are too close, and the servo can't react.After changing the time in if several times, the problem is still not solved.

Try to + delay(100) in the time period of angle=10 and angle=20




-T7


Record:After adding delay(100), the server still changes from 0 degrees to 90 degrees in about 3 minutes.

New issue - After turning to 90 degrees, the server keeps shaking when pressure=0. Analyze the reason - it may be that the delay time is too short after the server has turned 90 degrees..

Eliminate - the problem of directly turning from 0 degrees to 90 degrees-replace the 90 degree conditions with 20 degrees and observe whether the server stops after turning directly to 20 degrees.

The result - still from 0 degrees directly to 20 degrees, there is no change from 0-10 to 20 degrees.

Solution - try the new function millis




-T8


Record:Change the code. the program directly uses the delay function.

Result - the server can go from 0-10-20-90 degrees

Problem - When the pressure > 0, the servo rotates cyclically.

Solution - Extend the delay, otherwise it will keep looping.

Problem - only loop once. After the delay ends, no matter whether the pressure is greater than 0, the server will turn from 90 degrees back to 10 degrees, and it will continue to loop after the delay ends.

To be resolved - When pressure=0, the server immediately changes from 90 degrees to 0 degrees, and it is not affected by the time limit.





-T9


Record:

Solution - When pressure=0, the server immediately changes from 90 degrees to 0 degrees.

Problem - After removing the pressure on the pressure sensor and adding pressure, the servo no longer rotates.

Reason - The program can only loop once and needs to be uploaded again to run again.





-T10


Record:I reset the timer, this time there is no too complicated judgment.

Guess - The previous problem may be because the number of judgments was too many and the motor could not respond.

New problem - After adding the timer, the server changes directly from 0 degrees to 90 degrees.





Analog circuit on tinkercard


-1.



-2.





Successfully simulated the circuit on the breadboard


-a the circuit of 'force sensitive resistor controls server'



-b the circuit of 'the tilt sensor to control the buzzer'



-c 'a + b' the final circuit simulation





Comentários


bottom of page