Example code stm32nucleof401re_00_blinkled
Dependencies: mbed-os
main.cpp@0:6d3e4f76ec5f, 2020-02-05 (annotated)
- Committer:
- perlatecnica
- Date:
- Wed Feb 05 16:56:45 2020 +0000
- Revision:
- 0:6d3e4f76ec5f
v1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
perlatecnica | 0:6d3e4f76ec5f | 1 | /* Copyright (c) 2019 Perlatecnica |
perlatecnica | 0:6d3e4f76ec5f | 2 | * |
perlatecnica | 0:6d3e4f76ec5f | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
perlatecnica | 0:6d3e4f76ec5f | 4 | * you may not use this file except in compliance with the License. |
perlatecnica | 0:6d3e4f76ec5f | 5 | * You may obtain a copy of the License at |
perlatecnica | 0:6d3e4f76ec5f | 6 | * |
perlatecnica | 0:6d3e4f76ec5f | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
perlatecnica | 0:6d3e4f76ec5f | 8 | * |
perlatecnica | 0:6d3e4f76ec5f | 9 | * Unless required by applicable law or agreed to in writing, software |
perlatecnica | 0:6d3e4f76ec5f | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
perlatecnica | 0:6d3e4f76ec5f | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
perlatecnica | 0:6d3e4f76ec5f | 12 | * See the License for the specific language governing permissions and |
perlatecnica | 0:6d3e4f76ec5f | 13 | * limitations under the License. |
perlatecnica | 0:6d3e4f76ec5f | 14 | */ |
perlatecnica | 0:6d3e4f76ec5f | 15 | |
perlatecnica | 0:6d3e4f76ec5f | 16 | /**************************************************** |
perlatecnica | 0:6d3e4f76ec5f | 17 | * RAPID PROTOTYPING WITH NUCLEO * |
perlatecnica | 0:6d3e4f76ec5f | 18 | * Example Code 00: Blink Led * |
perlatecnica | 0:6d3e4f76ec5f | 19 | * Author: Mauro D'Angelo * |
perlatecnica | 0:6d3e4f76ec5f | 20 | * Organization: Perlatecnica * |
perlatecnica | 0:6d3e4f76ec5f | 21 | *****************************************************/ |
perlatecnica | 0:6d3e4f76ec5f | 22 | |
perlatecnica | 0:6d3e4f76ec5f | 23 | #include "mbed.h" |
perlatecnica | 0:6d3e4f76ec5f | 24 | |
perlatecnica | 0:6d3e4f76ec5f | 25 | // It creates an instance of the DigitalOut class. |
perlatecnica | 0:6d3e4f76ec5f | 26 | // myled is the name of the variable (instance). |
perlatecnica | 0:6d3e4f76ec5f | 27 | // The instance shall 'point' to the pin LED1, that is the led on the board |
perlatecnica | 0:6d3e4f76ec5f | 28 | DigitalOut myled(LED1); |
perlatecnica | 0:6d3e4f76ec5f | 29 | |
perlatecnica | 0:6d3e4f76ec5f | 30 | // Entry point |
perlatecnica | 0:6d3e4f76ec5f | 31 | int main() { |
perlatecnica | 0:6d3e4f76ec5f | 32 | // Led blinking - The led is switched on and off |
perlatecnica | 0:6d3e4f76ec5f | 33 | while(1) { |
perlatecnica | 0:6d3e4f76ec5f | 34 | myled = 1; // The LED is ON |
perlatecnica | 0:6d3e4f76ec5f | 35 | wait(0.2); // Stop the program counter here and wait for 200 ms. In the meanwhile the led is on |
perlatecnica | 0:6d3e4f76ec5f | 36 | myled = 0; // Switch-off the LED |
perlatecnica | 0:6d3e4f76ec5f | 37 | wait(1.0); // Stop the program counter here and wait for 1 ms. In the meanwhile the led is off |
perlatecnica | 0:6d3e4f76ec5f | 38 | } |
perlatecnica | 0:6d3e4f76ec5f | 39 | } |
perlatecnica | 0:6d3e4f76ec5f | 40 | |
perlatecnica | 0:6d3e4f76ec5f | 41 | // EXERCISE: Modify the interval between the led status changing instructions |