Bjørn André Nyrud
/
oving_4_oppgave_1_3
øving_4_oppgave_1_3
main.cpp@0:40e1d38c59f5, 2017-09-19 (annotated)
- Committer:
- Banyrud
- Date:
- Tue Sep 19 12:15:20 2017 +0000
- Revision:
- 0:40e1d38c59f5
?ving_4_oppgave_1_3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Banyrud | 0:40e1d38c59f5 | 1 | #include "mbed.h" |
Banyrud | 0:40e1d38c59f5 | 2 | BusOut bar(p21,p22,p23,p24,p25,p26,p27,p28,p29,p30); |
Banyrud | 0:40e1d38c59f5 | 3 | AnalogIn pot(p20); |
Banyrud | 0:40e1d38c59f5 | 4 | Serial pc(USBTX, USBRX); |
Banyrud | 0:40e1d38c59f5 | 5 | int main() |
Banyrud | 0:40e1d38c59f5 | 6 | { |
Banyrud | 0:40e1d38c59f5 | 7 | while(1) { |
Banyrud | 0:40e1d38c59f5 | 8 | int v; |
Banyrud | 0:40e1d38c59f5 | 9 | int pow = 1; |
Banyrud | 0:40e1d38c59f5 | 10 | v = int(pot*10.5); |
Banyrud | 0:40e1d38c59f5 | 11 | for(int i = 0; i < v; i++) { |
Banyrud | 0:40e1d38c59f5 | 12 | pow*=2; |
Banyrud | 0:40e1d38c59f5 | 13 | } |
Banyrud | 0:40e1d38c59f5 | 14 | bar=pow-1; |
Banyrud | 0:40e1d38c59f5 | 15 | wait (0.1); |
Banyrud | 0:40e1d38c59f5 | 16 | } |
Banyrud | 0:40e1d38c59f5 | 17 | } |