12/20/2023 0 Comments Wedo projects![]() ![]() Select which lane the traffic will appear inĮach side of the road has two lanes, and both lanes need traffic. That will be on the left-hand side at the top. Looking at the starting coordinates for the traffic on the left, the coordinates are -152,170. ![]() A positive number will be in the top half of the screen, and a negative number at the bottom. So, an x-coordinate of a negative number will be on the left of centre, and a positive number will be on the right. Coordinate 0,0 (x,y) is in the centre of the screen. The starting coordinates, on the blue line at the top, tell the sprite where to begin. Coding for the traffic (in both directions) When the tilt sensor is more than 20 degrees to the right, the car will change to the diagonally-right costume, and move 10 pixels horizontally to the right. ![]() The third condition does the same as the second, but to the right. This moves the car 10 pixels to the left, along the horizontal. That’s what the blue line of code is for – change x by -10. At the same time, you want the car to move sideways so it can change lanes. When the condition is met, costume 2 will show, where the car is facing diagonally left. (Vertical = less than 20 degrees, Left = more than 20 degrees.) If you change the vertical range in Condition 1, make sure you update Conditions 2 and 3 to match. The degrees selected should be the same as the condition for vertical, so that there’s no overlap or gap in the code. The second condition applies when the tilt sensor is more than 20 degrees to the left. We found that 20 degrees either side was good, but you may prefer something different. If the range is too small, you’ll find it hard to hold the steering wheel close enough to vertical, and the racing car will veer off to the side when you don’t want it to. Very important for this part of the code is to nominate a suitable range either side of vertical. Under those conditions, costume 1 will show, which is when the car is facing straight ahead. The first part of this code applies when the tilt sensor is close to vertical – less than 20 degrees either left or right. All three are inside a forever loop, so the sprite will constantly check which condition is applicable. That’s one condition for each costume, so that the sprite knows what to do. Notice that there are three ‘if’ conditions in this section of code. At the same time, we want the car to move left or right when we turn the steering wheel, so the blue lines of code tell the car to move along the horizontal axis.įinal part of the code for the racing car, using Lego Wedo tilt sensor blocks It’s controlled by the tilt angle of the sensor, either left, right, or vertical. The first is to control which costume is used for the racing car sprite. In this code, the tilt sensor is used to instruct two different actions simultaneously. How to connect Lego Wedo 2.0 to Scratch.We’re using the left/right detection in the code for the racing car game. For the racing car project, the sensor is fixed vertically to the central bar of the steering wheel. The sensor can detect up/down and left/right movement, which it feeds to the smarthub. The steering wheel was the first project that required the sensor, so there was a lot of learning. Liam has been working on some other Wedo projects recently, but they’ve been using only the motor and the smarthub. The tilt sensor is one of the key components in the Lego Wedo 2.0 kit, along with a motion sensor, motor and smarthub. ![]() Lego Wedo tilt sensor attached to the back of the steering wheel It’s taken a while, but it’s definitely worth getting the rest of the code up and running. In the final section of code, the Lego Wedo tilt sensor finally comes into the game. These multiple tools are combined to introduce students to multiple programming languages through which they can learn coding basic principles via hands on applied projects.Racing car code part 3 – when the car crashes Part 4 – using the tilt sensor on the steering wheel The Scratch program also includes an extension package for the WeDo 2.0 which enables using the Scratch programming blocks to interact with your WeDo 2.0 creations and add visual animations and sounds. Accompanying guides helps teachers to become confident users of the WeDo 2.0 Core Set. The WeDo 2.0 Curriculum Pack covers life, physical, earth, and space sciences, as well as engineering, based upon the latest science standards and was created to enhance students' curiosity and science skills. There are 27 lessons provided per grade that include a combination of LEGO Education WeDo 2.0 source projects, LKD publishing WeDo 2.0 source projects, as well as, LKD publishing Scratch coding projects (using the MIT Scratch programming language and software). LKD publishing authors have created this resource to expand on the number of lesson plans provided by LEGO Education’s WeDo 2.0 product targeting primary levels. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |