Exploring the Hub - Part 2 Inital Look Around

 

In part 1 of this series, I gave you details on how to connect and log in to the Mindstorms hub. Please follow those instructions before starting this guide.  (click here to view post)

Once connected, make sure you have pressed <CTRL> + C on your keyboard, to stop the data updating and scrolling.

 

Once you have stopped the hub updating you will see the following at the bottom of the screen: 

Press <CTRL> + C to stop the scrolling

The last line states “Type “help()” for more information.” So try it (and press enter after it). You will find that this gives you some helpful commands:

Some helpful commands?

The first is hub.info(), so try typing that and pressing enter. You will get the following error: 

Error! 

Before you can access the hub library, you need to import it.  Type “import hub” and enter, then try hub.info() again and enter. See the following screenshot. I’m not sure what everything means yet, but this is some information about the hub! 

hub.info()

hub.status() gives some useful information – can you work out what everything means?  Tyre putting the hub on its side, and try hub.status again. 

hub.status()


One final trick.  To discover Python commands to help you program, try the following trick.

So let’s say I want to display a message on the display. To find a possible command type “hub.” (need the full stop) and press the Tab key. 

All of the methods for hub.


This shows all of the methods that are available to hub.  From this list I can see’display’, so I’m going to type ‘display.’ After ‘hub.’, and that will display a list of all methods available to display. 

All of the methods for hub.display.

 I obviously want to us 'show' so enter show. after what is already displayed and press tab.  This time there is no list,  just the word ‘__class__’ is added to the end of the line.  This tells me that there are no other commands ‘beneath’ hub.display.show. 

The end of the line!

So, what if I type  hub.display.show()  ?  Try it.

This shows the output of the mathod call.
 

Mine shows a string of numbers. The first 5 digits are the top row of the display, the second the next row down etc..  9 means the light is on, 0 means it is off (would 5 mean it is on but only at half brightness - I do not know)

Now type hub.display.show(‘My name is Bob’)  and when you press enter, watch the display on the hub! 

Look at the light matrix on the hub.


That’s all I’ve got time for today.  Try the above procedure to find other commands and see what they do.  Please comment below if you find any interesting ones!”


In Part 3 of this series we'll look at what else is on the hub.





Comments