Thomas Morris
/
PROJ324_Final
Proj 324 Final
Fork of ELEC351_Group_T by
LED.hpp@5:2594b953f111, 2017-12-10 (annotated)
- Committer:
- thomasmorris
- Date:
- Sun Dec 10 17:30:00 2017 +0000
- Revision:
- 5:2594b953f111
- Child:
- 51:47f5db68500b
Task 1,5,8 Working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 5:2594b953f111 | 1 | #ifndef _LED_HPP_ //Known as header guards |
thomasmorris | 5:2594b953f111 | 2 | #define _LED_HPP_ |
thomasmorris | 5:2594b953f111 | 3 | |
thomasmorris | 5:2594b953f111 | 4 | class LED //This creates a class called Led |
thomasmorris | 5:2594b953f111 | 5 | { |
thomasmorris | 5:2594b953f111 | 6 | |
thomasmorris | 5:2594b953f111 | 7 | //Below are methods of the class these are the opperations the class will support |
thomasmorris | 5:2594b953f111 | 8 | public: //The public: word enables the methods to be accessed outside of the class itself |
thomasmorris | 5:2594b953f111 | 9 | |
thomasmorris | 5:2594b953f111 | 10 | LED(PinName pinName); |
thomasmorris | 5:2594b953f111 | 11 | void switchOn(); //Void is the return type as no values will be output the return type is void |
thomasmorris | 5:2594b953f111 | 12 | void switchOff(); //SwitchOff is the name of the method/function |
thomasmorris | 5:2594b953f111 | 13 | void flash(float time); //float time is the parameter of the function in this case it creates a floating poi t variable known as time and this is then passed o the function when called. |
thomasmorris | 5:2594b953f111 | 14 | void Toggle(); |
thomasmorris | 5:2594b953f111 | 15 | |
thomasmorris | 5:2594b953f111 | 16 | private: //This is used here to make digitalout pin only useable from inside class Led |
thomasmorris | 5:2594b953f111 | 17 | DigitalOut pin; //DigitalOut is the Class and the object is called pin the object pin is now an attribute of led this is also known as a member variable or field |
thomasmorris | 5:2594b953f111 | 18 | }; |
thomasmorris | 5:2594b953f111 | 19 | |
thomasmorris | 5:2594b953f111 | 20 | |
thomasmorris | 5:2594b953f111 | 21 | #endif |