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.
Dependencies: mbed
main.cpp@0:254a855b2bf5, 2019-02-21 (annotated)
- Committer:
- patter23
- Date:
- Thu Feb 21 17:20:33 2019 +0000
- Revision:
- 0:254a855b2bf5
Test
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| patter23 | 0:254a855b2bf5 | 1 | //incudes the API header file |
| patter23 | 0:254a855b2bf5 | 2 | #include "mbed.h" |
| patter23 | 0:254a855b2bf5 | 3 | |
| patter23 | 0:254a855b2bf5 | 4 | //Connected on board led1 to digitial out |
| patter23 | 0:254a855b2bf5 | 5 | DigitalOut myled(LED1); //onboard led1 |
| patter23 | 0:254a855b2bf5 | 6 | DigitalOut yourled(LED2); //onboard led2 |
| patter23 | 0:254a855b2bf5 | 7 | DigitalOut outLed1(p20); //breadboard led - pin 20 |
| patter23 | 0:254a855b2bf5 | 8 | DigitalOut outLed2(p21); //breadboard led - pin 21 |
| patter23 | 0:254a855b2bf5 | 9 | DigitalOut SquareWave(p19); //squarewave output - pin 7 |
| patter23 | 0:254a855b2bf5 | 10 | |
| patter23 | 0:254a855b2bf5 | 11 | //main loop area |
| patter23 | 0:254a855b2bf5 | 12 | int main() { |
| patter23 | 0:254a855b2bf5 | 13 | while(1) { |
| patter23 | 0:254a855b2bf5 | 14 | /* |
| patter23 | 0:254a855b2bf5 | 15 | // ONBOARD LED 1 |
| patter23 | 0:254a855b2bf5 | 16 | myled = 1; //sets the led high |
| patter23 | 0:254a855b2bf5 | 17 | wait(0.1); //wait for 0.1 seconds |
| patter23 | 0:254a855b2bf5 | 18 | myled.write(0); //sets the led low - different way to write this |
| patter23 | 0:254a855b2bf5 | 19 | wait(0.5); //wait for 0.5 seconds |
| patter23 | 0:254a855b2bf5 | 20 | |
| patter23 | 0:254a855b2bf5 | 21 | // ONBOARD LED 2 |
| patter23 | 0:254a855b2bf5 | 22 | yourled = 1; //sets the led high |
| patter23 | 0:254a855b2bf5 | 23 | wait(0.1); //wait for 0.1 seconds |
| patter23 | 0:254a855b2bf5 | 24 | yourled.write(0); //sets the led low - different way to write this |
| patter23 | 0:254a855b2bf5 | 25 | wait(0.5); //wait for 0.5 seconds |
| patter23 | 0:254a855b2bf5 | 26 | |
| patter23 | 0:254a855b2bf5 | 27 | |
| patter23 | 0:254a855b2bf5 | 28 | // BREADBOARD LED 1 - PIN 20 |
| patter23 | 0:254a855b2bf5 | 29 | outLed1 = 1; //sets the led high |
| patter23 | 0:254a855b2bf5 | 30 | wait(0.1); //wait for 0.1 seconds |
| patter23 | 0:254a855b2bf5 | 31 | outLed1.write(0); //sets the led low - different way to write this |
| patter23 | 0:254a855b2bf5 | 32 | wait(0.5); //wait for 0.5 seconds |
| patter23 | 0:254a855b2bf5 | 33 | |
| patter23 | 0:254a855b2bf5 | 34 | // BREADBOARD LED 1 - PIN 21 |
| patter23 | 0:254a855b2bf5 | 35 | outLed2 = 1; //sets the led high |
| patter23 | 0:254a855b2bf5 | 36 | wait(0.1); //wait for 0.1 seconds |
| patter23 | 0:254a855b2bf5 | 37 | outLed2.write(0); //sets the led low - different way to write this |
| patter23 | 0:254a855b2bf5 | 38 | wait(0.5); //wait for 0.5 seconds |
| patter23 | 0:254a855b2bf5 | 39 | */ |
| patter23 | 0:254a855b2bf5 | 40 | // SQUAREWAVE - PIN 19 |
| patter23 | 0:254a855b2bf5 | 41 | SquareWave = 1; //sets the output high |
| patter23 | 0:254a855b2bf5 | 42 | wait(.01); //wait for 10 ms |
| patter23 | 0:254a855b2bf5 | 43 | SquareWave.write(0); //sets the output low - different way to write this |
| patter23 | 0:254a855b2bf5 | 44 | wait(.01); //wait for 10 ms |
| patter23 | 0:254a855b2bf5 | 45 | |
| patter23 | 0:254a855b2bf5 | 46 | } |
| patter23 | 0:254a855b2bf5 | 47 | } |