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

Committer:
Pokitto
Date:
Wed Nov 22 22:33:43 2017 +0000
Revision:
8:1f8f91d671a5
Parent:
5:c4a0391b43ac
Child:
9:a6bed03648e5
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 0:2d2a3994d55d 1 #include "Pokitto.h"
Pokitto 0:2d2a3994d55d 2
Pokitto 8:1f8f91d671a5 3 // the pokitto core library
Pokitto 8:1f8f91d671a5 4 Pokitto::Core pokitto;
Pokitto 8:1f8f91d671a5 5
Pokitto 8:1f8f91d671a5 6 // create a 'DigitalOut' object to represent
Pokitto 8:1f8f91d671a5 7 // the digital output pin used to communicated with the LED
Pokitto 8:1f8f91d671a5 8 // the object is set to use the EXT0 pin for output
Pokitto 8:1f8f91d671a5 9 DigitalOut led0 = DigitalOut(EXT0);
Pokitto 8:1f8f91d671a5 10
Pokitto 8:1f8f91d671a5 11 int main ()
Pokitto 8:1f8f91d671a5 12 {
Pokitto 8:1f8f91d671a5 13 // initialise the Pokitto
Pokitto 8:1f8f91d671a5 14 pokitto.begin();
Pokitto 0:2d2a3994d55d 15
Pokitto 8:1f8f91d671a5 16 // the main loop
Pokitto 8:1f8f91d671a5 17 while (pokitto.isRunning())
Pokitto 8:1f8f91d671a5 18 {
Pokitto 8:1f8f91d671a5 19 // update the Pokitto's state
Pokitto 8:1f8f91d671a5 20 if (pokitto.update())
Pokitto 8:1f8f91d671a5 21 {
Pokitto 8:1f8f91d671a5 22 // write 'Hello World!' to the screen
Pokitto 8:1f8f91d671a5 23 // this is so you can tell the Pokitto is running
Pokitto 8:1f8f91d671a5 24 pokitto.display.print("Hello World!");
Pokitto 8:1f8f91d671a5 25
Pokitto 8:1f8f91d671a5 26 // if the A button is pressed
Pokitto 8:1f8f91d671a5 27 if(pokitto.buttons.aBtn())
Pokitto 8:1f8f91d671a5 28 {
Pokitto 8:1f8f91d671a5 29 // send a high signal to turn the LED on
Pokitto 8:1f8f91d671a5 30 led0.write(1);
Pokitto 8:1f8f91d671a5 31 }
Pokitto 8:1f8f91d671a5 32
Pokitto 8:1f8f91d671a5 33 // if the B button is pressed
Pokitto 8:1f8f91d671a5 34 if(pokitto.buttons.bBtn())
Pokitto 8:1f8f91d671a5 35 {
Pokitto 8:1f8f91d671a5 36 // send a low signal to turn the LED off
Pokitto 8:1f8f91d671a5 37 led0.write(0);
Pokitto 8:1f8f91d671a5 38 }
Pokitto 8:1f8f91d671a5 39 }
Pokitto 8:1f8f91d671a5 40 }
Pokitto 8:1f8f91d671a5 41
Pokitto 8:1f8f91d671a5 42 return 1;
Pokitto 0:2d2a3994d55d 43 }