![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
tes ir atas semua
Dependencies: mbed ADS1115 StepperMotor SRF05 TPA81new
SharpIR/SharpIR.cpp@49:d23d76689933, 2019-03-06 (annotated)
- Committer:
- hisyamfs
- Date:
- Wed Mar 06 13:17:10 2019 +0000
- Revision:
- 49:d23d76689933
- Parent:
- 14:207770fefedf
tes bisa semua, tanpa servo. uvtron nggak bisa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hisyamfs | 14:207770fefedf | 1 | #include "SharpIR.h" |
hisyamfs | 14:207770fefedf | 2 | |
hisyamfs | 14:207770fefedf | 3 | SharpIR::SharpIR(PinName apin) : _ain(apin), _a(def_a), _b(def_b) |
hisyamfs | 14:207770fefedf | 4 | { |
hisyamfs | 14:207770fefedf | 5 | } |
hisyamfs | 14:207770fefedf | 6 | |
hisyamfs | 14:207770fefedf | 7 | SharpIR::SharpIR(PinName apin, int a, float b) : _ain(apin), _a(a), _b(b) |
hisyamfs | 14:207770fefedf | 8 | { |
hisyamfs | 14:207770fefedf | 9 | } |
hisyamfs | 14:207770fefedf | 10 | |
hisyamfs | 14:207770fefedf | 11 | float SharpIR::read() |
hisyamfs | 14:207770fefedf | 12 | { |
hisyamfs | 14:207770fefedf | 13 | float meas = _ain.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
hisyamfs | 14:207770fefedf | 14 | meas = meas * 3300; // Change the value to be in the 0 to 3300 range |
hisyamfs | 14:207770fefedf | 15 | float dist = _a * pow(meas , _b); |
hisyamfs | 14:207770fefedf | 16 | return dist; |
hisyamfs | 14:207770fefedf | 17 | } |