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@1:a5fcf4e7055a, 2015-10-07 (annotated)
- Committer:
- dwijaybane
- Date:
- Wed Oct 07 12:16:41 2015 +0000
- Revision:
- 1:a5fcf4e7055a
- Parent:
- 0:573d4c6e63ac
comments updated
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dwijaybane | 1:a5fcf4e7055a | 1 | #include "mbed.h" // Basic Library required for onchip peripherals |
| dwijaybane | 0:573d4c6e63ac | 2 | |
| dwijaybane | 1:a5fcf4e7055a | 3 | /* Create Objects */ |
| dwijaybane | 1:a5fcf4e7055a | 4 | PwmOut r (p23); // Create PWM object r for Red LED pin p23 |
| dwijaybane | 1:a5fcf4e7055a | 5 | PwmOut g (p24); // Create PWM object g for Green LED pin p24 |
| dwijaybane | 1:a5fcf4e7055a | 6 | PwmOut b (p25); // Create PWM object b for Blue LED pin p25 |
| dwijaybane | 0:573d4c6e63ac | 7 | |
| dwijaybane | 1:a5fcf4e7055a | 8 | /* Main Program */ |
| dwijaybane | 0:573d4c6e63ac | 9 | int main() |
| dwijaybane | 0:573d4c6e63ac | 10 | { |
| dwijaybane | 1:a5fcf4e7055a | 11 | r.period(0.001); // Periods in seconds which is 1KHz PWM freq |
| dwijaybane | 0:573d4c6e63ac | 12 | |
| dwijaybane | 0:573d4c6e63ac | 13 | while(1) { |
| dwijaybane | 1:a5fcf4e7055a | 14 | r = 0; // Display Red |
| dwijaybane | 1:a5fcf4e7055a | 15 | g = 1; // 1 is lowest intensity |
| dwijaybane | 1:a5fcf4e7055a | 16 | b = 1; // blue is also off |
| dwijaybane | 1:a5fcf4e7055a | 17 | wait (0.5); // 500 ms delay |
| dwijaybane | 1:a5fcf4e7055a | 18 | r = 1; |
| dwijaybane | 1:a5fcf4e7055a | 19 | g = 0; // Display green |
| dwijaybane | 0:573d4c6e63ac | 20 | b = 1; |
| dwijaybane | 1:a5fcf4e7055a | 21 | wait (0.5); // 500 ms delay |
| dwijaybane | 0:573d4c6e63ac | 22 | r = 1; |
| dwijaybane | 0:573d4c6e63ac | 23 | g = 1; |
| dwijaybane | 1:a5fcf4e7055a | 24 | b = 0; // Display blue |
| dwijaybane | 1:a5fcf4e7055a | 25 | wait (0.5); // 500 ms delay |
| dwijaybane | 0:573d4c6e63ac | 26 | } |
| dwijaybane | 0:573d4c6e63ac | 27 | } |