Kurz micro:bit: Rozdiel medzi revíziami
Z SensorWiki
(→Obsah) |
|||
Riadok 43: | Riadok 43: | ||
+ | Toto je zatial len priebezne robena zbierka prikladov | ||
+ | |||
+ | gallery heights=200px mode="packed"> <!-- slideshow? --> | ||
+ | Image:microbit01.png|''Prvý program...'' | ||
+ | Image:microbit01Run.png|''...bude vyzerať v simulátore takto.'' | ||
+ | </gallery> | ||
+ | |||
+ | {| class="wikitable" style="width: 100%;" | ||
+ | |- style="vertical-align:top;" | ||
+ | | style="background: LightYellow" | | ||
+ | '''Javascript''' | ||
+ | <source lang="javascript"> | ||
+ | |||
+ | |||
+ | basic.showIcon(IconNames.Heart) | ||
+ | |||
+ | </source> | ||
+ | |||
+ | | | ||
+ | '''Python''' | ||
+ | <source lang="python" style="background: LightBlue;"> | ||
+ | |||
+ | from microbit import * | ||
+ | |||
+ | display.show(Image.HEART) | ||
+ | |||
+ | </source> | ||
+ | |||
+ | | | ||
+ | '''C++''' | ||
+ | <syntaxhighlight lang=c style="background: Cornsilk"> | ||
+ | #include "MicroBit.h" | ||
+ | |||
+ | MicroBit uBit; | ||
+ | MicroBitImage Heart("0,1,0,1,0\n | ||
+ | 1,0,1,0,1\n | ||
+ | 0,1,0,1,0\n | ||
+ | 1,0,1,0,1\n | ||
+ | 0,1,0,1,0\n"); // 5x5 image | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | uBit.init(); | ||
+ | uBit.display.print(Heart); | ||
+ | release_fiber(); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <tabs> | ||
+ | <tab name="Javascript"><source lang="javascript"> | ||
+ | |||
+ | basic.showIcon(IconNames.Heart) | ||
+ | |||
+ | </source></tab> | ||
+ | <tab name="Python"><source lang="python" style="background: LightBlue;"> | ||
+ | |||
+ | from microbit import * | ||
+ | |||
+ | display.show(Image.HEART) | ||
+ | |||
+ | </source></tab> | ||
+ | <tab name="C++"><syntaxhighlight lang=c style="background: Cornsilk"> | ||
+ | #include "MicroBit.h" | ||
+ | |||
+ | MicroBit uBit; | ||
+ | MicroBitImage Heart("0,1,0,1,0\n | ||
+ | 1,0,1,0,1\n | ||
+ | 0,1,0,1,0\n | ||
+ | 1,0,1,0,1\n | ||
+ | 0,1,0,1,0\n"); // 5x5 image | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | uBit.init(); | ||
+ | uBit.display.print(Heart); | ||
+ | release_fiber(); | ||
+ | } | ||
+ | </syntaxhighlight></tab> | ||
+ | </tabs> | ||
+ | |||
+ | |||
+ | <!-- **************************************************************************** --> | ||
+ | |||
+ | gallery heights=200px mode="packed"> <!-- slideshow? --> | ||
+ | Image:microbit-WinkSmiley.png|''Prvý program...'' | ||
+ | Image:microbit-WinkSmileyRun.png|''...bude vyzerať v simulátore takto.'' | ||
+ | </gallery> | ||
+ | |||
+ | Zmurkajuci smajlik: | ||
+ | |||
+ | <tabs> | ||
+ | <tab name="Javascript"><source lang="javascript"> | ||
+ | |||
+ | basic.forever(function () { | ||
+ | basic.showIcon(IconNames.Happy) | ||
+ | basic.pause(100) | ||
+ | basic.showLeds(` | ||
+ | . . . . . | ||
+ | . # . . . | ||
+ | . . . . . | ||
+ | # . . . # | ||
+ | . # # # . | ||
+ | `) | ||
+ | basic.pause(100) | ||
+ | }) | ||
+ | |||
+ | </source></tab> | ||
+ | <tab name="Python"><source lang="python" style="background: LightBlue;"> | ||
+ | |||
+ | # MindPlus | ||
+ | # microbit | ||
+ | from microbit import * | ||
+ | |||
+ | |||
+ | while True: | ||
+ | display.show(Image("00000:09090:00000:90009:09990")) | ||
+ | sleep(100) | ||
+ | display.show(Image("00000:00090:00000:90009:09990")) | ||
+ | sleep(100) | ||
+ | |||
+ | |||
+ | </source></tab> | ||
+ | <tab name="C++"><syntaxhighlight lang=c style="background: Cornsilk"> | ||
+ | /*! | ||
+ | * MindPlus | ||
+ | * microbit | ||
+ | * | ||
+ | */ | ||
+ | #include <Microbit_Matrix.h> | ||
+ | // Static constants | ||
+ | const uint8_t bbcBitmap[][5] = { | ||
+ | {B00000,B01010,B00000,B10001,B01110}, | ||
+ | {B00000,B00010,B00000,B10001,B01110} | ||
+ | }; | ||
+ | |||
+ | |||
+ | // Main program start | ||
+ | void setup() { | ||
+ | |||
+ | } | ||
+ | void loop() { | ||
+ | MMatrix.show(bbcBitmap[0]); | ||
+ | delay(100); | ||
+ | MMatrix.show(bbcBitmap[1]); | ||
+ | delay(100); | ||
+ | } | ||
+ | |||
+ | </syntaxhighlight></tab> | ||
+ | </tabs> | ||
+ | |||
+ | |||
+ | |||
+ | <!-- **************************************************************************** --> | ||
+ | |||
+ | gallery heights=200px mode="packed"> <!-- slideshow? --> | ||
+ | Image:microbit-DisplayMisc.png|''Prvý program...'' | ||
+ | Image:microbit-DisplayMiscRun.png|''...bude vyzerať v simulátore takto.'' | ||
+ | </gallery> | ||
+ | |||
+ | Zakladne vypisy: | ||
+ | |||
+ | <tabs> | ||
+ | <tab name="Javascript"><source lang="javascript"> | ||
+ | |||
+ | basic.showString("Result:") | ||
+ | basic.showNumber(3) | ||
+ | basic.showIcon(IconNames.Yes) | ||
+ | |||
+ | }) | ||
+ | |||
+ | </source></tab> | ||
+ | <tab name="Python"><source lang="python" style="background: LightBlue;"> | ||
+ | |||
+ | # MindPlus | ||
+ | # microbit | ||
+ | from microbit import * | ||
+ | |||
+ | |||
+ | display.scroll(str("Result: "), wait=False, loop=False) | ||
+ | display.scroll(str((str(3))), wait=False, loop=False) | ||
+ | display.show(Image("00000:00009:00090:90900:09000")) | ||
+ | |||
+ | |||
+ | </source></tab> | ||
+ | <tab name="C++"><syntaxhighlight lang=c style="background: Cornsilk"> | ||
+ | /*! | ||
+ | * MindPlus | ||
+ | * microbit | ||
+ | * | ||
+ | */ | ||
+ | #include <Microbit_Matrix.h> | ||
+ | // Static constants | ||
+ | const uint8_t bbcBitmap[][5] = { | ||
+ | {B00000,B00001,B00010,B10100,B01000} | ||
+ | }; | ||
+ | |||
+ | |||
+ | // Main program start | ||
+ | void setup() { | ||
+ | MMatrix.print("Result: "); | ||
+ | MMatrix.print((String(3))); | ||
+ | MMatrix.show(bbcBitmap[0]); | ||
+ | } | ||
+ | void loop() { | ||
+ | |||
+ | } | ||
+ | |||
+ | </syntaxhighlight></tab> | ||
+ | </tabs> | ||
[[Category:micro:bit]] | [[Category:micro:bit]] |
Verzia zo dňa a času 18:02, 24. máj 2020
Obsah
- Čo je to physical computing? Interaktivita v umení, priemysle, vzdelávaní.
- Zoznámte sa s BBC micro:bit - Tour de Board.
- Displej a tlačidlá
- Napájanie a konektory
- Senzory
- Komunikačné možnosti
- Začíname. Prvý program.
- Možnosti programovania: Microsoft Blocks, Javascript, Python, C++
- Vstupy a výstupy
- Displej, LED diódy
- Tlačidlá, jednoduché senzory
- Externé zariadenia
- Senzory
- Snímač tlaku
- Snímač zrýchlenia
- Kompas
- Snímač teploty
- Snímač osvetlenia
- Komunikácia
- Sériová linka a USB
- Rádio
- Bluetooth
- Vlastný projekt
Toto je zatial len priebezne robena zbierka prikladov
gallery heights=200px mode="packed"> Image:microbit01.png|Prvý program... Image:microbit01Run.png|...bude vyzerať v simulátore takto. </gallery>
Javascript
basic.showIcon(IconNames.Heart)
|
Python from microbit import *
display.show(Image.HEART)
|
C++ #include "MicroBit.h"
MicroBit uBit;
MicroBitImage Heart("0,1,0,1,0\n
1,0,1,0,1\n
0,1,0,1,0\n
1,0,1,0,1\n
0,1,0,1,0\n"); // 5x5 image
int main()
{
uBit.init();
uBit.display.print(Heart);
release_fiber();
}
|
basic.showIcon(IconNames.Heart)
from microbit import *
display.show(Image.HEART)
#include "MicroBit.h"
MicroBit uBit;
MicroBitImage Heart("0,1,0,1,0\n
1,0,1,0,1\n
0,1,0,1,0\n
1,0,1,0,1\n
0,1,0,1,0\n"); // 5x5 image
int main()
{
uBit.init();
uBit.display.print(Heart);
release_fiber();
}
gallery heights=200px mode="packed"> Image:microbit-WinkSmiley.png|Prvý program... Image:microbit-WinkSmileyRun.png|...bude vyzerať v simulátore takto. </gallery>
Zmurkajuci smajlik:
basic.forever(function () {
basic.showIcon(IconNames.Happy)
basic.pause(100)
basic.showLeds(`
. . . . .
. # . . .
. . . . .
# . . . #
. # # # .
`)
basic.pause(100)
})
# MindPlus
# microbit
from microbit import *
while True:
display.show(Image("00000:09090:00000:90009:09990"))
sleep(100)
display.show(Image("00000:00090:00000:90009:09990"))
sleep(100)
/*!
* MindPlus
* microbit
*
*/
#include <Microbit_Matrix.h>
// Static constants
const uint8_t bbcBitmap[][5] = {
{B00000,B01010,B00000,B10001,B01110},
{B00000,B00010,B00000,B10001,B01110}
};
// Main program start
void setup() {
}
void loop() {
MMatrix.show(bbcBitmap[0]);
delay(100);
MMatrix.show(bbcBitmap[1]);
delay(100);
}
gallery heights=200px mode="packed">
Image:microbit-DisplayMisc.png|Prvý program...
Image:microbit-DisplayMiscRun.png|...bude vyzerať v simulátore takto.
</gallery>
Zakladne vypisy:
basic.showString("Result:")
basic.showNumber(3)
basic.showIcon(IconNames.Yes)
})
# MindPlus
# microbit
from microbit import *
display.scroll(str("Result: "), wait=False, loop=False)
display.scroll(str((str(3))), wait=False, loop=False)
display.show(Image("00000:00009:00090:90900:09000"))
/*!
* MindPlus
* microbit
*
*/
#include <Microbit_Matrix.h>
// Static constants
const uint8_t bbcBitmap[][5] = {
{B00000,B00001,B00010,B10100,B01000}
};
// Main program start
void setup() {
MMatrix.print("Result: ");
MMatrix.print((String(3)));
MMatrix.show(bbcBitmap[0]);
}
void loop() {
}