kohacraft Lab
/
kc_sample_mbed_motor
スイッチを押すと2秒間モーターが回るプログラムです。
main.cpp@0:ea8160d85d16, 2015-12-28 (annotated)
- Committer:
- kohacraft
- Date:
- Mon Dec 28 03:42:55 2015 +0000
- Revision:
- 0:ea8160d85d16
ver1.0;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kohacraft | 0:ea8160d85d16 | 1 | #include "mbed.h" |
kohacraft | 0:ea8160d85d16 | 2 | |
kohacraft | 0:ea8160d85d16 | 3 | DigitalOut myled(LED1); |
kohacraft | 0:ea8160d85d16 | 4 | DigitalIn sw(dp28); |
kohacraft | 0:ea8160d85d16 | 5 | |
kohacraft | 0:ea8160d85d16 | 6 | int main() { |
kohacraft | 0:ea8160d85d16 | 7 | while(1) { |
kohacraft | 0:ea8160d85d16 | 8 | myled = 0; |
kohacraft | 0:ea8160d85d16 | 9 | if( sw == 1 ) |
kohacraft | 0:ea8160d85d16 | 10 | { |
kohacraft | 0:ea8160d85d16 | 11 | myled = 1; |
kohacraft | 0:ea8160d85d16 | 12 | wait(2); |
kohacraft | 0:ea8160d85d16 | 13 | myled = 0; |
kohacraft | 0:ea8160d85d16 | 14 | } |
kohacraft | 0:ea8160d85d16 | 15 | } |
kohacraft | 0:ea8160d85d16 | 16 | } |