Jump to content
THIS IS THE TEST SITE OF EUROBRICKS! ×
THIS IS THE TEST SITE OF EUROBRICKS!

Recommended Posts

Posted

   I have 2 trains that I’ve tried to control using the (latest) Lego Powered Up app via my I-Phone.  One train is Lego's ‘Crocodile’, with (what appears to be) the ‘large' Lego Technic motor.  The other train is an adaptation of Lego's ‘Emerald Night’, which has been modified to operate via two Lego ‘train’ motors under the (extended) tender.  Both trains have been known to run well, - but only if one bluetooth hub has been connected to the P-U app.  I’ve used the app’s included ‘Crocodile’ user interface for that engine, and the included ‘Disney’ user interface for the Emerald Night.

  My problem is that I find it exceedingly difficult (- to nearly impossible!) to switch quickly / easily between the 2 trains on the P-U app.  It seems that the app will only connect to the ‘last’ engine hub used, - and even after multiple tries at closing down that hub, it doesn’t really completely disconnect, and the 2nd engine will not run.

   So, I’ve started the process of trying to understand, and use, the special Projects coding option in the app (which is at this point in time are Lego’s ‘light yellow' coding blocks).  However, after endless tries at building a coding sequence, I simply cannot find a way to control the train motor with a simple ‘Variable Speed’ control….(!)  The only results I get are that the motor either runs at the initial speed setting (before hitting the ’Start’ block), - or it doesn’t run at all.  I just can’t find a way to input a ‘Variable Speed’ coding block, or input something that will vary the speed of the motor.

  The ‘Net’ is that all I want to do for each engine (hub) is to: a) ‘Start’ the engine; b) vary the speed Forward, and/or Reverse: c) then ‘Stop the engine.  I don’t know why this is so difficult…(!?)  Can anyone advise…?  Better yet, is someone in position to simply post the coding blocks sequence to do this for one (1) engine…?  (Note: my conceptual approach is that I would do 2 separate ‘Projects’, - one for each engine.  I would just give each one a different name)

  Many thanks in advance...

Posted
11 minutes ago, 2_ft_Builders said:

that I would do 2 separate ‘Projects’, - one for each engine.

Why?

What you need is a controller with two sliders.
Here is what I answered yesterday in another thread.

Use "controller", add two sliders, add  two blocks to read the sliders and sent the values to the specific  ports and hub.

 

 

Posted

OK.  What would the coding blocks sequence look like….?

(Note:  I am totally new to P-U coding.  So, I'm not as familiar as I’d like to be with the terminology, what these look like, and how they are connected…)

Posted (edited)

Hi, in a first approach the is no sequence , because for this application there is  a  complete control block

Starting the Powered Up app you have the choice between "Play" and "Create"  (in English, upper right)
With "Play" you can choose a certain set. But there is no predefined program for your requirements

So you can select "create", add a new project, name it and then choose "controller".
Add two slider- "widgets". Could look like this. Note the numbers.

http://www.werner-falkenbach.de/bricks/PoweredUp-Sliders.jpg

And the program:

http://www.werner-falkenbach.de/bricks/PoweredUp-Loop.jpg

Refers to "HUB1", "Port A" and slider no "1"
So you'll need this twice with different hubs, ports , slider.

There is also a list of all blocks with explanations on the LEGO site.

Edited by Lok24
Posted

Excellent….!  Most helpful.  I’ll look into it straight away.

Many thanks for your time and assistance.  If I run into any ‘issues’, I’ll revert on the Forum.

Best -

Posted (edited)
21 minutes ago, idlemarvel said:

You can download a book on powered up app programming here on this site. It's free to eurobricks users.  

(BTW:  I can't insert pictures from a link any more, it's just me?)

Edited by Lok24
Posted

Aha….  These look very cool…!

I loaded up the earlier coding blocks you sent, and this works fine, - albeit the top speed of the motor seems to run rather slower than I would like.  Perhaps is there a way to adjust this…. (?)

I’ll load up the ‘Advanced Version(s)’ for these, and will be keen to see how they work, i.e.:  what additional controls / features these bring...

Thanks again. 

(PS:  to David (‘IdleMarvel'), I just downloaded your Lego Powered Up Pocketbook, and it looks to be a tremendous resource !  151 pages… Whew….!!

Posted

So, Lok24….  

  I loaded up the P-U blocks per the ‘Advanced’ sequence that you sent into a new ‘Project’ for my ‘Crocodile’ engine (#1).  After a (short) bit of futzing around, it all worked very well, and delivered the simple motor control that I was looking for…  Hooray…!!~

  Subsequent to this, I created an entirely new (& separate) ‘Project’ for my 'Emerald Night’ engine (#2), and loaded up exactly (!!) the same sets of coding blocks.  On initiating the ‘start’ for this program, it seems that I am running into a similar version of one of the same problems that I had when trying to switch to a different engine, namely:  There is some hindrance in the app that prevents me from making this switch seamlessly.  Net:  the engine simply doesn’t respond.  It’s like there’s no Bluetooth link to the I-Phone app.  One indicator of the problem is that on engine #2, the coding in the app won’t let me change the Hub to #2.  It simply puts up a plain Hub icon, - with no number, and won’t let me change to Hub#2 (… or any other Hub number !!).  I turned Hubs ‘On’ and ‘Off’ repeatedly for both engines, - same result.  I don’t know if this is some syndrome that is unique to my Hubs, or whether it has been seen before in the Lego / Train Tech community….

  Any thoughts…?

  Thanks -

Posted

You have to connect the app to both hubs by pressing the bluetooth icon. By default they will be numbered hub 1 and 2. Then in your code you have to specify any hub other than the default (1) using a maths block (the pink blocks) as input to the port on the motor block. With that you can specify the hub and port that the train motor is connected to.

Posted (edited)
11 hours ago, 2_ft_Builders said:

Subsequent to this, I created an entirely new (& separate) ‘Project’ for my 'Emerald Night’ engine (#2), and loaded up exactly (!!) the same sets of coding blocks.

You don' need a additional project.

You have two sliders for two trains in one(!) project . What you have to duplicate is just the two sequences (drive/display  and brake) in the same project on the surface.

As @idlemarvel wrote you have to see both(!) hubs connected on the "BT"-screen

Edited by Lok24
Posted

Lok24 and Idlemarvel….

So ….. (- per your most appreciated counsel), I re-developed the coding blocks / sequence on one (only !!) project palette, with the net result being that both trains can now be successfully and independently run (!).  I have to say that I am quite pleased with this outcome.  I’ve learned a lot along the way, plodding through the tech world of ‘coding’, - which although I understand the ‘jist’ of it, isn’t quite in my wheelhouse.  But, a thoroughly enjoyable learning experience, nevertheless.

I do have to say that there is one thing that I discovered along the way, which I found both interesting and confounding:  After connecting the first Hub to the App (- which appropriately showed up as ‘Hub1’), I then proceeded to connect the second Hub to the App.  On doing this, when I endeavored to change to ‘Hub2’ on the selection menu, the ID on the hub coding block just read as ‘Hub’, - with no number identifier.  However, I decided to go ahead and give it a try anyway.  I first successfully ran engine #1 on ‘Hub1’, and then when I switched to ‘Hub2’, to my surprise, engine #2 successfully ran as well…. (!).  It seems strange to me that when trying to enter another Hub ID number on the App, the Hub number doesn’t show upon the coding block.  This makes it seem as though 'trying’ to make the switch was a ‘Fail’, which then just causes more ‘Confusion and Delay’ (…a familiar phrase).

I’ve attached a pic of the coding blocks palette for your review….  

BTW, I initially tried to do this by including an ‘IfSwitch’ (True-False) Flow block, through which I thought I could apply the logic of:  “ If the Hub ID is ‘Hub1', then proceed on the upper path, otherwise proceed on the Lower path (which would then be ‘Hub2’) “  After some time, I gave up, because I couldn’t figure out how to do the requisite Hub identification via one of the ‘Math’ blocks.  Maybe you guys can enlighten me on this…. (?)

Next, I plan on exploring adding a ‘Light’ control to one of my engines.  Seems like this shouldn’t be too complex, but if I run into any ‘issues’, I’ll be back to you.

Again, many "Thanks!” from a coding ‘newbie’….

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...