BMT M9 groep 7
/
halfgeleider
test halfgeleider
main.cpp@1:f2ec9d10960a, 2015-10-28 (annotated)
- Committer:
- Margreeth95
- Date:
- Wed Oct 28 20:10:38 2015 +0000
- Revision:
- 1:f2ec9d10960a
- Parent:
- 0:b8edd42c7819
Werkend script voor aansturing transistor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
laura94 | 0:b8edd42c7819 | 1 | #include "mbed.h" |
laura94 | 0:b8edd42c7819 | 2 | #include "HIDScope.h" |
laura94 | 0:b8edd42c7819 | 3 | |
Margreeth95 | 1:f2ec9d10960a | 4 | DigitalOut pin1(D4); |
Margreeth95 | 1:f2ec9d10960a | 5 | AnalogIn testpin(A0); |
Margreeth95 | 1:f2ec9d10960a | 6 | HIDScope scope (2); |
laura94 | 0:b8edd42c7819 | 7 | Ticker scope2; |
Margreeth95 | 1:f2ec9d10960a | 8 | Serial pc(USBTX, USBRX); |
laura94 | 0:b8edd42c7819 | 9 | |
laura94 | 0:b8edd42c7819 | 10 | void ScopeSend() |
laura94 | 0:b8edd42c7819 | 11 | { |
laura94 | 0:b8edd42c7819 | 12 | scope.set(0, pin1); |
Margreeth95 | 1:f2ec9d10960a | 13 | scope.set(1, testpin); |
laura94 | 0:b8edd42c7819 | 14 | scope.send(); |
laura94 | 0:b8edd42c7819 | 15 | } |
laura94 | 0:b8edd42c7819 | 16 | |
laura94 | 0:b8edd42c7819 | 17 | int main() |
laura94 | 0:b8edd42c7819 | 18 | { |
Margreeth95 | 1:f2ec9d10960a | 19 | pc.baud(115200); |
Margreeth95 | 1:f2ec9d10960a | 20 | scope2.attach(&ScopeSend, 0.002); |
Margreeth95 | 1:f2ec9d10960a | 21 | |
laura94 | 0:b8edd42c7819 | 22 | while (true) |
laura94 | 0:b8edd42c7819 | 23 | { |
Margreeth95 | 1:f2ec9d10960a | 24 | char c = pc.getc(); |
laura94 | 0:b8edd42c7819 | 25 | |
Margreeth95 | 1:f2ec9d10960a | 26 | if (c == 'f') |
laura94 | 0:b8edd42c7819 | 27 | { |
Margreeth95 | 1:f2ec9d10960a | 28 | pin1 = (1); |
Margreeth95 | 1:f2ec9d10960a | 29 | wait (2); |
Margreeth95 | 1:f2ec9d10960a | 30 | pin1 = (0); |
Margreeth95 | 1:f2ec9d10960a | 31 | wait(1); |
Margreeth95 | 1:f2ec9d10960a | 32 | } |
laura94 | 0:b8edd42c7819 | 33 | |
laura94 | 0:b8edd42c7819 | 34 | else |
laura94 | 0:b8edd42c7819 | 35 | { |
Margreeth95 | 1:f2ec9d10960a | 36 | pin1 = (0); |
Margreeth95 | 1:f2ec9d10960a | 37 | } |
laura94 | 0:b8edd42c7819 | 38 | } |
laura94 | 0:b8edd42c7819 | 39 | |
Margreeth95 | 1:f2ec9d10960a | 40 | } |