Menü Schließen

Java-Beispiele

Blinklicht

basic.forever(function () {
pins.digitalWritePin(DigitalPin.P0, 1)
basic.pause(1000)
pins.digitalWritePin(DigitalPin.P0, 0)
basic.pause(1000)
})

Calliope Mobil mit Blau- und Stopplicht (Version 2)

input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
motors.dualMotorPower(Motor.M0_M1, 50)
for (let index = 0; index < 10; index++) {
basic.setLedColor(0x0000ff)
basic.pause(200)
basic.setLedColor(0xffffff)
basic.pause(200)
}
motors.dualMotorPower(Motor.M0_M1, 0)
basic.setLedColor(0)
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. # # # .
. . # . .
`)
})

Calliope Mobil mit Sirene, Blau- und Stopplicht (Version 3)

input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
motors.dualMotorPower(Motor.M0_M1, 25)
for (let index = 0; index < 3; index++) {
music.playTone(440, music.beat(BeatFraction.Double))
basic.setLedColors(0x0000ff, 0xffffff, 0x0000ff)
music.playTone(587, music.beat(BeatFraction.Double))
basic.setLedColors(0xffffff, 0x0000ff, 0xffffff)
}
motors.dualMotorPower(Motor.M0, -25)
basic.pause(5000)
motors.dualMotorPower(Motor.M0_M1, 0)
basic.setLedColor(0)
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. # # # .
. . # . .
`)
basic.pause(1000)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})

Herzschlag sehen und hören

basic.forever(function () {

    basic.showIcon(IconNames.SmallHeart)

    basic.pause(500)

    music.playTone(988, music.beat(BeatFraction.Quarter))

    basic.showIcon(IconNames.Heart)

})

Pippi Langstrumpf auf Knopfdruck

input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
music.playTone(196, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Whole))
music.playTone(349, music.beat(BeatFraction.Quarter))
music.playTone(330, music.beat(BeatFraction.Quarter))
music.playTone(294, music.beat(BeatFraction.Quarter))
music.playTone(262, music.beat(BeatFraction.Quarter))
music.playTone(247, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Half))
music.playTone(196, music.beat(BeatFraction.Half))
music.playTone(247, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Whole))
music.playTone(330, music.beat(BeatFraction.Whole))
music.playTone(196, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Whole))
music.playTone(349, music.beat(BeatFraction.Quarter))
music.playTone(330, music.beat(BeatFraction.Quarter))
music.playTone(294, music.beat(BeatFraction.Quarter))
music.playTone(262, music.beat(BeatFraction.Quarter))
music.playTone(247, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Half))
music.playTone(196, music.beat(BeatFraction.Half))
music.playTone(247, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Double))
music.playTone(330, music.beat(BeatFraction.Whole))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(349, music.beat(BeatFraction.Whole))
music.playTone(349, music.beat(BeatFraction.Half))
music.playTone(349, music.beat(BeatFraction.Quarter))
music.playTone(330, music.beat(BeatFraction.Quarter))
music.playTone(294, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Quarter))
music.playTone(294, music.beat(BeatFraction.Quarter))
music.playTone(294, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Quarter))
music.playTone(262, music.beat(BeatFraction.Quarter))
music.playTone(247, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Whole))
music.playTone(330, music.beat(BeatFraction.Whole))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(349, music.beat(BeatFraction.Whole))
music.playTone(349, music.beat(BeatFraction.Half))
music.playTone(330, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Half))
music.playTone(294, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(247, music.beat(BeatFraction.Half))
music.playTone(262, music.beat(BeatFraction.Whole))
})

Motoren-Programmierung Calliope Version 3.0 (Fahren-Drehen-Fahren)

input.onButtonEvent(Button.A, input.buttonEventClick(), function () {
motors.dualMotorPower(Motor.M0_M1, 50)
basic.pause(2000)
motors.dualMotorPower(Motor.M0_M1, 0)
basic.pause(1000)
motors.dualMotorPower(Motor.M0, 50)
motors.dualMotorPower(Motor.M1, -50)
basic.pause(500)
motors.dualMotorPower(Motor.M0_M1, 0)
basic.pause(1000)
motors.dualMotorPower(Motor.M0_M1, 50)
basic.pause(2000)
motors.dualMotorPower(Motor.M0_M1, 0)
})