Deutsch English |
YOU LEARN HERE... |
how to use the two Calliope buttons to develop interactive programmes. |
HOW THE BUTTONS WORK |
The function button_a.is_pressed()returns True if the left button is pressed (analogue button_b_is pressed()). |
EXAMPLES |
Program: from calliope_mini import * from callibot import * repeat: if button_b.is_pressed():: setLED(1) delay(400) setLED(0) delay(400) delay(100) The commands for the buttons are in the calliope_mini module, which you must also import. Example 2: Reacting to the click of a button
Program: from calliope_mini import * from callibot import * from music import * repeat: if button_a.was_pressed(): play(JUMP_UP) if button_b.was_pressed(): play(JUMP_DOWN) delay(100) Example 3: Cancelling a programme with a button
Program: from calliope_mini import * from callibot import * setSpeed(30) forward() while not button_a.was_pressed(): d = getDistance() if d < 10: backward() delay(1000) forward() delay(200) stop() Example 4: Controlling the robot with buttons
Program: from calliope_mini import * from callibot import * forward() repeat: v = irLeft.read_digital() if v == 0: backward() delay(500) stop() if button_a.was_pressed(): left() delay(550) forward() elif button_b.was_pressed(): right() delay(550) forward() sleep(10) |
REMEMBER... |
You can use buttons to develop interactive programmes. The is_pressed() function returns True if the button is pressed. The was_pressed() function returns True if the button has been clicked at any time since the programme was started or since the last call. |
TO SOLVE BY YOURSELF |
|
Melody built into the music module.
ADADADUM - Beethoven 5. Sinfonie C Moll
ENTERTAINER - Scott Joplin's Ragtime
PRELUDE -J.S.Bach 48 Preludien aund Fugen
ODE - "Ode on Joy" Beethoven 9. Sinfonie D Moll
NYAN - Nyan Phone tone
FUNK - Secret agent
BLUES - Boogie-Woogie Blues
BIRTHDAY - Happy Birthday to You
WEDDING - Wagner Oper "Lohengrin"
FUNERAL - funeral procession, Chopin Klaviersonate
PUNCHLINE - a funny Tonclip
PYTHON - Monty Python Flying Circust;
BADDY - Filmclip The Baddy
CHASE - Filmclick Jagdszene
BA_DING - Signalton
WAWAWAWAA - Posaunenklang
JUMP_UP - for games, up movement
JUMP_DOWN - for games, down movement
POWER_UP - power up
POWER_DOWN -power downt