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:ef259ff25554, 2019-10-18 (annotated)
- Committer:
- maxnagazumi
- Date:
- Fri Oct 18 09:49:47 2019 +0000
- Revision:
- 0:ef259ff25554
- Child:
- 1:9732c03b0de4
yo
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| maxnagazumi | 0:ef259ff25554 | 1 | #include "mbed.h" |
| maxnagazumi | 0:ef259ff25554 | 2 | #include "EC.h" //Encoderライブラリをインクルード |
| maxnagazumi | 0:ef259ff25554 | 3 | #include "SpeedController.h" //SpeedControlライブラリをインクルード |
| maxnagazumi | 0:ef259ff25554 | 4 | #define RESOLUTION 500 |
| maxnagazumi | 0:ef259ff25554 | 5 | |
| maxnagazumi | 0:ef259ff25554 | 6 | PwmOut f(PA_9); |
| maxnagazumi | 0:ef259ff25554 | 7 | PwmOut b(PA_10); |
| maxnagazumi | 0:ef259ff25554 | 8 | DigitalIn s(PB_7,PullUp); |
| maxnagazumi | 0:ef259ff25554 | 9 | |
| maxnagazumi | 0:ef259ff25554 | 10 | Ec4multi EC(PA_6,PA_7,RESOLUTION); |
| maxnagazumi | 0:ef259ff25554 | 11 | int main() |
| maxnagazumi | 0:ef259ff25554 | 12 | { |
| maxnagazumi | 0:ef259ff25554 | 13 | printf("%d\n",s.read()); |
| maxnagazumi | 0:ef259ff25554 | 14 | f.period_us(50); |
| maxnagazumi | 0:ef259ff25554 | 15 | b.period_us(50); |
| maxnagazumi | 0:ef259ff25554 | 16 | while(1) { |
| maxnagazumi | 0:ef259ff25554 | 17 | printf("omega=%f\r\n",EC.getOmega()); |
| maxnagazumi | 0:ef259ff25554 | 18 | wait(0.1); |
| maxnagazumi | 0:ef259ff25554 | 19 | f = 0.2; |
| maxnagazumi | 0:ef259ff25554 | 20 | if(s.read() ==0)break; |
| maxnagazumi | 0:ef259ff25554 | 21 | } |
| maxnagazumi | 0:ef259ff25554 | 22 | f=0; |
| maxnagazumi | 0:ef259ff25554 | 23 | b=0; |
| maxnagazumi | 0:ef259ff25554 | 24 | return 0; |
| maxnagazumi | 0:ef259ff25554 | 25 | } |