| Author |
Message |
|
matt
Rookie
Joined: Mon Jan 30, 2012 8:15 pm Posts: 5
|
 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?
|
| Mon Jan 30, 2012 8:24 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2858 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue Jan 31, 2012 1:25 am |
|
 |
|
sumasmreq
Rookie
Joined: Fri Jan 27, 2012 6:57 pm Posts: 40
|
 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:
|
| Tue Jan 31, 2012 1:36 am |
|
 |
|
matt
Rookie
Joined: Mon Jan 30, 2012 8:15 pm Posts: 5
|
 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?
|
| Tue Jan 31, 2012 5:12 am |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 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.
_________________ sudo rm -rf /
|
| Tue Jan 31, 2012 11:08 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 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: 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.
_________________leonoverweel.com
|
| Tue Jan 31, 2012 9:04 pm |
|
 |
|
matt
Rookie
Joined: Mon Jan 30, 2012 8:15 pm Posts: 5
|
 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.
|
| Wed Feb 01, 2012 5:26 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 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.
_________________leonoverweel.com
|
| Wed Feb 01, 2012 5:52 pm |
|
 |
|
matt
Rookie
Joined: Mon Jan 30, 2012 8:15 pm Posts: 5
|
 Re: Color sensor as strobe
Good idea, I think that might work!
|
| Wed Feb 01, 2012 7:18 pm |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 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.
_________________ sudo rm -rf /
|
| Wed Feb 01, 2012 8:27 pm |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 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).
_________________leonoverweel.com
|
| Wed Feb 01, 2012 10:26 pm |
|
 |
|
matt
Rookie
Joined: Mon Jan 30, 2012 8:15 pm Posts: 5
|
 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?
|
| Thu Feb 02, 2012 6:46 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 Re: Color sensor as strobe
There shouldn't be but try it with low power first
_________________leonoverweel.com
|
| Thu Feb 02, 2012 5:40 pm |
|
|