potmeter motor aansturing
Dependencies: MODSERIAL mbed Project_script_encoder QEI
Fork of Project_script by
main.cpp@2:2f4444f1504d, 2018-09-11 (annotated)
- Committer:
- MarijkeZondag
- Date:
- Tue Sep 11 15:05:35 2018 +0000
- Revision:
- 2:2f4444f1504d
- Parent:
- 1:40470bc517f1
- Child:
- 3:a3ad58758696
Assignment 2c test;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:c8f15874531b | 1 | #include "mbed.h" |
vsluiter | 0:c8f15874531b | 2 | #include "MODSERIAL.h" |
vsluiter | 0:c8f15874531b | 3 | |
vsluiter | 0:c8f15874531b | 4 | DigitalOut myled(LED_GREEN); |
vsluiter | 0:c8f15874531b | 5 | MODSERIAL pc(USBTX, USBRX); |
MarijkeZondag | 2:2f4444f1504d | 6 | DigitalIn button(PTA4); |
vsluiter | 0:c8f15874531b | 7 | |
vsluiter | 0:c8f15874531b | 8 | int main() |
vsluiter | 0:c8f15874531b | 9 | { |
MarijkeZondag | 2:2f4444f1504d | 10 | char c; |
MarijkeZondag | 2:2f4444f1504d | 11 | c = pc.getc(); |
MarijkeZondag | 2:2f4444f1504d | 12 | |
vsluiter | 0:c8f15874531b | 13 | pc.baud(115200); |
Gijsvanoort | 1:40470bc517f1 | 14 | pc.printf("Hello World!\r\n"); |
vsluiter | 0:c8f15874531b | 15 | |
MarijkeZondag | 2:2f4444f1504d | 16 | while (true) |
MarijkeZondag | 2:2f4444f1504d | 17 | { |
MarijkeZondag | 2:2f4444f1504d | 18 | myled==1; |
MarijkeZondag | 2:2f4444f1504d | 19 | |
MarijkeZondag | 2:2f4444f1504d | 20 | if (button==0) |
MarijkeZondag | 2:2f4444f1504d | 21 | { |
MarijkeZondag | 2:2f4444f1504d | 22 | wait(0.5f); // wait a small period of time |
MarijkeZondag | 2:2f4444f1504d | 23 | pc.printf("%c \n",c); |
MarijkeZondag | 2:2f4444f1504d | 24 | myled = !myled; // toggle a led |
MarijkeZondag | 2:2f4444f1504d | 25 | } |
vsluiter | 0:c8f15874531b | 26 | } |
vsluiter | 0:c8f15874531b | 27 | } |