Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:37a74423d68e, 2015-02-19 (annotated)
- Committer:
- Ty
- Date:
- Thu Feb 19 14:31:05 2015 +0000
- Revision:
- 0:37a74423d68e
proportional
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Ty | 0:37a74423d68e | 1 | #include "mbed.h" |
| Ty | 0:37a74423d68e | 2 | #include "Motor.h" |
| Ty | 0:37a74423d68e | 3 | Serial pc(USBTX,USBRX);//allows communication through the USB |
| Ty | 0:37a74423d68e | 4 | AnalogIn range(p19); |
| Ty | 0:37a74423d68e | 5 | float height; |
| Ty | 0:37a74423d68e | 6 | float rv; |
| Ty | 0:37a74423d68e | 7 | float dh; |
| Ty | 0:37a74423d68e | 8 | float ds; |
| Ty | 0:37a74423d68e | 9 | float er; |
| Ty | 0:37a74423d68e | 10 | float k=0.15; |
| Ty | 0:37a74423d68e | 11 | Motor m(p26, p29, p30); |
| Ty | 0:37a74423d68e | 12 | int main() |
| Ty | 0:37a74423d68e | 13 | { |
| Ty | 0:37a74423d68e | 14 | |
| Ty | 0:37a74423d68e | 15 | m.speed(0); |
| Ty | 0:37a74423d68e | 16 | while(1){ |
| Ty | 0:37a74423d68e | 17 | rv=range; |
| Ty | 0:37a74423d68e | 18 | height=(-75.7457492123552*pow(rv,2))+(90.6774745565381*rv)+(-4.00358328437282); |
| Ty | 0:37a74423d68e | 19 | pc.printf("%f,%f\n",rv,height); |
| Ty | 0:37a74423d68e | 20 | pc.printf("Enter desired height\n"); |
| Ty | 0:37a74423d68e | 21 | pc.scanf("%f",&dh); |
| Ty | 0:37a74423d68e | 22 | er=dh-height; |
| Ty | 0:37a74423d68e | 23 | ds=k*er; |
| Ty | 0:37a74423d68e | 24 | m.speed(ds); |
| Ty | 0:37a74423d68e | 25 | |
| Ty | 0:37a74423d68e | 26 | |
| Ty | 0:37a74423d68e | 27 | |
| Ty | 0:37a74423d68e | 28 | } |
| Ty | 0:37a74423d68e | 29 | } |