Ejemplo n.º 1
0
def start():
    mark("begin")
    oled_page("Begin")
    print("""
Yay! You got here!

Of course, that was easy. This time, it will be harder.
You'll need to figure out how to get to the next step.

In the same package as me is a secret closed envelope.
Don't open it; you won't need anything in it until the end.

But outside the box, there was a strange, featureless 
white card. That holds the clue to the next step.

Don't get it wet, or break it, or anything like that.

But see if it responds to something you already own.

To encourage you, here's a few rainbows!
""")

    rainbow()
    rainbow()
    rainbow()

    print("""
If you ever want to just see a rainbow, you can do:

  >>> from common import rainbow
  >>> rainbow(brightness=0.2, ntimes=1)

p.s. The card may or may not work for you --- reach out
     for help in #secret-pico if you're stuck :)
""")
Ejemplo n.º 2
0
def start():
    mark("sensors")
    # Convert a 16-bit number to 0 - 3.3 (Pico runs at 3.3volt)
    CONVERSION_FACTOR = 3.3 / 65535

    # Define the ADC pin number for the thermistor
    temperature_sensor = machine.ADC(4)

    # read voltage from temp sensor and convert into volts (0 - 3.3V)
    reading = temperature_sensor.read_u16() * CONVERSION_FACTOR

    # convert that to the actual temperature in Celsius:
    # 0.706V is 27 degrees C, with a slope of -1.721mV per degree.
    temperature = 27 - (reading - 0.706) / 0.001721

    oled_page("Sensors", "{temperature}C".format(temperature=temperature))
    print("""
Want to know a fun fact?

It's about {temperature} degrees Celsius where you are.

I can tell the approximate temperature from a sensor built in to me. In fact,
reading sensors is something I'm awesome at.

You can learn more at:

    {url}

When you'd like to move on:

    >>> import music
    >>> music.start()
""".format(url=url("sensors"), temperature=temperature))
Ejemplo n.º 3
0
def start():
    mark("morse")
    oled_page("Morse Code")

    print("""
We're going to be exploring Morse Code, a way of encoding information in
lights or sound. Turn off any music so you can listen carefully.

You'll probably find it helpful to do a minute of research and find a chart
of Morse Code on the internet.
    """)

    input("Press RETURN when ready ? > ")

    play("Hello")
    input("""
Hear that? That was 'Hello')

Press RETURN when ready > """)

    play(name)
    print("""
Hear that? That was '{name}'

Now: listen to what I'm saying.
""".format(name=name))

    test_listen()

    print("""
Well done!

Now you try sending a message!

A short press for a dot, a long press for a dash. Pause about a second between
letters, about three seconds between words. When you're done, just wait ---
after five seconds, I'll finish your recording and tell you what you said.
""")

    input("""Press RETURN when ready > """)
    print(record())

    test_record()

    print("""
Great job! Learn more: 

    {url}

When you're ready to go on:

    >>> import cryptogram
    >>> cryptogram.start()
""".format(url=url("morse")))
Ejemplo n.º 4
0
def test_listen():
    oled_page("Morse Code", "", "(Listen!)")

    while True:
        input("Press RETURN when ready > ")
        play("Rithm", listen=True)
        guess = input("What was that word? > ")
        if guess.lower() == "rithm":
            return
        
        print("Nope. Listen again")
Ejemplo n.º 5
0
def start():
    mark("cryptogram")
    oled_page("Cryptogram")
    print("""
An important message arrived just a moment ago, but I can't seem
to puzzle out what it means:


MXCLAAPKA PB UJPYX QB VQOM QB JOPUPKA UVX YFMX PK UVX SPOBU EDQYX.
UVXOXSFOX, PS RFL JOPUX UVX YFMX QB YDXZXODR QB EFBBPCDX, RFL QOX,
CR MXSPKPUPFK, KFU BWQOU XKFLAV UF MXCLA PU.

UVX WFBU XSSXYUPZX MXCLAAPKA UFFD PB BUPDD YQOXSLD UVFLAVU,
YFLEDXM JPUV ILMPYPFLBDR EDQYXM EOPKU BUQUXWXKUB.

-- COPQK NXOKPAVQK


A friendly secret agent told me that it's enciphered using a
"monoalphabetic substitution cipher" (each letter in the message
corresponds in a 1-to-1 relationship with another letter.)

These kind of codes, often called "cryptograms", can be a fun
puzzle to solve. You can find some ideas about how to approach
one from the notes from my Cryptography lecture or at:

  https://www.simonsingh.net/The_Black_Chamber/crackingsubstitution.html
  
When you've broken the code, you can answer a question about the
quotation, and I'll tell you where to find the final step.
""")
    
    while True:
        subject = input("In one word, what is the subject of this quote? > ")
        if subject.lower() == "debugging":
            break
        print("\nNope.\n")
        
    rainbow()
    print("""
Great job! 

Read about this: 

    {url}

Proceed to the next step with:

  >> import yay
  yay.start()
""".format(url=url("decipher")))
Ejemplo n.º 6
0
def start():
    mark("cat")
    oled_page("Cat")
    print("""
Of course, since this is all written in Python and you have the REPL, you can
do things like you would in more traditional Python.

For example, I've made a Cat class for you. Go ahead and make an instance of
it (you can substitute any name you'd like):

    >>> fluffy = cat.Cat("Fluffy")

Then, make Fluffy dance!
    """)
Ejemplo n.º 7
0
def start():
    mark("music")
    oled_page("Music!")

    led.high()
    for c in TAKE_ON_ME:
        play_note(c, 0.2)

    speaker.duty_u16(0)

    print("""
A-ha! :-)

I can hum decently well, can't I?

You can learn more at {url}

When you'd like to move on:

    >>> import morse
    >>> morse.start()
""".format(url=url("pwm")))
Ejemplo n.º 8
0
def start():
    mark("yay")
    oled_page("Yay!")
    rainbow()

    print("""
You did it! It was fun for me to lead you through this.

And here's a personal message from Joel for you:

--

{joel_msg}

--

You can learn more, as well as get the table of contents for everything, along
with permission to dig into that mysterious envelope, at:
    
    {url}

<3 Pico, Joel, and Fluffy
""".format(joel_msg=joel_msg, url=url("yay")))
Ejemplo n.º 9
0
def start():
    mark("welcome")
    oled_page("Hi " + name + "!", "The cursor at", "the bottom right",
              "means 'press the'", "black button'")
    wait()

    oled_page("I'm Pico!", "I'm so happy to", "meet you! Joel",
              "thinks you're", "awesome.")
    wait()

    oled_page("Getting Hints", "If you get stuck", "and need a hint",
              "use Slack", "#secret-pico")
    wait()

    oled_page("Let's begin!", "Let's move this", "convo to your",
              "laptop, ok?")
    wait()

    oled_page("Type in Shell:", "screen", "  /dev/tty.usb*", "",
              "& press RETURN")
    wait()

    oled_page("Connect to me!", "", "I'll be waiting", "for you there :)")
    wait(msg="Press black button")

    oled_page("Serial output")

    print("""
Hi again! It's me, Pico!

I'm a gift wrapped in a puzzle wrapped in an educational
experience. Joel made me just for you and your cohort-mates.

I've got lots to show you, plus a reward at the end. But
first, like any good hero, you have to overcome some challenges.
Don't give up too easily! Part of a challenge is figuring it out.
But, remember, if you get stuck, you ask in #pico-secret.
""")

    input("Press RETURN > ")

    print("""
Along the way, I have some learning material for you. For
example, you should read:

    {url}
""".format(url=url('pico')))

    input("Press RETURN when ready > ")

    print("""
I can be programmed in lots of languages but, of course,
Joel programmed me in Python. It's actually a version of Python
called MicroPython, meant to be run on tiny machines like me.
It has almost all of the normal language features, plus some
of the standard library. We'll be using it throughout.

You'll start each section by importing a Python module,
and then running it's `start()` function. You can always
revisit and earlier section by importing it. Of course, you
won't know all the future sections, so you can't jump ahead :).

Let's begin! I'm going to return you to my Python shell.
When you're ready, you should type:

    >>> import begin
    >>> begin.start()
    
See you there!
""")
Ejemplo n.º 10
0
# In order for this to work, you'll need a light sensor connected, which wasn't
# in the kit.

from machine import ADC
from common import speaker, button, VOLUME_OFF, VOLUME_OFF, oled_page
import time
import math

light_sensor = ADC(1)

oled_page("Light theramin", "Expose sensor", "to more/less", "light. Press",
          "button to stop")

speaker.duty_u16(VOLUME_MAX)

print("""
Raise and lower your hands over the light sensor or shine a light on it
(it's between the Pico and the screen.) 
 
To stop, press the black button.
""")

prev = light_sensor.read_u16()

while button.value() == 1:
    light = light_sensor.read_u16()
    print(light)
    if abs(prev - light) > 200:
        speaker.freq(light // 10)
    prev = light
    time.sleep(0.1)
Ejemplo n.º 11
0
led.on()

try:
    step = uio.open("/step.txt").read().strip()
except:
    step = "welcome"

if step == "welcome":
    # they're just starting, so move for them
    import welcome
    welcome.start()
    
else:
    oled_page(
        "Welcome back!",
        "Connect using",
        "screen",
        " /dev/tty.usb*")
    wait("Press black button")
    print("""
Welcome back.

You can pick up where you were with:

    >>> import {step}
    >>> {step}.start()

(if you know other step names, feel free to use them)
""".format(step=step))