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 May 02 06:23:20 2018 +0000
Revision:
10:3ca58d7decfd
Parent:
9:a6bed03648e5
New pokittolib with improved volume controls & better button handling

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 9:a6bed03648e5 24 pokitto.display.color=led0+1;
Pokitto 9:a6bed03648e5 25 pokitto.display.setCursor(0,0);
Pokitto 9:a6bed03648e5 26 if (led0==0) pokitto.display.print("Hello World!");
Pokitto 9:a6bed03648e5 27 else pokitto.display.print("Hei Etlari!");
Pokitto 8:1f8f91d671a5 28
Pokitto 8:1f8f91d671a5 29 // if the A button is pressed
Pokitto 8:1f8f91d671a5 30 if(pokitto.buttons.aBtn())
Pokitto 8:1f8f91d671a5 31 {
Pokitto 8:1f8f91d671a5 32 // send a high signal to turn the LED on
Pokitto 8:1f8f91d671a5 33 led0.write(1);
Pokitto 8:1f8f91d671a5 34 }
Pokitto 8:1f8f91d671a5 35
Pokitto 8:1f8f91d671a5 36 // if the B button is pressed
Pokitto 8:1f8f91d671a5 37 if(pokitto.buttons.bBtn())
Pokitto 8:1f8f91d671a5 38 {
Pokitto 8:1f8f91d671a5 39 // send a low signal to turn the LED off
Pokitto 8:1f8f91d671a5 40 led0.write(0);
Pokitto 8:1f8f91d671a5 41 }
Pokitto 8:1f8f91d671a5 42 }
Pokitto 8:1f8f91d671a5 43 }
Pokitto 8:1f8f91d671a5 44
Pokitto 8:1f8f91d671a5 45 return 1;
Pokitto 0:2d2a3994d55d 46 }