Presentation is loading. Please wait.

Presentation is loading. Please wait.

LEGO Robotics Lecture 1: Getting acquainted with your robotic environment.

Similar presentations

Presentation on theme: "LEGO Robotics Lecture 1: Getting acquainted with your robotic environment."— Presentation transcript:

1 LEGO Robotics Lecture 1: Getting acquainted with your robotic environment

2 Getting to know your Robotics Environment You will be using: –The parts in the kit build the bots –Computer write, compile and debug programs –The infrared (IR) tower Communicate with the brick –The RCX brick To power and control you robot

3 Programming Open program called “Bricx Command Center” –Select “COM1,” click “ok.” –Turn on the brick and place the IR sensor side of it facing the IR tower –Start a new file

4 For a list of commands, either hit the “F9” key or select View  templates from the menu bar The command list is very useful! Every command you might need is here. Now, we just have to learn how to use the commands!

5 Now some programming Write the following EXACTLY as it is written –Punctuation, upper/lower case, etc task main() { OnFwd(OUT_A); } –You could also insert the command OnFwd() without typing by finding it in the templates menu and clicking on it –What does this mean?? It will make more sense soon

6 Compiling (constructing) Many ways to compile: “F5” key, the compile menu, or this button If all is well, you will get no errors Errors appear here Most common error is a “parse error.” This means that you are not following the rules of the programming language There are many ways to upload: “F6,” the compile menu bar or this button (Brick must be on & facing tower). Selects which program slot (1-5) the program downloads to

7 Hooking up motors Using a wire, connect a motor to the “A” connector of the RCX brick The “program” key on the brick will cycle through the choice of programs to run. Select the program slot that you downloaded to On the brick click “run.” What happens???

8 Turn on two motors Write the following EXACTLY as it is written –Punctuation, upper/lower case, etc task main() { OnFwd(OUT_A+OUT_C); } Or you could use OnFwd(OUT_AC); –This time connect motors to A and C. Compile, –download and run like before. What happens?

9 Reverse motor direction 1) rotate connector orientation 180 degrees Or use –OnRev( ) command in place on OnFwd( )

10 Motor: starting and stopping Try this code: Task main() { OnFwd(OUT_A); Off(OUT_A); } Upload and run the program like before, correcting any errors.

11 Motor: starting and Stopping What happened? Run the program again and look carefully! Did the motor do what you thought it would do, or what you told it to do?

12 Ah, the computer is quick! The brick executes commands pretty quickly, so you saw the motor turn on for a very very short time and then turn off How can we tell the program to keep the motor on? –There are many ways to do this but lets try this command … Wait ("time"); Where “time” is a value in hundredths (.01) of a second Example –Wait(100) will pause for 1 second, or 100 hundredths of a second Time=.01sec*100 =1sec  “time is 100.01 seconds” –Wait(1500) will pause for 15 seconds, or1,500 hundredths of a second Time=.01sec*1500 seconds=15sec  “time is 1500.01 seconds”

13 Now modify your program using the wait command in the appropriate place Make the motor turn on for 5sec, and then turn off. Did it work?

14 Task for the day: Build a robot –Your choice of how to build it –Focus on functionality and simplicity, not looks! From a starting point, program your robot to: –Drive forward and stop exactly 6 feet from the starting point as quickly as possible –Pretend that there is a little LEGO man 6 feet away and you want to really scare him, but not hit him. –You will compete with other teams for the closest distance without hitting the man. You may work on this with remaining time today and the majority of next class

15 Turn in for class credit Submit a copy of your program Plot the position, acceleration and velocity of the robot as a function of time. –Remember, position is how many feet the robot travels in a certain time, velocity how many feet/sec the robot travels in a second and acceleration is the change in velocity (think back to physics class freshman year!)

Download ppt "LEGO Robotics Lecture 1: Getting acquainted with your robotic environment."

Similar presentations

Ads by Google