Pflanzenbewässerung Lösung: Unterschied zwischen den Versionen

Aus microbit - Das Schulbuch
Wechseln zu: Navigation, Suche
Zeile 4: Zeile 4:
 
== Hilfestellungen und Lösung zum Pflanzenwächter ==
 
== Hilfestellungen und Lösung zum Pflanzenwächter ==
 
xxx
 
xxx
<pre id="01">
+
<pre id="pre01">
input.onGesture(Gesture.Shake, function () {
+
input.onButtonPressed(Button.A, function () {
     if (Math.randomBoolean()) {
+
     pins.servoWritePin(AnalogPin.P2, 0)
   
+
    basic.pause(1000)
     }
+
    pins.servoWritePin(AnalogPin.P2, 180)
 +
    basic.pause(1000)
 +
    pins.servoWritePin(AnalogPin.P2, 0)
 +
    basic.pause(2000)
 +
     pins.digitalWritePin(DigitalPin.P2, 0)
 
})
 
})
 
</pre>
 
</pre>
  
<pre id="01">
+
 
let anzahl_kopf = 0
 
let anzahl_zahl = 0
 
input.onGesture(Gesture.Shake, function () {
 
    if (Math.randomBoolean()) {
 
        anzahl_kopf += 1
 
        basic.showLeds(`
 
            . # . . #
 
            . # . # .
 
            . # # . .
 
            . # . # .
 
            . # . . #
 
            `)
 
    } else {
 
        anzahl_zahl += 1
 
        basic.showLeds(`
 
            . # # # #
 
            . . . . #
 
            . . # # .
 
            . # . . .
 
            . # # # #
 
            `)
 
    }
 
})
 
</pre>
 
  
 
== Komplettlösungen ==
 
== Komplettlösungen ==
 
xxx
 
xxx

Version vom 13. Dezember 2021, 19:20 Uhr

Grundsätzliche Überlegungen

xxx

Hilfestellungen und Lösung zum Pflanzenwächter

xxx

input.onButtonPressed(Button.A, function () {
    pins.servoWritePin(AnalogPin.P2, 0)
    basic.pause(1000)
    pins.servoWritePin(AnalogPin.P2, 180)
    basic.pause(1000)
    pins.servoWritePin(AnalogPin.P2, 0)
    basic.pause(2000)
    pins.digitalWritePin(DigitalPin.P2, 0)
})


Komplettlösungen

xxx