View unanswered posts | View active topics It is currently Mon Dec 22, 2014 6:25 pm






Reply to topic  [ 9 posts ] 
How to code a Lego infrared sensor 
Author Message
Rookie

Joined: Mon Jun 03, 2013 2:02 pm
Posts: 4
Post How to code a Lego infrared sensor
I'm trying to make a simple Mindstorms robot that will act as a turret using an infrared sensor. The goal is for the robot to just turn and scan the environment and when the infrared sensor detects the beacon, it will stop. I was wondering how I would go about in coding such a robot.


Mon Jun 03, 2013 2:14 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: How to code a Lego infrared sensor
Which infrared sensor?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon Jun 03, 2013 7:43 pm
Profile WWW
Rookie

Joined: Mon Jun 03, 2013 2:02 pm
Posts: 4
Post Re: How to code a Lego infrared sensor
The Lego Mindstorms Infrared Receiver seen here: http://shop.lego.com/en-US/LEGO-MINDSTORMS-NXT-IR-Receiver-2855040


Mon Jun 03, 2013 7:58 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: How to code a Lego infrared sensor
I would start turning the motor, go into a loop, and continuously check for a signal. If a signal appeared I'd break out of the loop and tell the motor to stop.

Are you using RobotC? (I guess you would be, since you're on this forum)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Mon Jun 03, 2013 9:36 pm
Profile
Rookie

Joined: Mon Jun 03, 2013 2:02 pm
Posts: 4
Post Re: How to code a Lego infrared sensor
I am using RobotC but I am not very experienced with it and it would help if I could get an example of this code.


Tue Jun 04, 2013 1:43 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: How to code a Lego infrared sensor
That sensor is designed for sensing the signals from a power functions remote. I don't think it'll work as a beacon detector.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Jun 04, 2013 1:53 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: How to code a Lego infrared sensor
That sensor can be used as a sensor for the FTC beacon. You can use the built-in drivers but you have to enable a few things first. First put ROBOTC in expert mode like this:
Attachment:
2013-06-05_15-14-03.png
2013-06-05_15-14-03.png [ 5.18 KiB | Viewed 3744 times ]

After that, you have to enable access to these sensors:
Attachment:
2013-06-05_15-15-25.png
2013-06-05_15-15-25.png [ 7.15 KiB | Viewed 3744 times ]

Make sure the line with HiTechnic in it is ticked.

Now you can select the sensor (either 600 or 1200 Hz) from the list
Attachment:
2013-06-05_15-17-12.png
2013-06-05_15-17-12.png [ 20 KiB | Viewed 3744 times ]


= 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]


Wed Jun 05, 2013 9:18 am
Profile WWW
Rookie

Joined: Mon Jun 03, 2013 2:02 pm
Posts: 4
Post Re: How to code a Lego infrared sensor
Alright, I have the Lego Infrared Seeker, can I get a sample of how I would code what I want with this?


Wed Jun 05, 2013 1:58 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: How to code a Lego infrared sensor
Read the sensor's data with SensorValue[]. Experiment with simply displaying its value on the screen to see what kind of numbers it returns.

= 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]


Wed Jun 05, 2013 2:04 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 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:  



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