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.
Diff: ledlib.h
- Revision:
- 0:f2dd1916acde
diff -r 000000000000 -r f2dd1916acde ledlib.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ledlib.h Wed Jul 08 10:59:04 2020 +0000
@@ -0,0 +1,60 @@
+#ifndef LEDLIB_H
+#define LEDLIB_H
+
+#include "mbed.h"
+
+/** LED class.
+ * Collection of supporrt functions for the second lab in the course ET095G at Mittuniversitetet.
+ *
+ * To use the library, its header file needs to be included and an object of the LED class created.
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "Led.h"
+ *
+ * LED myled(PF4);
+ *
+ * int main(){
+ * while(1){
+ * wait(5);
+ * myled.on(); //Turns the led on
+ * wait(5);
+ * myled.blink(1); //Blinks the led for 0.2 seconds
+ * wait(5);
+ * myled.toggle(); //Toggles the state of the led (turns it off)
+ * }
+ * @endcode
+ */
+
+class LED {
+ public:
+ /** The constructor creates an instance of the LED class. It is automatically called when a new object is declared.
+ * @param PinName pin = (The pin that is used).
+ */
+ LED(PinName pin);
+
+ /** This function sets LED0(i.e., turns it on).
+ */
+ void on();
+
+ /** This function clears LED0 (i.e., turns it off).
+ */
+ void off();
+
+ /** This function toggles LED0 (i.e., it inverts its current state).
+ */
+ void toggle();
+
+ /** This function toggles LED0 on and off in an intervall set by the user.
+ * @param sec intervall time for led blink in seconds.
+ */
+ void blink(float sec);
+
+ private:
+ /** LED0 is the lamp on the board
+ */
+ DigitalOut LED0;
+};
+
+#endif
\ No newline at end of file