Frau Hmpf
Published © GPL3+

Merely a Recitation of Poetry

Does the BBC micro:bit share my affinity for German poetry? Is it able to randomly change a line of verse? I believe so.

BeginnerWork in progress30 minutes1,286
Merely a Recitation of Poetry

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
Alligator Clips
Alligator Clips
×2
VISATON Speaker/ dome tweeter 8 Ω
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

code with Mu
BBC micro:bit MicroPython documentation

Story

Read more

Schematics

set up after flashing the Python code via USB

connection: micro:bit to the positive and negative inputs of your speaker, it's not working with a piezo buzzer, when connected to headphones attach crocodile clips to pin 0 and GND

Code

Morgenstern4microbit.py

Python
from microbit import *
from microbit import speech
from microbit import random

location = random.choice(["einem Kiesel", "einer Wiese", "dem Zwiesel"])
action = random.choice(["sass", "stand", "lag", "schlief"])
subj = (["Wiesel"])
prop = random.choice(["Bachgeriesel", "Schneegriesel",
                     "einer Pfuetze Diesel"])
clue = random.choice(["das Mondkalb", "der Nachtalb"])
attitude = random.choice(["um des Reimes Willen", "um einfach mal zu chillen"])

poem = [
    "Das aesthetische Wiesel frei nach Christian Morgenstern",
    "Ein {}".format(subj),
    "{} auf".format(action),
    "inmitten {}".format(prop),
    "Wisst ihr, weshalb?",
    "{} verriet es mir im Stillen:".format(clue),
    "Das raffinierte Tier tats {}".format(attitude)]
for line in poem:
    speech.say(line, speed=120, pitch=100, throat=100, mouth=200)
    sleep(500)

Credits

Frau Hmpf

Frau Hmpf

3 projects • 16 followers
working where the wild things are a.k.a. teacher @ primary school

Comments