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.
Fork of Lab3 by
Function.cpp@2:14bfd1fc2163, 2018-01-21 (annotated)
- Committer:
- Kaniiii
- Date:
- Sun Jan 21 21:59:04 2018 +0000
- Revision:
- 2:14bfd1fc2163
- Parent:
- 0:2270b7a3a8ad
Library for manipulating led light (includes a main with examples of how to use the program)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kaniiii | 0:2270b7a3a8ad | 1 | #include "Ka.h" |
Kaniiii | 0:2270b7a3a8ad | 2 | |
Kaniiii | 0:2270b7a3a8ad | 3 | |
Kaniiii | 0:2270b7a3a8ad | 4 | Ka::Ka() : m(LED0) |
Kaniiii | 0:2270b7a3a8ad | 5 | {} |
Kaniiii | 0:2270b7a3a8ad | 6 | void Ka::set_led0() |
Kaniiii | 0:2270b7a3a8ad | 7 | { |
Kaniiii | 0:2270b7a3a8ad | 8 | m = 1; |
Kaniiii | 0:2270b7a3a8ad | 9 | } |
Kaniiii | 0:2270b7a3a8ad | 10 | |
Kaniiii | 0:2270b7a3a8ad | 11 | void Ka::clear_led0() |
Kaniiii | 0:2270b7a3a8ad | 12 | { |
Kaniiii | 0:2270b7a3a8ad | 13 | m = 0; |
Kaniiii | 0:2270b7a3a8ad | 14 | } |
Kaniiii | 0:2270b7a3a8ad | 15 | void Ka::invert() |
Kaniiii | 0:2270b7a3a8ad | 16 | { |
Kaniiii | 0:2270b7a3a8ad | 17 | if (m==0){ |
Kaniiii | 0:2270b7a3a8ad | 18 | m=1; |
Kaniiii | 0:2270b7a3a8ad | 19 | } |
Kaniiii | 0:2270b7a3a8ad | 20 | else {m=0;} |
Kaniiii | 0:2270b7a3a8ad | 21 | } |
Kaniiii | 2:14bfd1fc2163 | 22 | void Ka::blinker (int a) |
Kaniiii | 0:2270b7a3a8ad | 23 | { |
Kaniiii | 0:2270b7a3a8ad | 24 | a=a+a; |
Kaniiii | 0:2270b7a3a8ad | 25 | for (int b = 0 ; b<a ; b++){ |
Kaniiii | 0:2270b7a3a8ad | 26 | if (b%2==0){ |
Kaniiii | 0:2270b7a3a8ad | 27 | m=1; |
Kaniiii | 0:2270b7a3a8ad | 28 | } |
Kaniiii | 0:2270b7a3a8ad | 29 | else { m=0; } |
Kaniiii | 0:2270b7a3a8ad | 30 | wait(1); |
Kaniiii | 0:2270b7a3a8ad | 31 | } |
Kaniiii | 0:2270b7a3a8ad | 32 | } |
Kaniiii | 0:2270b7a3a8ad | 33 | |
Kaniiii | 0:2270b7a3a8ad | 34 | |
Kaniiii | 0:2270b7a3a8ad | 35 |