Tuesday, June 9, 2015

Transcript - Hands-On Robotics (cont.)

Class: Informatics, Computing, and the Future
Instructor: Dan Berleant
Transcriber: Brooke Yu
Date: Tuesday, April 16, 2013

Professor:  Here's a diagram reminding you how to plug those in with the arrow facing outward, just so you know.  So you weren't here to see it before Collin.  Did you get it working? 

Male Student:  I mean, the lights are on. 

Professor:  Alright, great.  Just go ahead and grab a robot.  Also, robots are fun, maybe not as much fun as your next homework.  But they're becoming less time consuming so you can work on your project. 

So take a look at the homework to see if you have any questions. 

Alright, so those who weren't here last time might have to rely on your neighbors or ask for help in this exercise, but I think you'll be able to pick up the essentials from last time. 

So any questions on the next homework?  Anything?  Projects?  Anything?  Let's take a look at what we have going on.  Next time we already have four people signed up for presentations, so next time we'll just have presentations. 

The date after that, there's two people who have to give presentations.  If we have time left over, we might talk more about robots.  We might not use the real robots because of time, but we'll talk about them.  This is Thursday [On board.]  

Next Tuesday, a week from today.  Then a week from Thursday, three presentations.  Then way off on the 30th, three more presentations.  There's two people in the class with the initials "R.M."  On the last day of class, two more presentations are scheduled. 

There will not be a final exam, and you don't have to show up unless you're making up assignments.  You can hand in your project via email.  If you're behind on the homeworks, you have to come the day of the final to make up assignments.  Any questions?  We're getting close to the end now, so I want everyone to be reasonably clear on things. 

To review a couple of things- you've already got your robots hooked up.   Does anyone remember what the first number that you send to the robot is?

Male Student:  121? 

Professor:  Close, 128.  And what does it mean? 

Male Student:  Like "recognize me" or something like that. 

Professor:  Yeah, it's like the start command.  Okay, so the first one is 128.  The second is 131 or 132.  131 gives the robot some control over its fate, so if you tell it to roll over the edge the table it'll stop.  132 gives you full control over the robot's fate.  We're going to deal more with 131 today. 

If you want to run a program, you first type 128 131 or 132. 

128 is start.  131 means "take partial command."  And 132 is "take full Command."  Any time you tell the robot to do anything, you have to preface it with these. 

Male Student:  Do you do these individually or put them all on the same line?

Professor:  You can put them all on the same and it should be fine. 

So if you try it now- try 131 this time.  The little light should go off meaning that you haven't told any lights to be on, okay? 

So everybody send these numbers and make the light go off. 

Is everybody's little light off?  Okay. 

So last time we controlled the lights.  Last time we made it do music and stuff too.  So let's focus on motion today

What makes a robot a robot?  It can move!  Once you set the initialization and take partial command, you can tell it to move.  Here's a movement command.  Alright, someone made it work.  Be ready to grab it because it'll break the cord or mess something up if you make it go too far because the wheels grip pretty well. 

Try this command- it's five different numbers which I'll explain after you get it working. 

And help your neighbored out if they weren't here last time. 

If you run into problems and it doesn't work, just raise your hand. 

It'll break your computer if you're not careful. 

Male Student:  It doesn't work with 131 for some reason. 

Professor:  Okay, let's check it. 

Male Student:  Oh, it was turned off. 

Professor:  Aha.  That's easy to do.  Power cycle it if it doesn't work.  Turn it off and turn it back on. 

Okay, let's see what's going on here with that motion command.  As you know from last time, you know, as a programming language it's not very user friendly.  So 137 is the command for going- or driving.  It has four arguments to it which is why this line has five numbers- the command and its four arguments. 

So 137 says drive.  The next two numbers are two parts of one argument- 0 100 says go 100 mm/sec.  So this is the one's place and this is the 256th place so if you have 100 here, that's 100, so 0 100 says go 0 times 256 + 100 mm/sec. 

And then there's two more bytes.  This is the direction, except it's a special direction.  This is very arbitrary.  128 0 means go straight. 

Male Student:  If you put 100 100, it likes to go fast. 

Professor:  Yeah.  If you put 100 here and 100 here, it should be 100 times 256 + 100 mm/sec.  But there is a maximum speed. 

Male Student:  What's the max speed? 

Professor:  Well, I don't know.  I have a document that says.  It's not outrageous.  Okay, so play around with that.  Try to find not the fastest- well, you can if you want.  But try to figure out the slowest speed- you'll be able to notice when it won't go at all.  Try to figure out the slowest speed to make it go. 

So while you're figuring that out, I'll circulate and help make sure everyone is on the right track. 

Professor:  Yes, you can go backwards. 

How about you?  How are things going? 

Alright. 

Professor:  Okay, so someone got it to go in circles.  How did you do that?

Male Student:  Change 128 to 0. 

Professor:  Since you mentioned it, I'll try it here.  I don't know what the numbers are for going backwards.  How slow could you make it go? 

Female Student:  10

Professor:  What happens when you put a 9 here? 

Male Student:  8 works for me. 

Professor:  Alright, so your robot would handle 8 mm/sec, and others wouldn't even handle 9.  I guess that's because the motors have manufacturing variability.  Anyone get it below 8? 

Female Student:  Mine goes on 8, but it won't go on 7. 

Professor:  What else?  How many people have tried the 158 command?  A couple people did.  Let's talk a little about that so it'd be nice to make so you could send the go command and not have it go until you're ready for it to go.  One way to do that is the 158 command which is a "wait Command."  It tells it to wait for something.  There are several options for this. 

Option 5 is a bump on the bumper.  If you type 158 5, then the robot will not do anything until you tap it on the bumper.  The bumper is right here, so if you send the 158 5 command, it'll wait until you bump it. 

So here, I've strung this together with a go command.  158 5 says wait until you bump it, then 137 says go.  So this robot won't do anything until you tap the bumper.  When you tap it, it'll start going. 

At the end of class today, it'd like to have everyone bring their robots down here and tap the bumper without the cord attached then have it do something. 

Male Student:  So the program will be there until you turn it off? 

Professor:  Right, it'll be there until you turn it off. 

Male Student:  So you can write something to it, unplug it, put it on the ground, and it'll do it? 

Professor:  Yes.  You can also pull the plug out while it's doing it and it'll keep going, but please don't do that. 

Questions? 

Okay.  So give this a shot and we'll go on from there. 

While you're experimenting, I'm going to make a note on the board. 

How are things going over here? 

Female Student:  Good. 

Professor:  Things working out? 

Male Student:  Yep. 

Male Student:  Mine says "battery current 0." 

Professor:  I don't think so, because the light is on. 

Male Student:  Okay. 

Professor:  A lot of people are realizing that if the robot is a little bit off the table, this cliff sensor will be activated and it won't go.  The robot will be afraid to go. 

Good?  Alright. 

Professor:  Okay, let's see what else we've got here. 

Alright, well, things get even more complicated then this.  So here's a small example of a complete program.  Let's analyze what it does. 

Actually, here's a new command, 156, which I'll explain, and 157 and 152.  Let's see what they do. 

152 is a script defining command.  This just means we're going to define a longer program.  And how long is it going to be?  It's going to be 17 bytes.  So the first number after 152 is the length of the program. 

So it's 17 bytes, and here are the 17 bytes.  It's 17 bytes long. 

Okay, so what is in these 17 bytes?  The first five bites are our go command.  It says drive 44 mm/sec and drive straight . if there was a 1 here instead of 0, it'd be 3 meters per second. 

After the go command, there's a 156 command, which has 2 arguments.  It says wait until you go a certain distance- until you go 144 millimeters.  This is basically going to drive until it goes 144 millimeters and then it'll go on to the next part of the program.  So go 144 millimeters, then go again... notice instead of 128 0, we have... sorry, instead of 128 0, we've got 0 1 for the last two arguments. 

128 0 means go straight.  0 1 means spin counterclockwise.  So it'll go 144 millimeters, then it's going to go again, but this time with a 0 1, so it'll spin counter clockwise. 

Then it's going to execute a 157 command which is another wait command, which says "wait until you've gone 90 degrees."  Then 153 says "repeat the Script."  So 153 is a loop command.  Let's review

It goes 44 mm/sec.  It waits until it goes 144 millimeters, then it'll spin counterclockwise until it has gone 90 degrees, then it will go back to the beginning so it goes straight again for 144 millimeters.  

So it'll go for 144 millimeters, then it'll spin counterclockwise 90 degrees, go another 44 millimeters, spin counterclockwise 90 degrees, and it'll go in a square.  If 144 millimeters is too much for your table, you can make it go 10 millimeters.  If you knew how to do the math, you could make it go in a triangle or a pentagon or whatever you wanted to do. 

152 says define a script, 153 says run a script.  In essence, that's the script- go and turn, then it repeats by going back to the beginning. 

To start it out, you have to do your 128 131.  You might have to put it on the floor for this, or use a really small square- make it go 10 millimeters instead of 144.  But you can experiment with it. 

You have to run the script the first time.  All this does is define the script with the 152 command.  To run it the first time, you have to send a 153 to run the script.  So there's a 153 here which says to run it again, but you can't repeat it unless you've already run it once so you have to use 153.  If you want, you can wait for a bump and then run the script. 

I know this is a lot.  Just experiment with it and see what you can do. 

If the cord is getting really twisted, you might want to unplug it and untwist it, then plug it back in. 

While you're experimenting, I'm going to write the commands we've been using on the board for reference. 

I've written all the commands we've looked at so far on the board. 

Questions?  Raise your hand if you have a question and I'll try to come by and help you.  No questions? 

The next step them is for you to connect all of these commands together.  Make a script so that you can bump the bumper to run your program so we can bring them to the front of the class.  

If you remember from last time, you can make it go with script, make it play music....

How are this going over here? 

Female Student:  I don't think mine is working. 

Professor:  How are things going with you?  If you're sending a 131 command, you should make it stop by just picking up the side of it.  Are you using 131 or 132? 

Okay, yeah.  So if you just pick up the side the cliff sensor will activate. 

If anyone wants to see what other commands are available, raise your hand and I'll bring the document around.  We only have 25 minutes left.  So work on a script you can show the class at the end.   Try experimenting to make it do something after you push the bumper.  We'll spend the last 7 or 8 minutes of class doing that.  So you have about 17 minutes left to develop your script. 

Be really careful the those cables because they bend really easily.   We've already had a couple bend. 

Male Student:  So to add more bits, does that have to match the rest of numbers? 

Professor:  The 17?  Yes. 

Male Student:  Does that count spaces or just numbers? 

Professor:  Just numbers.  If you put an 18 there but you only have 17 bytes, it won't go until it gets the 18th number. 

Professor:  Not really.  There's no actual stop command.  You just have to pick up the edge or something. 

Male Student:  Like the song thing.  Can you not just add to the front of this and then whatever you already have? 

Professor:  Yeah, you could run the song and then do a 153. 

Male Student:  Well, can you look at this? 

Professor:  I guess now is a god time to make sure you can test whatever you have it to do so you can bring it up to the front and it'll work.  Make sure you can tap the bumper and it'll do something.  Then in a couple of minutes we'll do the demos. 

Alright, if you're ready to demo it, put it up here. I realize that just spending a few minutes in one class is not enough to get it to water your plants, but that's okay. 

Are you ready?

Female Student:  One more try. 

Professor:  Haha, okay. 

If you're using a 131 command, I don't think it'll let you move it or pick it up, so you might have to use a 132 command maybe we should just demo them at our seats

Alright, let's demo them at our seats. 

Do you want to get up and watch each others demos? 

Male Student:  I'm working on mine. 

Professor:  Okay, just show me then. 

Once you've shown your demo you can put them back and you can go. 

Female Student:  I got it to go at one angle, but I couldn't figure out how to turn it. 

Okay.  Oh, it went fast and then slow. 

So how did you make it- did you have a wait? 

I see.  Cool, okay. 



Transcript - Hands-On Robotics

Class: Informatics, Computing, and the Future
Instructor: Dan Berleant
Transcriber: Brooke Yu
Date: Thursday, April 11, 2013

Professor:  Okay, so we'll talk about those in a minute.  First I just want to go over where we are in the course.  We're getting to the end of the semester, so today we're going to start on our robotics unit.  That's what those things are. 

Many people signed up for presentations, so we're down to 15 minutes per presentation. 

Can we interrupt you?  For the VMware, we have mark here

If any of you are getting knocked off and have to log back in, if I could get a screenshot of the error, send it to me. 

We really wanted to fix it tomorrow. 

Send it to mhpace@ualr.edu

I'll put it on the board. 

It's mhpace@ualr.edu. 

Female Student:  It has been kicking me off today, but no error message. 

Yeah, some people get it and I need to see the message. 

Thank you! 

Professor:  They're not going to be logging in to use these things.  They'll be using the local machine. 

Male Student:  I'll just keep VMware open. 

Alright, thank you! 

Male Student:  I noticed earlier too it seemed like other computers doing it.  It's not just VMware. 

Okay, thank you. 

Professor:  Okay, so sign up for presentations if you haven't yet.  If you have, your name should be here.  What else?  There's a homework due next Tuesday, then there will be one more homework, and a last homework which is a test, but it counts like a homework. 

The test is really for our accreditation for the course.  So take it seriously, and that will be the last assignment for the course.  Then we have presentations. 

So we're sort of in the home stretch.  Any questions about the project or anything?  Test?  Anything?  No?  We won't meet for the final unless you have to make up assignments. 

Okay, so let's talk about robots. 

I'm going to show you stuff, but instead of me for just standing up here, I'd like everyone to get their own robot.  So just come up and get one.  You can pick it up by the handle, or just grab it.  They're all charged.  I've been charging them all morning. 

Male Student:  It can't talk, can it? 

Professor:  Haha, no.  Well, one year I found a sudent who found a speech interface for it.  Anyway, these this looks sort of like a rhumba.  And it's made by the same company.  So I like to say it's similar, but it doesn't have a vacuum.  It just rolls around.   And you can program this one. 

So let's look at the parts.  First, it has a handle so you can pick it up.  It has an omnidirectional IR receiver.  What is omnidirectional?  All directions.  What does IR stand for?  Infrared.  Does anyone know what that means? 

You know, there's the colors.   Like the rainbow goes from red up to blue in a layer.  This is the frequency of the light- how fast the light waves are going.  Past blue, what's that? 

Male Student:  Yellow? 

Professor:  Yellow, I think is here

Male Student:  Orange? 

Professor:  Right between yellow and red. 

Male Student:  White? 

Professor:  That's the combination of all colors. 

Professor:  Do you ever hear the term black light?  That's the same as ultra violet.   It really is light, but you can't see it. 

So what's under ultraviolet?  Violet, which is purple light.  You have blue color receptors in your eyes, but no violet color receptors.  It looks that way because it starts activating the red receptors.  It activates both blue and red receptors at the same time.  Ultra means beyond, so infra means below, so infrared means below red

So these robots, if you look at this thing on the front, it has a clear plastic layer undue rathe disk.  That clear plastic is a way that this thing receives and transmits infrared light. 
It communicates by infrared light. 

And notice it's clear plastic all around- well, thats' because it's omnidirectional.  It doesn't transmit, it just receives.  That why it has a periscope in the front so it can communicate with things like the charging base. 

If you'll notice the charging base has a similar circular clear plastic thing.  This is a transmitter.   The robot can sense it and the robot and come and dock and get charged. 

In fact, I'll show you.  

Plug it in. 

You might want to stand up, or come around here and see how it works

Might as well, otherwise I'll just have to tell you. 

Male Student:  These are the same ones we used in the ethics class. 

Professor:  Yeah.  Alright.  It's trying to dock, and this thing is emitting infrared light and it's trying to adjust its path so it can dock.  Now it's charging.  You can see the charging light is on and it's able to dock because of that omnidirectional IR receiver. 

Alright.  So it also has a cargo bay.  Why do you want a cargo bay?  People do all kinds of research with these robots and people have done things like build structures into the bay that have a hand or something that can grab a beer out of the fridge.  Plus it's not a vacuum cleaner, so they have extra space

Inside it has a cargo bay connector.  See that?  It's so you can connect this to a computer that sends arbitrary C code to control what the robot does.  If you don't want a wire connected to it, you can set up a radio transmitter.  So you can use this to do arbitrary complex programs like taking the beer out of the fridge

Or it can be set up to water tomato plants in a lab.  You can still program it to 100 bytes.  We'll do that maybe next time. 

Cargo bay connector- charging socket.  It's right on the side.  See if you can find it. 

So I showed you how it docks.  Does everyone see it?  It has a lightning thing.  If you don't have a docking device, this charger is what gives it the juice, and you can plug it right into the thing. 

Look at the green light.  When I plug it in, it turns red and pulses.  When it's fully charged, this light will turn green again. 

You can also plug it into the charger docking station and then it'll be docked that way. 

Okay, if you look above the charging socket, there's something cayley death serial port.  Here's the charging port, and above it is the serial port.  We're going to plug this into the computer to send programming commands.  Did everyone find the serial port?  If you look at the serial port, you can see how you can only plug the cable in one kind of orientation.  It's easy to bend these pins.  It's not really made for school use, so when I give you pins, don't force them in the wrong way. 

Avoid bending pins.  But I haven't given you the cables yet, so you'll see that later. 

The trick is to align the arrows.  The cables have an arrow on them, and you want to align them so you know you won't bend them.  Does anyone have a cover over the serial port?  When they come new they're covered.  I took them off though for today. 

Okay, now I'm going to hand out some cables and you can plug the cables in.  Before I do that, I want to show you how to do it. 

Okay, so here is the robot.  And here's the serial port.  There's a cable that plugs in.  Notice that the cable has an arrow on it.  So you can twist it so that the arrow is facing the right way- it should be facing out so you can see it.  Then you know you're plugging it in the right way.   Does that make sense?  You want the arrow to be sort of facing outward from the robot and then it'll plug in properly.  Let me go ahead and pass these out. 

So take your time plugging them in.  It's really the one thing people are most likely to break on these- the cable.  So really try to be careful. 

Make sure you see the arrow before you try to plug it in. 

Alright.  Is it going okay?  Any questions? 

The next step is to plug the other end of the cable which is a rectangular shape into your computer.  The computers have right over on the left side over here is the socket for that. 

So you got a cable that's marked fragile.  But you have it all set right. 

Okay.  Everybody all set?  Any questions?  Well, let's continue our process here.  If you'll notice, it has three buttons on the robot.  One has a symbol that looks like this [On board.]  

Someone already pressed their power button. 

That's the power button.  Does anyone know why it has this symbol? 

Male Student:  Isn't it like input/output/ 

Professor:  Yeah, it's the 1 0 kind of thing.  For computers, that means on and off.  This is the standard symbol for a power switch. 

Oh, I see.  It's per IEEE standard 1621.  It'll make a beep.  Go ahead and press it.  And the light turns on.  It should be a green light. 

If it's amber, your batter is only partially charged.  If it's red it really needs charging.  If it doesn't come on, it's dead how many have green? 

Anybody have amber or anything else? 

I charged them earlier. 

Good what else?  The power button has LEDs in it.  Who knows what that stand for? 

Male Student:  Light emitting diode. 

Professor:  Right.  That's where lightbulbs are going too.  We talked about how lightbulbs will all be LED soon.  The power button has a red one and a green one in there.  If the green one is on it's charged.  If it's not charged, it lights up the red one instead.  Or if it's partially charged they both light up.  It also has some other buttons.  It has a play button. 

That's the arrow in the middle, and it has an LED associated with it. 

So you can just try... if you press it, your robot will move.  Don't press it yet.  It has an advance button.   You've seen these before. 

So there's a bunch of demos. 

We're going to go outside for this.  You have to unplug them.  Bring them out here and I'll demonstrate. 

Professor:  So how many people found out what the music playing demos were?  It has some cool motion abilities too. 

Okay.  Any questions so far?  Comments? 

Alright.  So I showed you the home base here where it can dock for recharging.  If you look under the robot by the front wheel, it has these two shiny pads.  That matches up with the contacts on the home base so it can charge.  Does everyone see those pads there?  Metal is expensive.  More expensive than plastic.  So why not change money by making those contact pads out of plastic? 

Male Student:  Doesn't conduct electricity. 

Professor:  Right.  I saw someone noticed that it wouldn't fall down the stairs.  I hope you were there to catch it.  The reason is because it has cliff sensors so it won't fall off of tables or down stairs.  If you look at it, it has rectangular holes by the pads.  Those are cliff sensors. 

So my question is- are these spring loaded feelers or are they electronic? 

Male Student:  I imagine they're electronic. 

Professor:  Okay, how could you tell? 

Male Student:  Spring? 

Professor:  Yeah, you know, like springy things that fall down to detect? 

Male Student:  I see wires.  No springs. 

Professor:  Okay.  If you shake it, you don't see any springs dropping down.  So yeah, they're electronic cliff sensors. 

Turn it upside down.  We'll look at the batter.  It's similar to a batter for your computer or something.  It's called- everyone see it?  Take out the batter.  You press on the ends.  There's little finger holes and you can lift the battery out.  To put it back in, drop it into place and press on both ends and make sure you hear two clicks. 

You should hear two clicks and you're good to go. 

Okay, our next step is to send commands to the robot to make it do things go ahead and plug the cable back in, being careful that the arrow is straight out so it won't break.  Remember, the arrow faces out. 

And everyone got that connected?  If you go to your computer- you don't have to log in.  It's on the local machine.   You don't have to log in.  

So if you go to your computer, there's a program called real term.  It comes up with a black window. 

You can download real term at home.  I don't know if we have it on this machine.  Probably not. 

How many people found it?  Oh, you got it.  There are people running it.  Anyone not have it yet? 

Okay.  Are you already sending commands? 

Male Student:  I learned how to do it in ethics class. 

Professor:  Right!  Okay.  So there's a bunch of tabs.  Click the "Send" tab because we want to send commands. 

So click the send tab. 

In the window, there's a little window.... I don't have a picture.  There's a type in window for sending commands.  What does it say- it says "send numbers."  So you'll want to send two numbers.  128 space 132.  Type them, but don't click send yet.  Then power cycle your robot tget to the initial state.  Turn it off then turn it on. 

When you send the numbers, watch the power light.  It should go off. 

So give it a try.  When you send those numbers, the power LED should turn off. 

Okay.  Raise your hand if you're running into problems. 

128 132. 

On the same line. 

128 132. 

Click send. 

And it turned off. 

If you want to try again, you can

Okay, what's going on here is that these are programs in the programming language.  128 is the start command.  It tells it to get ready to accept software 132 gives you control over the robot.  If you say go forward, it'll go forward over the edge of the table.  So you have to use your power carefully. 

Okay.  Let's try something else.  Try this command here.  It's three commands with three arguments.  Try sending this command and watch what happens. 

Someone tell me what happens. 

Male Student:  The play button turns green. 

Professor:  Okay, so it should turn on the middle light and everything else should be off.  The 139 command is a light controlling command.  2 0 0 are three arguments.  Okay.  The first argument is the one that controls the light that just turned on.  If you... let's see how to say that.  If you give it an 8 instead of 2, it'll light up differently. 

Male Student:  The forward button turns on. 

Professor:  Right.  So 2 makes one button turn on.  There's one bit that stands for the 2, the third bit stands for 8.  But the cool thing- if you use 10 instead of 8, 10 is 2 + 8 and that's like sending both 2 and 8 at the same time, so it'll light up both lights.  I see some of you are ahead of me. 

That's good. 

Alright.  That's just the first argument. 

Tuns out that the first argument is for two of the lights and the second two are all for one light. 

So we've lit up the play and advance light.  Let's play with the power light, which can be red, green, and amber.  That's why you need two arguments for that one. 

It turns out that one of the arguments- there's three arguments.  Here's three arguments.  0, 0, 255.   First argument, we already played with.  The second is for power, and the third is for brightness.  So try this one- the mouse is pointing to.  This line of commands.  That will turn on the light at maximum brightness- 255 is the max brightness. 

And it'll light up with color 0.  So find out what color 0 is in the second argument. 

Male Student:  Green. 

Professor:  Okay, so everyone gets green.  So if you change it, you should be able to make it change color. 

If you want to have red and green at the same time, or something between red and green- it'll look like yellow.  So if you turn them on at the same time, you should get a yellow light.  Or something that's reddish or greenish.  [On screen.]  The question is what value between 0 and 255 gives you a pure yellow light- not orangey or greenish yellow.  Experiment with it and find the number that gives you a great yellow light. 

Raise your hand if you have questions and I'll stop by. 

Is it going okay? 

You want to use that exact line of code which I had on the board. 

This line right here. 
Type those 6 numbers in. 

Okay, now send the commands.  Did you send it?  No, no.  Click here.  Okay, now change that second 0... type 255. 

 Then another space and another 255. 

Okay, anyone get yellow yet? 



Male Student:  Is this yellow? 

Professor:  That's pretty good.  I claim that red and green make yellow.  You should see a little red and green light in the button.  When you back off, it should look yellow.  You see it? 

There's a red and green in there.  There's nothing yellow in there at all. 

Okay.  What number gives you a pretty good yellow? 

Male Student:  10

Professor:  Anyone get another number? 

Male Student:  13

Professor:  You'd think it would be 128 or 127.  I don't know why, but one LED gets brighter quicker, so to get a good balance, it's more like a very low number like 10 or 20. 

Okay.  Any questions? 

Alright, let's move right along. 

Another command is for the sensors.  The command 142 is for reading sensors.  142 has an argument- 1 argument, they put in the 9.  But it can have many arguments.  9 is the left cliff sensor.  If you do number 9, that's the left cliff sensor.  It'll return the result of reading that sensor in the black window when you send it. 

The cliff sensor has not been activated.  If you lift the left side of the robot and resend this command, it'll resend a 1 instead of 0 since you activated the sensor. 

Male Student:  For a while it kept saying null. 

Professor:  Maybe your hand was under the cliff sensor. 

Male Student:  Maybe.  Is everyone getting the NUL or the SOl?  Okay. 

So let's see.  Oh, maybe it's SOH, not SOL. 

If you want to see how many sensors there are, send a 6 instead of a 9.  Then you can count the returns to see how many sensors it has. 



Male Student:  Quite a few. 

Professor:  Yeah, your screen is filling up with junk- that means you're reading all the sensors. 

Any other questions about this?

Male Student:  Is it okay if I leave early?  There's an event that's happening at 5:30. 

Professor:  Okay.  For those who are had this exercise before, this is new.  So new command.  Command 158 is wait for an event and don't do anything until afterwards.  And then which event you wait for- 5 is a bump on the bumper.  There's a bunch of them.  You could do a wheel drop or whatever.  You know after this command, then you put the light changing command and it won't do it until you hit the bumper

We'll do more with that in a little bit. 

So let's talk about the music capabilities of the robot

As usual, you want to send these commands to get the start command.  Then you can load a song.  Here's a song, so comamnd 140 says load a song, then it has arugments for how the song goes

140 is load, 141 is play.  So you have to initialize with the 128 132.  So try loading, then try playing.  

Someone got it. 

Professor:  Let me tell you a little about what's going on here.  It's a complicated set of numbers to describe the song. 

140 is the command that says define a song.  You can define several songs.  Each has a name, and the number of this song is 0.  You can play song 1 or 2, but we're labeling it 0.  4 says how many notes in the song.  It has four notes.  What are the four notes?  Note 1, note 2, note 3, note 4 [On board.]  

Let's look at note 1.  The 12 is 12 64ths of a second, the 68 is the frequency.  So that's three 16ths of a second, and 68 is a standard number for describing frequency.  So remember the song went.... it was 74, so that means it was a little longer.  So you can control the frequency and you can control the length of each note and you can even control.... sorry, I made a big mistake. 

This is the note, this is the length of the note.  Frequency, length, frequency, length.  And you can even control the number notes. 

Make it a 3 and have it shorter.   Just make this work and see if you can get another song.  So this is a composing class today for a few minutes. 

Female Student:  Mine won't either.  It'll turn off every time. 

Okay. 

Alright, type in 141 on the next line.  Down a line.  Down a line.  Go down.  Move the cursor to the next. 

141 0 now try sending that second line. 

Okay.  So the 140 loads, 141 plays. 
Alright? 

Now you can mess with these numbers to change the parameters of the notes. 

So you two things you could try.  Be creative and try to come up with a cool song, add notes, find the lowest note that will play, or the highest.  Oddly enough, if you get the frequency too high, older people like me won't be able to hear it but younger people probably will.  Has anyone heard about ringtones for your cell phone that are super high frequency and teachers and adults can't hear it but you can?  If you did it in class I wouldn't be able to hear it.  We have ten minutes left.  I don't want to go onto something new. 

So come up with a better tune- more notes, higher notes, lower notes.  In about 7 minutes we'll have a concert and each person can play their tune.  We'll have a recital. 

He said you can just change the numbers around to experiemnt with the sounds. 

So our concert is schedule for about 6 or 7 minutes from now.  In the meantime, you can practice your piece. 

Professor:  So this is a pretty lousy computer language for programming, but that's how they do it.  So let's have our concert. 

Alright.  Everybody ready? 

Okay.  Hold your horses.  We'll take turns. 

Okay, you programmed a whole bunch of notes. 

Professor:  Okay.  Alright. 

Female Student:  Mine's not working.   This is all I have. 

Professor:  Okay. 

You guys. 

Okay. 


Alright, well, we're not talking about mozart here, but you can do it.  You can do some pretty cool things.  Next time we'll pick up here and go with motion stuff.  Turn off your robots and put them back on the cart.  We'll do more next time.