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

How to code a Lego infrared sensor
http://www.robotc.net/forums/viewtopic.php?f=1&t=5924
Page 1 of 1

Author:  mkbay [ Mon Jun 03, 2013 2:14 pm ]
Post subject:  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.

Author:  NeXT-Generation [ Mon Jun 03, 2013 7:43 pm ]
Post subject:  Re: How to code a Lego infrared sensor

Which infrared sensor?

Author:  mkbay [ Mon Jun 03, 2013 7:58 pm ]
Post subject:  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

Author:  Ernest3.14 [ Mon Jun 03, 2013 9:36 pm ]
Post subject:  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)

Author:  mkbay [ Tue Jun 04, 2013 1:43 pm ]
Post subject:  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.

Author:  NeXT-Generation [ Tue Jun 04, 2013 1:53 pm ]
Post subject:  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.

Author:  mightor [ Wed Jun 05, 2013 9:18 am ]
Post subject:  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 7169 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 7169 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 7169 times ]


= Xander

Author:  mkbay [ Wed Jun 05, 2013 1:58 pm ]
Post subject:  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?

Author:  mightor [ Wed Jun 05, 2013 2:04 pm ]
Post subject:  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

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