ROBOTC.net forums
http://www.robotc.net/forums/

Color sensor as strobe
http://www.robotc.net/forums/viewtopic.php?f=1&t=4185
Page 1 of 1

Author:  matt [ Mon Jan 30, 2012 8:24 pm ]
Post subject:  Color sensor as strobe

Hi

I'm trying to get the color sensor to strobe using the following code:

while (true){
SensorType[COLOR] = sensorCOLORBLUE;
wait1Msec(10);
SensorType[COLOR] = sensorCOLORNONE;
}

But nothing happens, if I use a wait time of over 100 miliseconds it works fine, anything under 100 and nothing happens at all.
So is there a way to get the color sensor to flash at high speed or is this not possible?

Author:  mightor [ Tue Jan 31, 2012 1:25 am ]
Post subject:  Re: Color sensor as strobe

It doesn't really seem to let itself get switched on and off very quickly in my experience. It could be a limitation of the sensor's internal firmware.

- Xander

Author:  sumasmreq [ Tue Jan 31, 2012 1:36 am ]
Post subject:  Re: Color sensor as strobe

I would expect your color sensor would stay on blue; you need another wait statement after 'SensorType[COLOR] = sensorCOLORNONE;' or else your code is effectively the same as:

Code:
while (true){
SensorType[COLOR] = sensorCOLORNONE;
SensorType[COLOR] = sensorCOLORBLUE;
wait1Msec(10);
}

Author:  matt [ Tue Jan 31, 2012 5:12 am ]
Post subject:  Re: Color sensor as strobe

Thanks.

I think its color sensor being a bit slow and not me:)

Any ideas on creating a custom 'sensor' that was basically an LED that could be turned on and off with precision?

Author:  magicode [ Tue Jan 31, 2012 11:08 am ]
Post subject:  Re: Color sensor as strobe

Do you have the protoboard? It's not needed for what you want to do, but it makes hooking up electronics to the NXT a lot easier.

Author:  DiMastero [ Tue Jan 31, 2012 9:04 pm ]
Post subject:  Re: Color sensor as strobe

What sumasmreq says is true though; you need a second wait statement or it'll just skip ahead to the next one without waiting:
Code:
#pragma config(Sensor, S1,     COLOR,               sensorCOLORBLUE)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main{
  int timeToWait = 150;
  while (true){
     SensorType[COLOR] = sensorCOLORBLUE;
     wait1Msec(timeToWait);
     SensorType[COLOR] = sensorCOLORNONE;
     wait1Msec(timeToWait);
  }
}
And you're also right - I didn't get to work much faster than having a 150 mSec wait in between. It still looks pretty strobe-y, though.

If you have a light sensor, you might want to try that. I've used it a few times before and it will let you turn the LED on it on and off much faster than this, if I remember correctly.

Author:  matt [ Wed Feb 01, 2012 5:26 am ]
Post subject:  Re: Color sensor as strobe

Thanks for the feedback.

The code I posted was just a snippet, there were other bits around it.

What I was trying to do was create an effect similar to the pixar zoetrope (plenty of videos of it on youtube).

The idea being that the motor rotated a disc with 12 evenly spaced images on with the light flashing on quickly every 30 degree rotation to create an animated effect.

Protoboards and light sensors looks a bit pricy as I was hoping I could just shove an led into the pins of a connector cable.

Author:  DiMastero [ Wed Feb 01, 2012 5:52 pm ]
Post subject:  Re: Color sensor as strobe

What you could also do is cover the color sensor with something (circular) with a small hole in it. Then spin that something using a motor to get a strobe-like effect. You could then tune the speed of the motor to adjust the speed of the strobe light.

Author:  matt [ Wed Feb 01, 2012 7:18 pm ]
Post subject:  Re: Color sensor as strobe

Good idea, I think that might work!

Author:  magicode [ Wed Feb 01, 2012 8:27 pm ]
Post subject:  Re: Color sensor as strobe

Or, if you have a motor controller, hook up the DC motor output to a couple of resistors and an LED. Then turn the motor on and off.

Author:  DiMastero [ Wed Feb 01, 2012 10:26 pm ]
Post subject:  Re: Color sensor as strobe

Oh yeah that reminds me:

If you have Power Functions (at least one motor and one light), you can use my tutorial to turn that motor into a custom NXT to Power Functions wire. You could then hook the PF lights up to that. I've used it for a lot of things and you can turn them on and off REALLY fast (upto 500 times a second, in my experience).

Anyways, here's the link: http://worldofmindstorms.com/2011/03/26 ... pf-cables/

So basically, you'd plug that into one of your motor ports and then just control them like you'd control a motor (the faster you make the motor speed, the brighter the light). Do make sure that you turn your PID controll off, though (in the motors and sensors setup window).

Author:  matt [ Thu Feb 02, 2012 6:46 am ]
Post subject:  Re: Color sensor as strobe

Ok, Ive done a bit of research and if I connect up the following:

Black wire on nxt connecter > 330 ohm resistor > 3.5v LED > white wire on nxt connector.

I'll be able to turn the light on and off using the code on the link DIMastero posted above.

As long as the white and black wire don't touch is there any risk of this damaging the nxt?

Author:  DiMastero [ Thu Feb 02, 2012 5:40 pm ]
Post subject:  Re: Color sensor as strobe

There shouldn't be but try it with low power first

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/