Page 1 of 1
Statements about LEGO lamp brick for NXC
Posted: 08 May 2011, 05:29
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
Re: Statements about LEGO Light Brick for NXC
Posted: 08 May 2011, 06:19
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).
Re: Statements about LEGO Light Brick for NXC
Posted: 08 May 2011, 07:58
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
Re: Statements about LEGO Light Brick for NXC
Posted: 08 May 2011, 08:13
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...
Re: Statements about LEGO lamp brick for NXC
Posted: 08 May 2011, 08:29
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
Re: Statements about LEGO lamp brick for NXC
Posted: 08 May 2011, 08:50
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.
Re: Statements about LEGO lamp brick for NXC
Posted: 08 May 2011, 09:00
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.
Re: Statements about LEGO lamp brick for NXC
Posted: 08 May 2011, 09:02
by mattallen37
So use the OnFwd/OnRev and the Off/Coast commands.
Re: Statements about LEGO lamp brick for NXC
Posted: 08 May 2011, 10:19
by chanyh
Hi, Matt,
Thanks!
I use the commands that you suggested. It works.
YH Chan.