Search the Community
Showing results for tags 'brake'.
Found 2 results
Andman posted a topic in LEGO Technic, Model Team and Scale ModelingI'm missing a place where Powered Up code can be gathered and explained so other guys can reuse it or find inspiration. I had a discussion with @Jim how that could work out in this forum. I was thinking about having something like the hall of fame for code which underwent optimizations in a dedicated thread and which was proven to work. But this might lead to several thread which are prone to be inactive. So we decided to start with a single thread to publish PU code and discuss it. If it gets to chaotic We could have two separate thread. One for discussion and help request and the other one for working and optimized code. To keep things orderly, a general structure might be helpful. So here we start with my proposal. TL;DR: Automatic brake lights based on speed reduction Description: The following code switches brakes lights on in case the speed is reduced. That works for reducing speed while driving forward and backward. When the speed reaches 0, the light are turned off. In this code I'm using PF lights controlled by the Boost color and distance sensor. But that can be replaced with PU lights. Code: Video Declaration of variables: a - Used to control the speed, is set by the slider 0 b - Speed (a) at the first point in time c - Speed (a) at the second point in time d - Speed difference between b and c Detailed walkthrough: The code block consists of three rows. The first row consists of a loop (left) and the code block to control the speed of the motor (right). Most of the code blocks in the loop are not needed. You actually just need the first block which sets constantly a value for the variable a to control the speed. The rest are widgets for testing timings. The second row is the logic to detect speed differences. To do that constantly, a loop is used again. It simply reads a, the speed at different times. You can adjust the time between the measurments according to your needs. In my case 0,08s worked well. At the end of the loop the difference is set to the variable d. The value can be something between 100 and -100. The third loop at the bottom contains the logic to turn the brake lights on or off. You will also notice the purple blocks. They are used to control the PF lights. I'll come to that in a bit. First i want to explain the logic to turn the lights off an on. There are three scenarios: Driving forwards Driving backwards Parking When you are driving forward the max value of a is 100. Lets say the speed is suddenly reduced to 50. The difference is 50. When you are driving backwards the max value for a is -100. The speed is again reduced by 50. The difference is -50. When you are parking the difference is of course 0, because it doesn't change. So i have two condition i want to check for: Am I driving backwards or forwards? Is there a speed difference? I can exclude the third check, parking, by checking values for a that are greater or smaller than 0. So, in one sentence: IF there is a speed difference AND the speed is GREATER THAN 0 OR IF there is a speed difference AND the speed is SMALLER THAN 0 then turn on the light (upper purple block at the end). But how to control PF lights with Powered UP??? That is covered for example by @kbalage here. The first purple code block on the left sets the port and the correct mode for the boost sensor. The two purple code blocks on the right side control the brightness of the PF lights. D is the port where the sensor is connected to, 3 is the channel 4 on the PF IR receiver, 5 is the red or blue port on the IR receiver, 7 switches the light to max brightness, 8 turns it off.
Hello everybody! I hasten to introduce you to a new job: Pneumatic Disc Brakes Lego Technic. In work details were modified. Try to bet on Chiron. Disks I have no) Subscribe to the Shannel / Подписывайтесь на Канал YouTube - Subscribe