View unanswered posts | View active topics It is currently Sun Dec 21, 2014 4:58 pm






Reply to topic  [ 13 posts ] 
Color sensor as strobe 
Author Message
Rookie

Joined: Mon Jan 30, 2012 8:15 pm
Posts: 5
Post 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
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Jan 31, 2012 1:25 am
Profile WWW
Rookie

Joined: Fri Jan 27, 2012 6:57 pm
Posts: 40
Post 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);
}


Tue Jan 31, 2012 1:36 am
Profile
Rookie

Joined: Mon Jan 30, 2012 8:15 pm
Posts: 5
Post 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
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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
Profile
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post 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.

_________________
leonoverweel.com


Tue Jan 31, 2012 9:04 pm
Profile WWW
Rookie

Joined: Mon Jan 30, 2012 8:15 pm
Posts: 5
Post 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
Profile
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post 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
Profile WWW
Rookie

Joined: Mon Jan 30, 2012 8:15 pm
Posts: 5
Post Re: Color sensor as strobe
Good idea, I think that might work!


Wed Feb 01, 2012 7:18 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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
Profile
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post 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
Profile WWW
Rookie

Joined: Mon Jan 30, 2012 8:15 pm
Posts: 5
Post 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
Profile
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.