Ejemplo n.º 1
0
tutorial.start([
    "Welcome to Explorer HAT {name}...",
    """In this introduction, we'll show you the basics.

You'll learn how to turn a light on and off,
and how to use a fancy pulse effect too!
""", lambda: tutorial.wait_for_space(),
    """Before starting, we must "import" Explorer HAT.

This loads the Python code, called a module, needed
to make Explorer HAT work.

To do this, type:

    import explorerhat

Try it now:""", lambda: tutorial.wait_for_input("import explorerhat"),
    lambda: tutorial.importme(),
    """You can do this when you run "python" on the command
line, and also in IDLE.

Now, let's learn a little about Explorer HAT. It has:

* 4 inputs, which accept up to 5 volts
* 4 outputs, which sink up to 5 volts to ground
* 4 LEDs; Yellow, Red, Blue and Green
* 8 touch inputs, 4 are fruit compatible

If you have an Explorer HAT Pro, you'll also find:

* 2 Motor outputs, for making robots!
* 4 Analog Inputs for reading sensors, sliders and stuff
""", """Let's start with something simple. We'll turn on an LED.

Type:

    explorerhat.light.red.on()
""", lambda: tutorial.wait_for_input("explorerhat.light.red.on()"),
    lambda: tutorial.explorerhat.light.red.on(),
    """Neat, huh? But what if we want to turn on ALL THE LEDS!!!

Try:

    explorerhat.light.on()
""", lambda: tutorial.wait_for_input("explorerhat.light.on()"),
    lambda: tutorial.explorerhat.light.on(), """Easy!

Well, {name}. You'll be happy to know Explorer HAT
really doesn't get much harder than this.

Everything is in a collection, like "led" or "input".

You refer to things by using the collection name, IE:

    explorerhat.light

Or an item in a collection by referring to it by name, IE:

    explorerhat.light.red

So, let's turn our lights off and try something more exciting.

Type:

    explorerhat.light.off()
""", lambda: tutorial.wait_for_input("explorerhat.light.off()"),
    lambda: tutorial.explorerhat.light.off(),
    """Boom! Now let's make 'em pulse! Aww yeah!

Type:

    explorerhat.light.pulse()
""", lambda: tutorial.wait_for_input("explorerhat.light.pulse()"),
    lambda: tutorial.explorerhat.light.pulse(),
    """Excellent! Well done {name}, you've mastered the basics.

One last thing...

Any time you need a helping hand, just type:

    explorerhat.help()

Now, press space to exit!
""", lambda: tutorial.wait_for_space()
])
Ejemplo n.º 2
0
tutorial.start([
    "Welcome to Explorer HAT {name}...",
    """In this tutorial we'll introduce you to Digital Inputs.

Digital inputs take a high (5V) or low (0V) voltage
and turn it into a value you can use in your code.
""",
    lambda: tutorial.wait_for_space(),
    """Before starting, we must "import" Explorer HAT.

Remember to type:

    import explorerhat

Go for it:
""",
    lambda: tutorial.wait_for_input("import explorerhat"),
    lambda: tutorial.importme(),
    """Great! Your Explorer HAT looks like it's plugged in
and ready to go. Let's start reading some digital values.

The easiest way to input a digital value is with a male to
male jump wire. Make sure you've got one handy!
""",
    lambda: tutorial.wait_for_space(),
    """Now to read a digital value you'll need to use:

    explorerhat.input.one.read()

Try it:
""",
    lambda: tutorial.wait_for_input("explorerhat.input.one.read()"),
    lambda: tutorial.print_value("Input One", tutorial.explorerhat.input.one.read()),
    """Now, use your jump wire to connect input one to 5V.

And ready the input again:

    explorerhat.input.one.read()
""",
    lambda: tutorial.wait_for_input("explorerhat.input.one.read()"),
    lambda: tutorial.print_value("Input One", tutorial.explorerhat.input.one.read()),
    """If everything went to plan you should see a different value.

Getting a digital value into your Python code is that simple,
now you can add all the tactile buttons you could ever need!

That's all for now, press space to exit!""",
    lambda: tutorial.wait_for_space(),
])
Ejemplo n.º 3
0
tutorial.start([
    "Welcome to Explorer HAT {name}...",
    """In this tutorial we'll introduce you to Analog Inputs.

Analog Inputs allow you to turn a variable voltage
( from 0v to 5v ) that you might get from a slider into a
digital value that you can use in your code.
""",
    lambda: tutorial.wait_for_space(),
    """You're going to need an Explorer HAT Pro for this tutorial,
so make sure you've got one and its plugged onto your Pi!
""",
    lambda: tutorial.wait_for_space(),
    """Before starting, we must "import" Explorer HAT.

Remember to type:

    import explorerhat

Go for it:
""",
    lambda: tutorial.wait_for_input("import explorerhat"),
    lambda: tutorial.importme(),
    lambda: tutorial.check_for_pro(),
    """Great! Your Explorer HAT Pro looks like it's plugged in
and ready to go. Let's start reading some analog values.

You should have a little blue Rotary Potentiometer wired up
to Analog 1 on your Explorer HAT Pro breadboard!
""",
    lambda: tutorial.wait_for_space(),
    """Now to read the analog value you'll need to use:

    explorerhat.analog.one.read()

Try it:
""",
    lambda: tutorial.wait_for_input("explorerhat.analog.one.read()"),
    lambda: tutorial.print_value("Analog One",
                                 tutorial.explorerhat.analog.one.read()),
    """Now turn the potentiometer slightly and try again:

    explorerhat.analog.one.read()
""",
    lambda: tutorial.wait_for_input("explorerhat.analog.one.read()"),
    lambda: tutorial.print_value("Analog One",
                                 tutorial.explorerhat.analog.one.read()),
    """If everything went to plan you should see a different value.

Getting an analog value into your Python code is that simple,
now you can use it to control motors, adjust the brightness of
LEDs or whatever you can imagine!

That's all for now, press space to exit!""",
    lambda: tutorial.wait_for_space(),
])
Ejemplo n.º 4
0
tutorial.start([
    "Welcome to Explorer HAT {name}...",
    """In this tutorial we'll introduce you to Analog Inputs.

Analog Inputs allow you to turn a variable voltage
( from 0v to 5v ) that you might get from a slider into a
digital value that you can use in your code.
""",
    lambda: tutorial.wait_for_space(),
    """You're going to need an Explorer HAT Pro for this tutorial,
so make sure you've got one and its plugged onto your Pi!
""",
    lambda: tutorial.wait_for_space(),
    """Before starting, we must "import" Explorer HAT.

Remember to type:

    import explorerhat

Go for it:
""",
    lambda: tutorial.wait_for_input("import explorerhat"),
    lambda: tutorial.importme(),
    lambda: tutorial.check_for_pro(),
    """Great! Your Explorer HAT Pro looks like it's plugged in
and ready to go. Let's start reading some analog values.

You should have a little blue Rotary Potentiometer wired up
to Analog 1 on your Explorer HAT Pro breadboard!
""",
    lambda: tutorial.wait_for_space(),
    """Now to read the analog value you'll need to use:

    explorerhat.analog.one.read()

Try it:
""",
    lambda: tutorial.wait_for_input("explorerhat.analog.one.read()"),
    lambda: tutorial.print_value("Analog One", tutorial.explorerhat.analog.one.read()),
    """Now turn the potentiometer slightly and try again:

    explorerhat.analog.one.read()
""",
    lambda: tutorial.wait_for_input("explorerhat.analog.one.read()"),
    lambda: tutorial.print_value("Analog One", tutorial.explorerhat.analog.one.read()),
    """If everything went to plan you should see a different value.

Getting an analog value into your Python code is that simple,
now you can use it to control motors, adjust the brightness of
LEDs or whatever you can imagine!

That's all for now, press space to exit!""",
    lambda: tutorial.wait_for_space(),
])
Ejemplo n.º 5
0
tutorial.start([
    "Welcome to Explorer HAT {name}...",
    """In this introduction, we'll show you the basics.

You'll learn how to turn a light on and off,
and how to use a fancy pulse effect too!
""",
    lambda: tutorial.wait_for_space(),
    """Before starting, we must "import" Explorer HAT.

This loads the Python code, called a module, needed
to make Explorer HAT work.

To do this, type:

    import explorerhat

Try it now:""",
    lambda: tutorial.wait_for_input("import explorerhat"),
    lambda: tutorial.importme(),
    """You can do this when you run "python" on the command
line, and also in IDLE.

Now, let's learn a little about Explorer HAT. It has:

* 4 inputs, which accept up to 5 volts
* 4 outputs, which sink up to 5 volts to ground
* 4 LEDs; Yellow, Red, Blue and Green
* 8 touch inputs, 4 are fruit compatible

If you have an Explorer HAT Pro, you'll also find:

* 2 Motor outputs, for making robots!
* 4 Analog Inputs for reading sensors, sliders and stuff
""",
    """Let's start with something simple. We'll turn on an LED.

Type:

    explorerhat.light.red.on()
""",
    lambda: tutorial.wait_for_input("explorerhat.light.red.on()"),
    lambda: tutorial.explorerhat.light.red.on(),
    """Neat, huh? But what if we want to turn on ALL THE LEDS!!!

Try:

    explorerhat.light.on()
""",
    lambda: tutorial.wait_for_input("explorerhat.light.on()"),
    lambda: tutorial.explorerhat.light.on(),
    """Easy!

Well, {name}. You'll be happy to know Explorer HAT
really doesn't get much harder than this.

Everything is in a collection, like "led" or "input".

You refer to things by using the collection name, IE:

    explorerhat.light

Or an item in a collection by referring to it by name, IE:

    explorerhat.light.red

So, let's turn our lights off and try something more exciting.

Type:

    explorerhat.light.off()
""",
    lambda: tutorial.wait_for_input("explorerhat.light.off()"),
    lambda: tutorial.explorerhat.light.off(),
    """Boom! Now let's make 'em pulse! Aww yeah!

Type:

    explorerhat.light.pulse()
""",
    lambda: tutorial.wait_for_input("explorerhat.light.pulse()"),
    lambda: tutorial.explorerhat.light.pulse(),
    """Excellent! Well done {name}, you've mastered the basics.

One last thing...

Any time you need a helping hand, just type:

    explorerhat.help()

Now, press space to exit!
""",
    lambda: tutorial.wait_for_space()
])