May 6, 2011

Lamp Brick

In my last project, the Sky Wheel, I used the "lamp" brick for the first time. Before then I couldn't find a use for it, and I didn't have any room for it anyway because it takes up a whole motor port. I even considered making a project simply devoted to trying out the lamp block, but then I found a way to incorporate it into the Sky Wheel.

What is the lamp brick?
The lamp brick is a small, white 1 x 2 stud brick with a tiny light bulb sticking out one of the larger sides. The LEGO Mindstorms Education set comes with three of them. Also, here are all (I think) the sets it comes with:

4 in 9701-1 - Control Lab Building Set (1995)
4 in 9723-1 - Cities and Transportation (2000)
3 in 9797-1 - LEGO MINDSTORMS Education NXT Base Set (2006)
3 in 9848-1 - Lamps and Fittings
1 in 7898-1 - Cargo Train Deluxe (2006)
1 in 9702-1 - Control System Building Set (1993)
1 in 9707-1 - Intelligent House Building Set (1996)
1 in 9785-1 - Robo Technology Set, with serial cable (2003)
1 in 4534-1 - LEGO Express (2002)
1 in 9794-1 - Team Challenge Set {updated}, with USB cable (2003)
1 in 9786-1 - Robo Technology Set, with USB cable (2003)
1 in 9685-1 - Green Car Set (2003)
1 in 3748-1 - Light Unit for Train (2001)
1 in 7897-1 - Passenger Train (2006)
1 in 65801-1 - Trains Value Pack (2005)
1 in 3801-1 - Ultimate Accessory Set (2000)
1 in 4511-1 - High Speed Train (2003)
1 in 4535-1 - LEGO Express Deluxe (2002)
1 in 4512-1 - Cargo Train (2003)
1 in 9684-1 - Renewable Energy Set II (2003)
1 in 4560-1 - Railway Express (1999)
1 in 5310-1 - Lighting Brick (1996)
1 in 4561-1 - Railway Express (1999)
1 in 5308-1 - Head Light Brick (1994)
1 in 4565-1 - Freight & Crane Railway (1996)
1 in 5307-1 - Head Light Brick (1992)
1 in 10001-1 - Metroliner (2001)
1 in 4558-1 - Metroliner (1992)

The above list was copied from an awesome website that I found recently. The site is called Peeron, and I definitely recommend checking it out if you're every wondering which sets come with which parts. I thought for a while that only the Mindstorms Education set has the Lamp brick, but Peeron proved me wrong! It truly is an awesome site. :) Check out this page, where I copied the list from.

How to program the Lamp Brick
Programming the Lamp Brick is extremely simple. In fact, I had tested out the Lamp Brick (about a month before I used it in the Sky Wheel) and didn't program it at all. I had a program on my Intelligent brick already which would just run the motor at 50 power. It was late at night, my computer was already off so I couldn't create a new program right then, and I was dying to see how it worked. Sadly, I did what I never thought I would do (and I don't recommend it!); I plugged the lamp into a port and ran the motor block. Thankfully, the lamp didn't burn out (I'm wondering how much power exactly would burn it out), but I won't be doing that again anytime soon. :)

Ok, now here is the very simple way of programming it... first, click and drag the lamp block onto your program. The default setting will have you plug it into port A. Change the setting by clicking the block and selecting a different port. The action setting will be set to "On". That simply means that you will be turning the light on (you'll need a block later on to turn it off). Next, select the intensity (brightness) you want. Before you add a block to turn the light off, you'll want a wait block so the light doesn't turn off instantly. Then add a block to turn the light off. Your setup should look something like this:


A more random way of programming the Lamp
As you get more experienced with programming, you'll discover that there are many different ways of performing operations. In fact, there are probably thousands of different ways to program your lamp. Here is another one that I just made up:

For this program, your lamp will turn on to a random intensity, stay on for 5 seconds, then turn off. The only difference in this program from the last is the random block, and the wire connecting it to the lamp block:
Please notice that I set the minimum random value to 1, so no matter what intensity was randomly chosen, you would still be able to see the lamp turn on somewhat...


Slowly turn on, slowly turn off
Finally, this is the method that I used in the Sky Wheel. I didn't just want the lamp to turn on and off, I wanted it to slowly get to its full brightness, then slowly dim back down to a zero intensity. And, I wanted it to complete the pattern 25 times. Okay, having it complete any operation 25 times is easy- simply throw the operation in a loop and set the loop to be continued until it reaches 25 completions. Easy. Now what about the lamp? From the Enterprise, I already knew how to make a motor slowly speed up. I knew for a fact I could use the same setup for a lamp too: Place the block inside a loop, and have the intensity equal the number of times the loop has been completed (limit 101). That makes it reach an intensity of 100 (the extra "1" is because of the fact that the first time the loop is completed, it is the first time it has been completed and the intensity will equal zero. You need the "extra" 1, otherwise the intensity will stop at 99). Once it has reached full intensity, it will move on to a second loop. For this loop I wanted the light to slowly dim. This wasn't as easy as simply having the intensity equaling the number of loops completed. After all, that would result in the intensity increasing. Instead, I wanted it to start at its 100 intensity level, and go down one for every loop completed.  So I used a math block.  I had the math block's "A" value is set at 100, and the "B" value is subtracted from the "A" value and is set to equal the number of loops completed. That way, the intensity equals "100" minus "the number of loops completed" (limit 101). There is only one more think you need to deal with. If you downloaded the program now, you wouldn't be able to see the lamp turn on and off 25 times because it would happen nearly instantly. In order to fix that problem, all you need to do is add a wait block to each of the two loops in the programming. The amount of time waited will determine how fast the lamp lights to full intensity, and how fast it dims again. You want the number to be really small, as the loop needs to be completed 101 times. Even if you set it for only 1 second, you would still have to wait 101 seconds for the intensity to reach max. That is why, in my program, I set the wait block for 0.005 seconds. Your setup should look something like this:


I could post different programs for the Lamp Brick all day, as there are hundreds of possibilities, but I should get on top of my homework now. And besides, what fun would it be for you if I just posted them all for you? :)

I hope you enjoyed this post and found what you were looking for in it. Feel free to ask questions if you have any- to post a comment, simply click the __ comments button, and type in the blank box. :)

No comments:

Post a Comment

Your comment will be moderated as soon as possible. Thank you!

TopOfBlogs