Operácie

Kitronik :MOVE mini MK2: Rozdiel medzi revíziami

Zo stránky SensorWiki

Balogh (diskusia | príspevky)
Vytvorená stránka „Druhá, vylepšená verzia :MOVE od firmy Kitronik. <div style='text-align: center;'> 500px<BR> ''Kitronik :MOVE mk2.'' </div> * Aplik…“
 
Balogh (diskusia | príspevky)
Bez shrnutí editace
Riadok 7: Riadok 7:
</div>
</div>


 
* Product page https://kitronik.co.uk/products/5652-move-mini-mk2-buggy-kit-excl-microbit
* Aplikácia na ovládanie cez mobil (Android): https://play.google.com/store/apps/details?id=com.kitronik.blemove&gl=SK
* Aplikácia na ovládanie cez mobil (Android): https://play.google.com/store/apps/details?id=com.kitronik.blemove&gl=SK


Riadok 14: Riadok 14:
== Základné programy ==
== Základné programy ==


Line following robot
 
=== Blinker ===
 
Pre prácu so svetielkami na hornej hrane robota je potrebné nahrať knižnicu '''<code>pocetNavstevnikov</code>'''
 
Jednoduchý program pre blinker, funguje na tlačítka - stlačením ľavého tlačidla 🅰 sa zapne ľavá smerovka, pravým tlačidlom 🅱 sa zapne pravá. Stlačením oboch 🅰+🅱 sa blinker vypne.
 
<gallery heights=200px mode="packed">  <!-- slideshow? -->
Image:microbit-KitronikMoveBlinker.png|''Smerovky''
</gallery>
 
 
<tabs>
<tab name="Javascript"><source lang="javascript">
input.onButtonPressed(Button.A, function () {
    turn_left_indicator_on = true
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.AB, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.B, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = true
    indicator.clear()
    indicator.show()
})
let turn_right_indicator_on = false
let turn_left_indicator_on = false
let indicator: neopixel.Strip = null
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.setBrightness(80)
basic.forever(function () {
    if (turn_left_indicator_on == true) {
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    } else if (turn_right_indicator_on == true) {
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    }
})
</source></tab>
<tab name="MS Python"><source lang="python" style="background: LightBlue;">
def on_button_pressed_a():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = True
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.A, on_button_pressed_a)
 
def on_button_pressed_ab():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.AB, on_button_pressed_ab)
 
def on_button_pressed_b():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = True
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.B, on_button_pressed_b)
 
turn_right_indicator_on = False
turn_left_indicator_on = False
indicator: neopixel.Strip = None
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.set_brightness(80)
 
def on_forever():
    if turn_left_indicator_on == True:
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
    elif turn_right_indicator_on == True:
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
basic.forever(on_forever)
</source></tab>
</tabs>
 
 
 
 
=== Základné pohyby ===
 
 
=== Line following robot ===
 
=== Ultrazvukový senzor ===
 
 
Stlačením ľavého tlačidla 🅰 sa vždy pripočíta jednotka. Stlačením oboch 🅰+🅱 sa zariadenie vynuluje a začneme od začiatku. Vo všetkých príkladoch používame '''premennú''' <code>pocetNavstevnikov</code>.
 
 
<gallery heights=200px mode="packed">  <!-- slideshow? -->
Image:microbit-PeopleCounter.png|''Prvý program...''
Image:microbit-PeopleCounterRun.png|''...bude vyzerať v simulátore takto.''
</gallery>
 
 
<tabs>
<tab name="Javascript"><source lang="javascript">
input.onButtonPressed(Button.A, function () {
    turn_left_indicator_on = true
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.AB, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.B, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = true
    indicator.clear()
    indicator.show()
})
let turn_right_indicator_on = false
let turn_left_indicator_on = false
let indicator: neopixel.Strip = null
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.setBrightness(80)
basic.forever(function () {
    if (turn_left_indicator_on == true) {
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    } else if (turn_right_indicator_on == true) {
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    }
})
</source></tab>
<tab name="MS Python"><source lang="python" style="background: LightBlue;">
def on_button_pressed_a():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = True
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.A, on_button_pressed_a)
 
def on_button_pressed_ab():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.AB, on_button_pressed_ab)
 
def on_button_pressed_b():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = True
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.B, on_button_pressed_b)
 
turn_right_indicator_on = False
turn_left_indicator_on = False
indicator: neopixel.Strip = None
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.set_brightness(80)
 
def on_forever():
    if turn_left_indicator_on == True:
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
    elif turn_right_indicator_on == True:
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
basic.forever(on_forever)
</source></tab>
</tabs>






👉 Späť na [[Kurz micro:bit#Zbierka príkladov|zoznam príkladov....]]




[[Category:Micro:bit]]
[[Category:Micro:bit]][[Category:Príklady micro:bit]]

Verzia z 11:00, 14. jún 2021

Druhá, vylepšená verzia :MOVE od firmy Kitronik.



Kitronik :MOVE mk2.


Základné programy

Blinker

Pre prácu so svetielkami na hornej hrane robota je potrebné nahrať knižnicu pocetNavstevnikov

Jednoduchý program pre blinker, funguje na tlačítka - stlačením ľavého tlačidla 🅰 sa zapne ľavá smerovka, pravým tlačidlom 🅱 sa zapne pravá. Stlačením oboch 🅰+🅱 sa blinker vypne.


input.onButtonPressed(Button.A, function () {
    turn_left_indicator_on = true
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.AB, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.B, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = true
    indicator.clear()
    indicator.show()
})
let turn_right_indicator_on = false
let turn_left_indicator_on = false
let indicator: neopixel.Strip = null
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.setBrightness(80)
basic.forever(function () {
    if (turn_left_indicator_on == true) {
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    } else if (turn_right_indicator_on == true) {
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    }
})
def on_button_pressed_a():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = True
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.A, on_button_pressed_a)

def on_button_pressed_ab():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.AB, on_button_pressed_ab)

def on_button_pressed_b():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = True
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.B, on_button_pressed_b)

turn_right_indicator_on = False
turn_left_indicator_on = False
indicator: neopixel.Strip = None
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.set_brightness(80)

def on_forever():
    if turn_left_indicator_on == True:
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
    elif turn_right_indicator_on == True:
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
basic.forever(on_forever)



Základné pohyby

Line following robot

Ultrazvukový senzor

Stlačením ľavého tlačidla 🅰 sa vždy pripočíta jednotka. Stlačením oboch 🅰+🅱 sa zariadenie vynuluje a začneme od začiatku. Vo všetkých príkladoch používame premennú pocetNavstevnikov.



input.onButtonPressed(Button.A, function () {
    turn_left_indicator_on = true
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.AB, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = false
    indicator.clear()
    indicator.show()
})
input.onButtonPressed(Button.B, function () {
    turn_left_indicator_on = false
    turn_right_indicator_on = true
    indicator.clear()
    indicator.show()
})
let turn_right_indicator_on = false
let turn_left_indicator_on = false
let indicator: neopixel.Strip = null
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.setBrightness(80)
basic.forever(function () {
    if (turn_left_indicator_on == true) {
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(0, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    } else if (turn_right_indicator_on == true) {
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Orange))
        indicator.show()
        basic.pause(75)
        indicator.setPixelColor(4, neopixel.colors(NeoPixelColors.Black))
        indicator.show()
        basic.pause(75)
    }
})
def on_button_pressed_a():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = True
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.A, on_button_pressed_a)

def on_button_pressed_ab():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = False
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.AB, on_button_pressed_ab)

def on_button_pressed_b():
    global turn_left_indicator_on, turn_right_indicator_on
    turn_left_indicator_on = False
    turn_right_indicator_on = True
    indicator.clear()
    indicator.show()
input.on_button_pressed(Button.B, on_button_pressed_b)

turn_right_indicator_on = False
turn_left_indicator_on = False
indicator: neopixel.Strip = None
indicator = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGB)
indicator.set_brightness(80)

def on_forever():
    if turn_left_indicator_on == True:
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(0, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
    elif turn_right_indicator_on == True:
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.ORANGE))
        indicator.show()
        basic.pause(75)
        indicator.set_pixel_color(4, neopixel.colors(NeoPixelColors.BLACK))
        indicator.show()
        basic.pause(75)
basic.forever(on_forever)


👉 Späť na zoznam príkladov....