![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
3.2.4
Dependencies: mbed
main.cpp@0:a7425af6fdde, 2017-09-12 (annotated)
- Committer:
- olemh88
- Date:
- Tue Sep 12 12:12:43 2017 +0000
- Revision:
- 0:a7425af6fdde
3.2.4;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
olemh88 | 0:a7425af6fdde | 1 | #include "mbed.h" |
olemh88 | 0:a7425af6fdde | 2 | |
olemh88 | 0:a7425af6fdde | 3 | DigitalOut Led1(LED1); |
olemh88 | 0:a7425af6fdde | 4 | DigitalOut Led4(LED4); |
olemh88 | 0:a7425af6fdde | 5 | |
olemh88 | 0:a7425af6fdde | 6 | Serial pc(USBTX, USBRX); |
olemh88 | 0:a7425af6fdde | 7 | int x = 0; |
olemh88 | 0:a7425af6fdde | 8 | int pulser; |
olemh88 | 0:a7425af6fdde | 9 | int ms; |
olemh88 | 0:a7425af6fdde | 10 | int LED; |
olemh88 | 0:a7425af6fdde | 11 | |
olemh88 | 0:a7425af6fdde | 12 | int main() |
olemh88 | 0:a7425af6fdde | 13 | { |
olemh88 | 0:a7425af6fdde | 14 | while(1) { |
olemh88 | 0:a7425af6fdde | 15 | int z = Led1; |
olemh88 | 0:a7425af6fdde | 16 | int y = Led4; |
olemh88 | 0:a7425af6fdde | 17 | z = 1; |
olemh88 | 0:a7425af6fdde | 18 | y = 4; |
olemh88 | 0:a7425af6fdde | 19 | pc.printf("Skriv inn antall pulser: "); |
olemh88 | 0:a7425af6fdde | 20 | pc.scanf("%d", &pulser); |
olemh88 | 0:a7425af6fdde | 21 | pc.printf("Skriv inn antall ms: "); |
olemh88 | 0:a7425af6fdde | 22 | pc.scanf("%d", &ms); |
olemh88 | 0:a7425af6fdde | 23 | pc.printf("Velg hvilken diode som skal lyse Led1 eller led4: "); |
olemh88 | 0:a7425af6fdde | 24 | pc.scanf("%d", &LED); |
olemh88 | 0:a7425af6fdde | 25 | if ( LED != 1 || 4) { |
olemh88 | 0:a7425af6fdde | 26 | pc.printf("Prov igjen, feil valg\n"); |
olemh88 | 0:a7425af6fdde | 27 | } |
olemh88 | 0:a7425af6fdde | 28 | for(x = 0; x < pulser; x++) { |
olemh88 | 0:a7425af6fdde | 29 | if (LED == x) { |
olemh88 | 0:a7425af6fdde | 30 | Led1 = 1; |
olemh88 | 0:a7425af6fdde | 31 | wait_ms(ms); |
olemh88 | 0:a7425af6fdde | 32 | Led1 = 0; |
olemh88 | 0:a7425af6fdde | 33 | wait_ms(ms); |
olemh88 | 0:a7425af6fdde | 34 | } |
olemh88 | 0:a7425af6fdde | 35 | if (LED == y) { |
olemh88 | 0:a7425af6fdde | 36 | Led4 = 1; |
olemh88 | 0:a7425af6fdde | 37 | wait_ms(ms); |
olemh88 | 0:a7425af6fdde | 38 | Led4 = 0; |
olemh88 | 0:a7425af6fdde | 39 | wait_ms(ms); |
olemh88 | 0:a7425af6fdde | 40 | } |
olemh88 | 0:a7425af6fdde | 41 | } |
olemh88 | 0:a7425af6fdde | 42 | |
olemh88 | 0:a7425af6fdde | 43 | } |
olemh88 | 0:a7425af6fdde | 44 | } |