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.
main.cpp@0:cd61b18cdfbd, 2021-12-15 (annotated)
- Committer:
- jim2022
- Date:
- Wed Dec 15 10:14:59 2021 +0000
- Revision:
- 0:cd61b18cdfbd
LFB erstes MBED Beispiel
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jim2022 | 0:cd61b18cdfbd | 1 | /* mbed Microcontroller Library |
| jim2022 | 0:cd61b18cdfbd | 2 | * Copyright (c) 2019 ARM Limited |
| jim2022 | 0:cd61b18cdfbd | 3 | * SPDX-License-Identifier: Apache-2.0 |
| jim2022 | 0:cd61b18cdfbd | 4 | */ |
| jim2022 | 0:cd61b18cdfbd | 5 | |
| jim2022 | 0:cd61b18cdfbd | 6 | #include "mbed.h" |
| jim2022 | 0:cd61b18cdfbd | 7 | #include "platform/mbed_thread.h" |
| jim2022 | 0:cd61b18cdfbd | 8 | #include "LCD.h" |
| jim2022 | 0:cd61b18cdfbd | 9 | |
| jim2022 | 0:cd61b18cdfbd | 10 | |
| jim2022 | 0:cd61b18cdfbd | 11 | // Blinking rate in milliseconds |
| jim2022 | 0:cd61b18cdfbd | 12 | #define BLINKING_RATE_MS 500 |
| jim2022 | 0:cd61b18cdfbd | 13 | |
| jim2022 | 0:cd61b18cdfbd | 14 | DigitalOut statusled(PC_0); |
| jim2022 | 0:cd61b18cdfbd | 15 | PortOut dieUebrigen(PortC,0b11111110); |
| jim2022 | 0:cd61b18cdfbd | 16 | PortIn schalterchen(PortB,0b11111111); |
| jim2022 | 0:cd61b18cdfbd | 17 | InterruptIn taste(PA_1); |
| jim2022 | 0:cd61b18cdfbd | 18 | AnalogIn poti(PA_0); |
| jim2022 | 0:cd61b18cdfbd | 19 | lcd meinLCD; |
| jim2022 | 0:cd61b18cdfbd | 20 | |
| jim2022 | 0:cd61b18cdfbd | 21 | void isr() |
| jim2022 | 0:cd61b18cdfbd | 22 | { |
| jim2022 | 0:cd61b18cdfbd | 23 | statusled=0; |
| jim2022 | 0:cd61b18cdfbd | 24 | } |
| jim2022 | 0:cd61b18cdfbd | 25 | |
| jim2022 | 0:cd61b18cdfbd | 26 | int main() |
| jim2022 | 0:cd61b18cdfbd | 27 | { |
| jim2022 | 0:cd61b18cdfbd | 28 | // Initialise the digital pin LED1 as an output |
| jim2022 | 0:cd61b18cdfbd | 29 | int zaehler=0; |
| jim2022 | 0:cd61b18cdfbd | 30 | float x; |
| jim2022 | 0:cd61b18cdfbd | 31 | DigitalOut led(LED1); |
| jim2022 | 0:cd61b18cdfbd | 32 | taste.mode(PullDown); |
| jim2022 | 0:cd61b18cdfbd | 33 | taste.rise(&isr); |
| jim2022 | 0:cd61b18cdfbd | 34 | taste.enable_irq(); |
| jim2022 | 0:cd61b18cdfbd | 35 | __enable_irq(); |
| jim2022 | 0:cd61b18cdfbd | 36 | meinLCD.clear(); |
| jim2022 | 0:cd61b18cdfbd | 37 | meinLCD.cursorpos(0x40); |
| jim2022 | 0:cd61b18cdfbd | 38 | meinLCD.printf("Hallo Welt"); |
| jim2022 | 0:cd61b18cdfbd | 39 | statusled=1; |
| jim2022 | 0:cd61b18cdfbd | 40 | schalterchen.mode(PullDown); |
| jim2022 | 0:cd61b18cdfbd | 41 | while (true) { |
| jim2022 | 0:cd61b18cdfbd | 42 | dieUebrigen=schalterchen; |
| jim2022 | 0:cd61b18cdfbd | 43 | led = !led; |
| jim2022 | 0:cd61b18cdfbd | 44 | zaehler++; |
| jim2022 | 0:cd61b18cdfbd | 45 | if (poti>0.5) statusled=1; |
| jim2022 | 0:cd61b18cdfbd | 46 | else statusled=0; |
| jim2022 | 0:cd61b18cdfbd | 47 | x=poti; |
| jim2022 | 0:cd61b18cdfbd | 48 | meinLCD.cursorpos(0); |
| jim2022 | 0:cd61b18cdfbd | 49 | meinLCD.printf("Z= %d, poti=%f ",zaehler,x); |
| jim2022 | 0:cd61b18cdfbd | 50 | //if (taste) statusled=0; |
| jim2022 | 0:cd61b18cdfbd | 51 | thread_sleep_for(BLINKING_RATE_MS); |
| jim2022 | 0:cd61b18cdfbd | 52 | } |
| jim2022 | 0:cd61b18cdfbd | 53 | } |