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
Fork of Exercise6 by
main.cpp@3:6875cf4af4a1, 2020-02-24 (annotated)
- Committer:
- drewantech
- Date:
- Mon Feb 24 14:53:38 2020 +0000
- Revision:
- 3:6875cf4af4a1
- Parent:
- 2:20562827e8dd
Exercise 6
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| drewantech | 0:cb7457d7c822 | 1 | #include "mbed.h" |
| drewantech | 1:245bc5eb1bbe | 2 | /**************************************************************** |
| drewantech | 3:6875cf4af4a1 | 3 | In this exercise we will now get onto a new concept called PMW (pulse wirdth modulation) |
| drewantech | 3:6875cf4af4a1 | 4 | |
| drewantech | 3:6875cf4af4a1 | 5 | this is basicly the use of fast acting digital pins to simulate analoge outputs. |
| drewantech | 1:245bc5eb1bbe | 6 | |
| drewantech | 3:6875cf4af4a1 | 7 | for this example I would iniitally like you to play with the "wait();" function. |
| drewantech | 3:6875cf4af4a1 | 8 | The wait function can take float inputs and so can delay by fractions of a seconds |
| drewantech | 3:6875cf4af4a1 | 9 | |
| drewantech | 3:6875cf4af4a1 | 10 | write a function that turns on the led then waits a specific amount of time (the argument of the function) and then turns it off again. |
| drewantech | 3:6875cf4af4a1 | 11 | place this function only in the main. |
| drewantech | 1:245bc5eb1bbe | 12 | ***************************************************************/ |
| drewantech | 0:cb7457d7c822 | 13 | |
| drewantech | 1:245bc5eb1bbe | 14 | // these functions initializes the led pins and functions associated with them these are technically c++ but dont worry to much about this yet |
| drewantech | 1:245bc5eb1bbe | 15 | DigitalOut led1(D5); |
| drewantech | 1:245bc5eb1bbe | 16 | DigitalOut led2(D6); |
| drewantech | 1:245bc5eb1bbe | 17 | DigitalOut led3(D7); |
| drewantech | 1:245bc5eb1bbe | 18 | DigitalOut led4(D8); |
| drewantech | 1:245bc5eb1bbe | 19 | DigitalOut led5(D9); |
| drewantech | 1:245bc5eb1bbe | 20 | DigitalOut led6(D10); |
| drewantech | 1:245bc5eb1bbe | 21 | DigitalOut led7(D11); |
| drewantech | 1:245bc5eb1bbe | 22 | DigitalOut led8(D12); |
| drewantech | 0:cb7457d7c822 | 23 | |
| drewantech | 1:245bc5eb1bbe | 24 | // this is your main function and is where the code starts good luck! |
| drewantech | 0:cb7457d7c822 | 25 | int main() { |
| drewantech | 1:245bc5eb1bbe | 26 | |
| drewantech | 0:cb7457d7c822 | 27 | } |
