Mario Barisic
/
TINF_blinky_klase
29.9.2020
main.cpp@0:2e7c943c07a9, 2020-09-29 (annotated)
- Committer:
- shogu
- Date:
- Tue Sep 29 15:52:57 2020 +0000
- Revision:
- 0:2e7c943c07a9
prvi;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shogu | 0:2e7c943c07a9 | 1 | #include "mbed.h" |
shogu | 0:2e7c943c07a9 | 2 | |
shogu | 0:2e7c943c07a9 | 3 | //DigitalOut myled(LED1); |
shogu | 0:2e7c943c07a9 | 4 | |
shogu | 0:2e7c943c07a9 | 5 | class MyLed { |
shogu | 0:2e7c943c07a9 | 6 | public: |
shogu | 0:2e7c943c07a9 | 7 | MyLed(PinName led) : _led(led) { |
shogu | 0:2e7c943c07a9 | 8 | _led = 1; |
shogu | 0:2e7c943c07a9 | 9 | } |
shogu | 0:2e7c943c07a9 | 10 | |
shogu | 0:2e7c943c07a9 | 11 | void ledOn(void) { |
shogu | 0:2e7c943c07a9 | 12 | _led = 1; |
shogu | 0:2e7c943c07a9 | 13 | wait_ms(500); |
shogu | 0:2e7c943c07a9 | 14 | } |
shogu | 0:2e7c943c07a9 | 15 | |
shogu | 0:2e7c943c07a9 | 16 | MyLed() {}; |
shogu | 0:2e7c943c07a9 | 17 | |
shogu | 0:2e7c943c07a9 | 18 | private: |
shogu | 0:2e7c943c07a9 | 19 | DigitalOut _led; |
shogu | 0:2e7c943c07a9 | 20 | }; |
shogu | 0:2e7c943c07a9 | 21 | |
shogu | 0:2e7c943c07a9 | 22 | MyLed myLed(LED1); |
shogu | 0:2e7c943c07a9 | 23 | MyLed myLed2(LED2); |
shogu | 0:2e7c943c07a9 | 24 | |
shogu | 0:2e7c943c07a9 | 25 | int main() { |
shogu | 0:2e7c943c07a9 | 26 | while(1) { |
shogu | 0:2e7c943c07a9 | 27 | myLed.ledOn(); |
shogu | 0:2e7c943c07a9 | 28 | myLed.ledOff(); |
shogu | 0:2e7c943c07a9 | 29 | myLed2.ledOn(); |
shogu | 0:2e7c943c07a9 | 30 | myLed2.ledOff(); |
shogu | 0:2e7c943c07a9 | 31 | } |
shogu | 0:2e7c943c07a9 | 32 | } |