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.
Revision 1:8cd3ad6ab5f3, committed 2016-10-06
- Comitter:
- spanesar
- Date:
- Thu Oct 06 09:40:57 2016 +0000
- Parent:
- 0:c2221c47a1f8
- Child:
- 2:3528eaaf5319
- Commit message:
- added Led classes
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Led.cpp Thu Oct 06 09:40:57 2016 +0000
@@ -0,0 +1,17 @@
+#include "Led.h"
+
+Led::Led(PinName pinName):
+pin(pinName)
+{
+}
+void Led::switchOn(){
+ this->pin = 1;
+ }
+void Led::switchOff(){
+ this->pin = 0;
+ }
+void Led::flash(float time){
+ this->pin = 1;
+ wait(time);
+ this->pin = 0;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Led.h Thu Oct 06 09:40:57 2016 +0000
@@ -0,0 +1,15 @@
+#ifndef _LED_H_
+#define _LED_H_
+#include "mbed.h"
+
+class Led
+{
+ public:
+ Led(PinName pinName);
+ void switchOn();
+ void switchOff();
+ void flash(float time);
+ private:
+ DigitalOut pin;
+ };
+ #endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 06 09:40:57 2016 +0000
@@ -0,0 +1,16 @@
+#include "mbed.h"
+#include "Led.h"
+
+Led greenLed(PD_12);
+Led orangeLed(PD_13);
+Led redLed(PD_14);
+Led blueLed(PD_15);
+
+int main(){
+ while(1){
+ greenLed.flash(0.1);
+ orangeLed.flash(0.1);
+ redLed.flash(0.1);
+ blueLed.flash(0.1);
+ }
+}
\ No newline at end of file