Jump to content

Recommended Posts

Posted

Hello,

I'd be grateful for help with Powered Up coding please.

I'm using the colour and distance sensor 88007 fitted to the underside of a train.

I've tested many different colour tiles using the report function and have settled on a small range of colours that return true readings.

Unfortunately I still get false readings from other blank parts of my track, with yellow and blue falsely triggering actions when the tile doesn't exist in that location.

I notice that the distance reading does seem reliable so a coloured tile placed on the track shows a 0 distance whereas the  sleepers and track bed read 1 and 3/4 respectively.

What I'd like to do with the code is have an action triggered only when, for example, the sensor reads a 0 distance AND blue at the same time. The closest I've come to making this work is the ForkJoin flow block but the sensor can read a false colour elsewhere on the track, then detect the correct 0 distance (on a different coloured tile) before it moves to the next block.

Ideally the code would only progress once both colour and distance conditions are met simultaneously. If only one condition is met, the code should revert to a state where it looks for a new instance of the condition.

I've attached a basic example of my code.

Any help would be greatly appreciated

Screenshot_20221207_113638_PoweredUp.jpg

Posted (edited)

first and fast idea (without test or APP):

In a loop:
- read sensor by distance and store in a variable
- read sensor by color and store in variable
- then you can check both variables with AND on your condition and let execute an action e.g. over a flag.

 

Thomas

Edited by Ts__
Posted

Thanks so much, your idea worked perfectly and I have a far better understanding of the app now.

I've attached a screenshot of it's of help to anyone else.

Screenshot_20221207_205145_PoweredUp.jpg

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...