Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very cool. #27

Open
bitdivine opened this issue Nov 2, 2023 · 2 comments
Open

Very cool. #27

bitdivine opened this issue Nov 2, 2023 · 2 comments

Comments

@bitdivine
Copy link

bitdivine commented Nov 2, 2023

Very cool. Thank you! My son has two Lego trains with Powered Up battery packs inside. With your code I can change the colour of the light on the battery pack. Can you give me some pointer to how to control the motor? I guess the motor in the UI is specific to Vernie?

Update: I traced the code and found https://github.com/ttu/lego-boost-browser - it looks as if the actual driver is in there.

@ttu
Copy link
Owner

ttu commented Nov 4, 2023

Hi!

What kind of hub + motor the train uses? Is the hub this one?
https://www.lego.com/en-us/product/hub-88009

Lego Boost (Vernie) has a hub and motor combined in a single unit. It basically has a 4 ports for motors, A,B,C,D.
https://www.lego.com/en-fi/product/move-hub-88006

Here are the port values in the controlling code:
https://github.com/ttu/lego-boost-browser/blob/61cffdf6c05f143a2b28483460585691af516cde/src/hub/hub.ts#L62

Apparently at least the port for the led is same, as you could change the color of the light :)

Sending motor commands:
https://github.com/ttu/lego-boost-browser/blob/61cffdf6c05f143a2b28483460585691af516cde/src/hub/hub.ts#L273

Many of the commands are designed to be used with Vernie, so many commands are sent to A or B ports.
https://github.com/ttu/lego-boost-browser/blob/61cffdf6c05f143a2b28483460585691af516cde/src/hub/hubAsync.ts#L202

You can try to control each individual motor from this view, but I suppose if hub for the train is different, it is possible that port values for the motors are different
https://legoboost.azurewebsites.net/motors

It is possible that we could extend the code to support also other hubs, as based on the LED, some commands seem to be working 👍

@bitdivine
Copy link
Author

Hello Tomi,

Yes, that is the hub.

Thank you very much for the references. I will need some time to read through and understand them all.

I did actually go out and buy a Vernie yesterday, with the idea that I could get one system working and then move from one type of living, working system to another. The one motor I plugged in to Vernie's hub worked in positional mode, like a servo, (Port D on the hub, port C in the UI; perhaps the labelling varies between devices or maybe everything needs to be plugged in for the labelling to match). The internal motors in the hub did not spin. However hopefully with a bit of study I will be able to get everything working, and then on to trains! :-)

Best wishes, Max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants