This shows you the differences between two versions of the page.
pm:prj2022:cstan:5 [2022/05/25 14:01] carlos_javier.del [Software Design] |
pm:prj2022:cstan:5 [2022/05/25 14:32] (current) carlos_javier.del [Concluzii] |
||
---|---|---|---|
Line 110: | Line 110: | ||
{{:pm:prj2022:cstan:psr10.png?200|}} | {{:pm:prj2022:cstan:psr10.png?200|}} | ||
+ | ***__CALCULATE DISTANCE OF OBJECTS__** | ||
+ | Once the sensor is ready, we can use it to calculate the distance. We do this with the function calculateDistance(). It is a particular function as it will return a value. This is done by putting at the end (or wherever you want) the reserved word return followed by the value you want to return. All code below the return is not executed, so be careful. In this case I return the calculated distance inside the function which is a float variable. | ||
+ | The pulseIn function detects just that, and returns the elapsed time in microseconds. For this reason, it must be converted to seconds by multiplying by 0.000001, which is the same as dividing by 1,000,000. With this information we can now apply the formula to calculate the distance as a function of time and speed. | ||
+ | |||
+ | {{:pm:prj2022:cstan:psr11.png?200|}} | ||
+ | |||
+ | ***__TRIGGER ALERTS__** | ||
+ | |||
+ | Once we have the distance calculated, we can decide whether we are in the situation to send an alert or not. Whenever the distance is below the first threshold (green LED threshold and the least restrictive), we will launch the corresponding visual and audible alert. | ||
+ | |||
+ | {{:pm:prj2022:cstan:psr12.png?200|}} | ||
+ | |||
+ | ***__FINAL CODE__** | ||
+ | |||
+ | {{:pm:prj2022:cstan:psr13.png?200|}} {{:pm:prj2022:cstan:psr14.png?200|}} {{:pm:prj2022:cstan:psr15.png?200|}} {{:pm:prj2022:cstan:psr16.png?200|}} | ||
</note> | </note> | ||
Line 119: | Line 134: | ||
</note> | </note> | ||
- | ===== Concluzii ===== | + | ===== Conclusions ===== |
+ | Testing the car sensor sensor car makes it easy for car drivers to park the car. | ||
===== Download ===== | ===== Download ===== | ||