Blinky example (blinking a LED) by Pharap
Dependencies: PokittoLib
Fork of HelloWorld by
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
main.cpp@10:3ca58d7decfd, 2018-05-02 (annotated)
- 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?
User | Revision | Line number | New 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 | } |