Statements about LEGO lamp brick for NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
chanyh
Posts: 17
Joined: 11 Oct 2010, 05:14

Statements about LEGO lamp brick for NXC

Post by chanyh »

Help!

What are the NXC statements for the LEGO lamp brick? How to control the functions such as on, off or blinking?

I cannot find these statements in the NXC Programmer's Guide.

YH Chan
Last edited by chanyh on 08 May 2011, 08:00, edited 1 time in total.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Statements about LEGO Light Brick for NXC

Post by mattallen37 »

Light brick? Do you mean the light sensor light? Use these lines to turn the light on and off:

Code: Select all

SetSensorType(S1, SENSOR_TYPE_LIGHT_ACTIVE);  //Turn on the light
SetSensorType(S1, SENSOR_TYPE_LIGHT_INACTIVE);//Turn off the light
If you are referring to the actual 9v light, you use it on the motor port, so the controls are exactly the same as the motors (OnFwd, and Off).
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
chanyh
Posts: 17
Joined: 11 Oct 2010, 05:14

Re: Statements about LEGO Light Brick for NXC

Post by chanyh »

Matt,

Sorry!


I mean the LEGO lamp brick, not the NXT Light Sensor or old RCX Light Sensor.

I try to use the following program, but no affect.

Code: Select all

task main()
  {
     while(true)
       {
          SetSensorType(OUT_A, SENSOR_TYPE_LIGHT_ACTIVE);  //Turn on the light
          Wait(1000);
          SetSensorType(OUT_A, SENSOR_TYPE_LIGHT_INACTIVE);//Turn off the light
          Wait(500);
       }
  }
YH Chan
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Statements about LEGO Light Brick for NXC

Post by mattallen37 »

chanyh wrote:...I mean the LEGO lamp brick...

YH Chan
Can you give a BL URL to it? I have no idea what lamp brick you are talking about...

Do you mean the new PF LEDs? You use those with the motor port, so you would turn them on and off like a motor.

I don't remember any lamp brick, other than the RCX one. Maybe there were some from the 12v train days, or the 4.5v sets...
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
chanyh
Posts: 17
Joined: 11 Oct 2010, 05:14

Re: Statements about LEGO lamp brick for NXC

Post by chanyh »

The lamp brick is the Electric, Light Brick 1 x 2 with Single Top Light.

The URL link is : http://www.bricklink.com/catalogItem.asp?P=4767

YH Chan
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Statements about LEGO lamp brick for NXC

Post by mattallen37 »

Okay, that is a 9v lamp, same as the RCX one, only this one you can reverse the polarity to make it flash (not really a necessary feature when being controlled by the NXT ;)).

To use it, use an NXT -> RCX converter wire in a motor port. Use the motor commands to turn it on and off.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
chanyh
Posts: 17
Joined: 11 Oct 2010, 05:14

Re: Statements about LEGO lamp brick for NXC

Post by chanyh »

From the the LEGO Mindstorms website, one can download a Lamp* block in the package of Legacy_Blocks. This block can control a lamp.

I want to control the lamp by NXC statements.

YH Chan.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Statements about LEGO lamp brick for NXC

Post by mattallen37 »

So use the OnFwd/OnRev and the Off/Coast commands.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
chanyh
Posts: 17
Joined: 11 Oct 2010, 05:14

Re: Statements about LEGO lamp brick for NXC

Post by chanyh »

Hi, Matt,

Thanks!

I use the commands that you suggested. It works.

YH Chan.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests