lego light brick switch

lego light brick switch

lego light brick battery

Lego Light Brick Switch

CLICK HERE TO CONTINUE




Lego EV3‎ > ‎The missing commentaries‎ > ‎ The interest of the exercise is of course that it demonstrates multitasking i.e. the ability of an EV3 program to run multiple branches or 'threads' simultaneously. This program splits into two branches after the start block, so both branches will run simultaneouslon! Loops are importan
. The block header indicates that the sound file 'click' has been selected. The volume has been set to 100% and the 'play type' has been set to 'wait for completion' (option 0) which means that the sound will play once and that the program will wait for the sound to complete before continuing. Loop 03 also contains a wait block in 'time' mode with the number of seconds set to 1, so there will be a one second pause after the click sound stops. The loop 03 block itself is in 'count' mode  the number of counts set to 2, so the contents of the loop will be run twice and the robot will go 'click, pause, click, pause'. Once the program has exited loop 03 a move steering block in 'rotations' mode will make the robot move straight with 50% power for 1 rotation of the whee




ls. Loop 02 is in 'unlimited' mode meaning it will repeat until stopped by some other block. Let's not forget about the lower loop, which is running simultaneously with the upper loop. The lower loop contains a wait block in mode 'touch sensor>compare>state'. The 'state' parameter is set to 'pressed' (option 1) so the block will continuously compare the actual state of the touch sensor with the 'pressed' state, ending the wait when they are equal, in other words when the actual state of the switch is (equal to) 'pressed'. The block also contains a 'measured value' output which is not used here. The last block is a 'loop interrupt' block which has only one mode and which will interrupt the loop named in the block's header (loop 02 in this case). To summarize, this program first makes the brick's status light pulse red for two seconds, then clicks twice and moves forwards one wheel rotation, repeatedly clicking and moving until the touch sensor is presseon! Switches are importa




nt! This program contains a loop block which is set to repeat forever (until the program is stopped by the user pressing the 'back' button on the brick). Within the loop block is a switch block in mode 'colour sensor>compare>reflected light intensity'. The 'compare type' is set to 'less than' (option 4) and the threshold value is set to 50%. So the switch block will test whether the measured reflected light intensity is less than 50%. If that condition is met or 'true' then the top branch of the switch will be run (notice the check mark above this branch). The top branch has a 'large motor' block in 'off' mode, which will switch off motor C (the right motor). The second large motor block will turn on motor B (the left motor) at 50% power, making the robot turn medium right. Since the loop is set to repeat forever the robot will turn right as long as the reflected light intensity is less than 50%, such as when the sensor is over a black line. The lower branch of the switch loop does the opposite, making the robot turn medium left if the sensor detects strong reflected light, such as when the sensor is  a white surfac




e. This program is in fact a simple form of 'line follower' program. The intention is that the robot will follow a black line that has been drawn on a white mat. This is a little difficult to do using only a single colour sensor. Imagine that the robot is moving along the line with the sensor over the black line, then the sensor will detect very little light being reflected. If the robot wanders off the line then the sensor will detect a strong reflected light intensity, but how useful is that information? The robot won't know whether it has wandered off the left side of the line or the right, so it won't know how to turn. So the trick is not to try to follow 'the line', it is to follow one edge of the black line, let's say the right edge. Now if the sensor detects that it is over white then we know the robot should turn left to find the edge again and if black right 4. Multiple Switft yellowright What if the sensor detects some other colour, like red? The top branch will activate since this is the 'default' branch, as shown by the black dot at the top of that branc




h. logical valuedata wireyellow numeric value. The next block is a 'text' block which has only one mode: merge. Its function is to 'merge' or 'join' or 'concatenate' two or three pieces of text together and to output the result. In this case the block will  together the number received through the yellow data wire (which represents the distance to the block) and the text string " cm". The text string is called a 'string' because it is a string of characters. Note that the text string contains a space as well as the two letters. It's OK for the text block to receive a number on one if its inputs even when it is expecting text because the block is smart enough to know how to convert that number into a text string. The text block outputs the joined-up text through a data wire that is coloured orange to indicate that it is carrying text. a display block in 'text grid' mode. It receives the text from the previous block through the orange data wire, clears the screen, displays the text beginning in position (5,6) on the screen's text grid which is 22 cells wide in the x direction and 12 cells tall in the y directi




on. The top-left text cell has coordinates (0,0) and the bottom-right cell has coordinates (21,11). Thus the text will appear somewhere near the  of the grid. The text colour is set to 'false' meaning 'black' and the font is set to 'Large' (option 2). In the 'Large' font each character occupies 2 text cells horizontally and 2 text cells vertically, so in this font the screen can display 6 rows of 11 characters each. a certain logical condition is met, or 'true'. The loop control input is connected to the green data wire which, as explained previously, will carry the value 'true' when the ultrasonic detector detects that the distance to the  object is less than 8 com The random block is in numeric mode and generates random integers between -70 and 70. The generated integer is output through the yellow data wire to a 'move steering' block which drives in a straight line with a random power between -70% (backwards) and +70% (forwards), the random power setting coming from the random blo

Report Page