NXC: turning on the light

View: New views
9 Messages — Rating Filter:   Alert me  

NXC: turning on the light

by iTOtto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Howdy,

maybe I'm overlooking something very simple, but I can't find a way to use the lamp that comes with the NXT when programming it in NXC.

Is this plainly not supported?

Regards,
iTOtto

Re: NXC: turning on the light

by John Hansen-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In lugnet.robotics, iTOtto <torsten.otto@...> wrote:
> Howdy,
>
> maybe I'm overlooking something very simple, but I can't find a way to use
> the lamp that comes with the NXT when programming it in NXC.
>
> Is this plainly not supported?
>
> Regards,
> iTOtto

My guess is you can turn it on using one of the powered sensor types such as
SENSOR_TYPE_LIGHT_ACTIVE or SENSOR_TYPE_LOWSPEED_9V.  I don't have a lamp to
test this with or any of the cables that are required to connect a lamp to a
sensor port.  The retail set doesn't include any of these cables or the lamp
itself.

Let me know if this works or not.

John Hansen

Re: NXC: turning on the light

by iTOtto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a bunch for the reply! The education set has the lamp, so my students would like to use it now...
I'll keep you 'posted' about the results...

Regards,
Torsten Otto

John Hansen-4 wrote:
In lugnet.robotics, iTOtto <torsten.otto@mac.com> wrote:
> Howdy,
>
> maybe I'm overlooking something very simple, but I can't find a way to use
> the lamp that comes with the NXT when programming it in NXC.
>
> Is this plainly not supported?
>
> Regards,
> iTOtto

My guess is you can turn it on using one of the powered sensor types such as
SENSOR_TYPE_LIGHT_ACTIVE or SENSOR_TYPE_LOWSPEED_9V.  I don't have a lamp to
test this with or any of the cables that are required to connect a lamp to a
sensor port.  The retail set doesn't include any of these cables or the lamp
itself.

Let me know if this works or not.

John Hansen

Re: NXC: turning on the light

by Philippe Hurbain :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> My guess is you can turn it on using one of the powered sensor types such
>> as
>> SENSOR_TYPE_LIGHT_ACTIVE or SENSOR_TYPE_LOWSPEED_9V.  I don't have a lamp
>> to
>> test this with or any of the cables that are required to connect a lamp to
>> a
>> sensor port.  The retail set doesn't include any of these cables or the
>> lamp
>> itself.
>>
>> Let me know if this works or not.
>>
>> John Hansen
>>
>>
The lamp is relatively power hungry, so you should connect it to a motor port
for best result. OnFwd ("ports", "pwr"); will light it, with brightness
controlled by the pwr parameter. Off ("ports"); will turn it off.

I have not tested, but most probably the lamp can dimly glow on a sensor port.
Use SetSensorType ("port", IN_TYPE_LIGHT_ACTIVE); to turn it on and
SetSensorType ("port", IN_TYPE_SWITCH); to turn it off.

Philo

Re: NXC: turning on the light

by Philippe Hurbain :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> My guess is you can turn it on using one of the powered sensor types such as
> SENSOR_TYPE_LIGHT_ACTIVE or SENSOR_TYPE_LOWSPEED_9V.  I don't have a lamp to
> test this with or any of the cables that are required to connect a lamp to a
> sensor port.  The retail set doesn't include any of these cables or the lamp
> itself.
>
> Let me know if this works or not.
>
> John Hansen

Since the lamp is a rather power hungry device, it is best to drive it with an
output port.
Use OnFwd(port, pwr) to turn it on (with brightness controlled by pwr
parameter), Off(port) to turn it off.

Though I have not tested, it should also glow dimly when plugged in a sensor
port. As John explained, set sensor type to SENSOR_TYPE_LIGHT_ACTIVE or
SENSOR_TYPE_LOWSPEED_9V to light it, SENSOR_TYPE_TOUCH will turn it off.

Philo

Re: NXC: turning on the light

by Ildefonso Zanette :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In lugnet.robotics, iTOtto <torsten.otto@...> wrote:
> Howdy,
>
> maybe I'm overlooking something very simple, but I can't find a way to use
> the lamp that comes with the NXT when programming it in NXC.
>
> Is this plainly not supported?
>
> Regards,
> iTOtto

Hi,

  Have you tried to connect the adapter cable in the output port and put the
lamp on it?

  Use this program to test:

task main()
{
  OnFwd(OUT_A, 100);
  Wait(5000);
  Off(OUT_A);
}

  This program assumes that you connected the cable in output A.

Regards,

Ildefonso.

Re: NXC: turning on the light

by iTOtto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We successfully tried the following:

task light()
{
OnFwd(OUT_A, 100);
}

It works like a motor  OnRev works as well.

We haven't yet tried the other idea.

Re: NXC: turning on the light

by John Hansen-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In lugnet.robotics, iTOtto <torsten.otto@...> wrote:
> Thanks a bunch for the reply! The education set has the lamp, so my students
> would like to use it now...
> I'll keep you 'posted' about the results...
>

Philo wasn't able to post here but via email he pointed out that it is best to
use the lamp on an output port rather than a sensor port.

Here's what he had to say:

Since the lamp is a rather power hungry device, it is best to drive it
with an output port.
Use OnFwd(port, pwr) to turn it on (with brightness controlled by pwr
parameter), Off(port) to turn it off.

Though I have not tested, it should also glow dimly when plugged in a
sensor port. As John explained, set sensor type to
SENSOR_TYPE_LIGHT_ACTIVE or SENSOR_TYPE_LOWSPEED_9V to light it,
SENSOR_TYPE_TOUCH will turn it off.

Philo

Re: NXC: turning on the light

by Philippe Hurbain :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Philo wasn't able to post here but via email he pointed out that it is best to
> use the lamp on an output port rather than a sensor port.
>
Well... my messages were published about 10 hours after posting... :-(

Philo
LightInTheBox - Buy quality products at wholesale price!