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:2ef3f0a3ce31, 2020-12-01 (annotated)
- Committer:
- javiervicente
- Date:
- Tue Dec 01 12:20:10 2020 +0000
- Revision:
- 0:2ef3f0a3ce31
- Child:
- 1:52b7ac862f35
Stepper
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
javiervicente | 0:2ef3f0a3ce31 | 1 | #include "mbed.h" |
javiervicente | 0:2ef3f0a3ce31 | 2 | |
javiervicente | 0:2ef3f0a3ce31 | 3 | Serial pc(USBTX, USBRX); // tx, rx |
javiervicente | 0:2ef3f0a3ce31 | 4 | |
javiervicente | 0:2ef3f0a3ce31 | 5 | |
javiervicente | 0:2ef3f0a3ce31 | 6 | DigitalOut led(LED1); |
javiervicente | 0:2ef3f0a3ce31 | 7 | DigitalOut step(D2); |
javiervicente | 0:2ef3f0a3ce31 | 8 | DigitalOut dir(D3); |
javiervicente | 0:2ef3f0a3ce31 | 9 | DigitalOut enable(D4); |
javiervicente | 0:2ef3f0a3ce31 | 10 | |
javiervicente | 0:2ef3f0a3ce31 | 11 | #define DATA_PIN D4 |
javiervicente | 0:2ef3f0a3ce31 | 12 | |
javiervicente | 0:2ef3f0a3ce31 | 13 | DS1820 probe(DATA_PIN); |
javiervicente | 0:2ef3f0a3ce31 | 14 | |
javiervicente | 0:2ef3f0a3ce31 | 15 | int main() |
javiervicente | 0:2ef3f0a3ce31 | 16 | { |
javiervicente | 0:2ef3f0a3ce31 | 17 | pc.baud(115200); |
javiervicente | 0:2ef3f0a3ce31 | 18 | enable=1; |
javiervicente | 0:2ef3f0a3ce31 | 19 | wait(1.0); |
javiervicente | 0:2ef3f0a3ce31 | 20 | while(1) { |
javiervicente | 0:2ef3f0a3ce31 | 21 | dir=1; |
javiervicente | 0:2ef3f0a3ce31 | 22 | for(int n=0; n<4000; n++) { |
javiervicente | 0:2ef3f0a3ce31 | 23 | step=1; |
javiervicente | 0:2ef3f0a3ce31 | 24 | wait_us(100); |
javiervicente | 0:2ef3f0a3ce31 | 25 | step=0; |
javiervicente | 0:2ef3f0a3ce31 | 26 | wait_us(900); |
javiervicente | 0:2ef3f0a3ce31 | 27 | } |
javiervicente | 0:2ef3f0a3ce31 | 28 | wait(2); |
javiervicente | 0:2ef3f0a3ce31 | 29 | dir=0; |
javiervicente | 0:2ef3f0a3ce31 | 30 | for(int n=0; n<4000; n++) { |
javiervicente | 0:2ef3f0a3ce31 | 31 | step=1; |
javiervicente | 0:2ef3f0a3ce31 | 32 | wait_us(100); |
javiervicente | 0:2ef3f0a3ce31 | 33 | step=0; |
javiervicente | 0:2ef3f0a3ce31 | 34 | wait_us(900); |
javiervicente | 0:2ef3f0a3ce31 | 35 | } |
javiervicente | 0:2ef3f0a3ce31 | 36 | led = !led; |
javiervicente | 0:2ef3f0a3ce31 | 37 | wait(2); |
javiervicente | 0:2ef3f0a3ce31 | 38 | } |
javiervicente | 0:2ef3f0a3ce31 | 39 | } |
javiervicente | 0:2ef3f0a3ce31 | 40 | |
javiervicente | 0:2ef3f0a3ce31 | 41 |