![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Proj 324 Final
Fork of ELEC351_Group_T by
LED.cpp@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 | #include "mbed.h" |
thomasmorris | 5:2594b953f111 | 2 | #include "LED.hpp" |
thomasmorris | 5:2594b953f111 | 3 | |
thomasmorris | 5:2594b953f111 | 4 | |
thomasmorris | 5:2594b953f111 | 5 | LED::LED(PinName pinName):pin(pinName)//Constuctor |
thomasmorris | 5:2594b953f111 | 6 | //Constuctor runs whenever a new instave of the class is created |
thomasmorris | 5:2594b953f111 | 7 | //The constructor has the same name as the class |
thomasmorris | 5:2594b953f111 | 8 | //The constructor does not have a return type |
thomasmorris | 5:2594b953f111 | 9 | //When called it needs to be given parameters Led redLed(D7); |
thomasmorris | 5:2594b953f111 | 10 | { |
thomasmorris | 5:2594b953f111 | 11 | |
thomasmorris | 5:2594b953f111 | 12 | } |
thomasmorris | 5:2594b953f111 | 13 | |
thomasmorris | 5:2594b953f111 | 14 | void LED::switchOn() //type void class is Led function is switchon |
thomasmorris | 5:2594b953f111 | 15 | { |
thomasmorris | 5:2594b953f111 | 16 | this->pin =1; //You access the attributes of the class by using the this command and then the name of the attribute |
thomasmorris | 5:2594b953f111 | 17 | } |
thomasmorris | 5:2594b953f111 | 18 | |
thomasmorris | 5:2594b953f111 | 19 | void LED::switchOff() |
thomasmorris | 5:2594b953f111 | 20 | { |
thomasmorris | 5:2594b953f111 | 21 | this->pin =0; |
thomasmorris | 5:2594b953f111 | 22 | } |
thomasmorris | 5:2594b953f111 | 23 | void LED::flash(float time) |
thomasmorris | 5:2594b953f111 | 24 | { |
thomasmorris | 5:2594b953f111 | 25 | this->pin = 1; |
thomasmorris | 5:2594b953f111 | 26 | wait(time); |
thomasmorris | 5:2594b953f111 | 27 | this->pin = 0; |
thomasmorris | 5:2594b953f111 | 28 | } |
thomasmorris | 5:2594b953f111 | 29 | void LED::Toggle() |
thomasmorris | 5:2594b953f111 | 30 | { |
thomasmorris | 5:2594b953f111 | 31 | this->pin= !this->pin; |
thomasmorris | 5:2594b953f111 | 32 | } |