Lets the LED Blink thought red, green and blue. Speed can be controlled by the slider

Dependencies:   mbed tsi_sensor

Files at this revision

API Documentation at this revision

Comitter:
JanHenrik
Date:
Tue Sep 09 15:35:48 2014 +0000
Commit message:
This programm will led the LED flash in 3 colors, speed is defined by the slider. it is an easy code and good for starters

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
tsi_sensor.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 88fd491a3a3d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 09 15:35:48 2014 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "tsi_sensor.h"
+
+int  divisor = 10;      //set divisor, for blinking speed
+float slider = 0;       //we need that later
+
+/* This defines will be replaced by PinNames soon, it is needed to init the slider */
+#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
+#define ELEC0 9
+#define ELEC1 10
+#elif defined (TARGET_KL05Z)
+#define ELEC0 9
+#define ELEC1 8
+#else
+#error TARGET NOT DEFINED
+#endif
+
+int main(void)
+{
+    TSIAnalogSlider tsi(ELEC0, ELEC1, 80);      //init slider
+
+    PwmOut ledGreen(LED_GREEN);                 //init led pwm channels
+    PwmOut ledRed(LED_RED);
+    PwmOut ledBlue(LED_BLUE);
+
+    while (true) {
+
+        if(tsi.readPercentage() != 0) {                 //check if slider is tuched, if tuched slider != 0
+            slider = tsi.readPercentage()/divisor;      //set slidervalue ( / divisor )
+        }
+
+        ledGreen = 1;                           //turn led´s on and off
+        ledRed = 0;
+        wait(slider);                           //wait defined speed (slidervalue)
+
+        ledRed = 1;
+        ledBlue = 0;
+        wait(slider);
+
+        ledBlue = 1;
+        ledGreen = 0;
+        wait(slider);
+
+
+    }
+}
+
+
diff -r 000000000000 -r 88fd491a3a3d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 09 15:35:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file
diff -r 000000000000 -r 88fd491a3a3d tsi_sensor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tsi_sensor.lib	Tue Sep 09 15:35:48 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Kojto/code/tsi_sensor/#f64097679f27