Author |
Message |
mkbay
Rookie
Joined: Mon Jun 03, 2013 2:02 pm Posts: 4
|
 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 |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 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 |
|
 |
mkbay
Rookie
Joined: Mon Jun 03, 2013 2:02 pm Posts: 4
|
 Re: How to code a Lego infrared sensor
|
Mon Jun 03, 2013 7:58 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 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 |
|
 |
mkbay
Rookie
Joined: Mon Jun 03, 2013 2:02 pm Posts: 4
|
 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 |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 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 |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 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: After that, you have to enable access to these sensors: Make sure the line with HiTechnic in it is ticked. Now you can select the sensor (either 600 or 1200 Hz) from the list = 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 |
|
 |
mkbay
Rookie
Joined: Mon Jun 03, 2013 2:02 pm Posts: 4
|
 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 |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 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 |
|
|