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.
Fork of ele350 by
Led.cpp@6:f804bb3faa26, 2015-11-05 (annotated)
- Committer:
- GGHHHH
- Date:
- Thu Nov 05 13:11:29 2015 +0000
- Revision:
- 6:f804bb3faa26
- Parent:
- 0:b43794060b94
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GGHHHH | 0:b43794060b94 | 1 | #include "Led.h" //includes the header with the class definition |
GGHHHH | 0:b43794060b94 | 2 | |
GGHHHH | 0:b43794060b94 | 3 | //constructor |
GGHHHH | 0:b43794060b94 | 4 | Led::Led(string s) //contructor implementation |
GGHHHH | 0:b43794060b94 | 5 | { |
GGHHHH | 0:b43794060b94 | 6 | if(s== "red") |
GGHHHH | 6:f804bb3faa26 | 7 | pin= PD_14; //The pin for the red led |
GGHHHH | 6:f804bb3faa26 | 8 | if(s=="green") |
GGHHHH | 6:f804bb3faa26 | 9 | pin= PD_12; |
GGHHHH | 6:f804bb3faa26 | 10 | if(s== "blue") |
GGHHHH | 6:f804bb3faa26 | 11 | pin= PD_15; |
GGHHHH | 6:f804bb3faa26 | 12 | if(s=="orange") |
GGHHHH | 6:f804bb3faa26 | 13 | pin= PD_13; |
GGHHHH | 6:f804bb3faa26 | 14 | |
GGHHHH | 6:f804bb3faa26 | 15 | |
GGHHHH | 0:b43794060b94 | 16 | l = new DigitalOut(pin); |
GGHHHH | 6:f804bb3faa26 | 17 | |
GGHHHH | 0:b43794060b94 | 18 | } |
GGHHHH | 0:b43794060b94 | 19 | |
GGHHHH | 0:b43794060b94 | 20 | void Led::On() //function implementation |
GGHHHH | 0:b43794060b94 | 21 | { |
GGHHHH | 0:b43794060b94 | 22 | l->write(1); //set the value of the pin to l |
GGHHHH | 0:b43794060b94 | 23 | } |
GGHHHH | 0:b43794060b94 | 24 | |
GGHHHH | 0:b43794060b94 | 25 | void Led::Off() |
GGHHHH | 0:b43794060b94 | 26 | { |
GGHHHH | 0:b43794060b94 | 27 | l->write(0); //set the value of the pin to 0 |
GGHHHH | 0:b43794060b94 | 28 | } |