Blinky example (blinking a LED) by Pharap

Dependencies:   PokittoLib

Fork of HelloWorld by Pokitto Community Team

/media/uploads/Pokitto/9158987a0a515653f5ae7a4898c32517bced1b53.png

/media/uploads/Pokitto/ce2e6057553d5cc79a6f7532a538c4478d1dc344_1_666x500.jpg

Blinking an LED with Pokitto / LEDin vilkutus Pokittolla

Instructions/ohjeet:

https://talk.pokitto.com/t/wiki-draft-using-the-pex-01-a-simple-led-project/613

Revision:
8:1f8f91d671a5
Parent:
5:c4a0391b43ac
Child:
9:a6bed03648e5
--- a/main.cpp	Sun Oct 22 19:13:22 2017 +0000
+++ b/main.cpp	Wed Nov 22 22:33:43 2017 +0000
@@ -1,13 +1,43 @@
 #include "Pokitto.h"
 
-Pokitto::Core mygame;
+// the pokitto core library
+Pokitto::Core pokitto;
+
+// create a 'DigitalOut' object to represent
+// the digital output pin used to communicated with the LED
+// the object is set to use the EXT0 pin for output
+DigitalOut led0 = DigitalOut(EXT0);
+
+int main ()
+{
+    // initialise the Pokitto
+    pokitto.begin();
 
-int main () {
-    mygame.begin();
-    while (mygame.isRunning()) {
-        if (mygame.update()) {            
-            mygame.display.print("Hello World!");
-            } 
-        }    
-    
+    // the main loop
+    while (pokitto.isRunning())
+    {
+        // update the Pokitto's state
+        if (pokitto.update())
+        {
+            // write 'Hello World!' to the screen
+                        // this is so you can tell the Pokitto is running
+            pokitto.display.print("Hello World!");
+
+            // if the A button is pressed
+            if(pokitto.buttons.aBtn())
+            {
+                // send a high signal to turn the LED on
+                led0.write(1);
+            }
+
+            // if the B button is pressed
+            if(pokitto.buttons.bBtn())
+            {
+                // send a low signal to turn the LED off
+                led0.write(0);
+            }
+        }
+    }
+
+    return 1;
 }
\ No newline at end of file