HiTechnic IR sensor
Page 1 of 1

Author:  JohnCena [ Sun Nov 15, 2015 6:47 am ]
Post subject:  HiTechnic IR sensor

Hey guys,
I have been trying to get my IR seeker v1 trying to work, and this is my code:
#pragma config(Sensor, S3,     IRSensor,                 sensorHiTechnicIRSeeker1200)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main() {

   int IR = SensorValue(IRSensor);
   nxtDisplayTextLine(2, "%d", IR);


This doesn't seem to be giving me what I expect it to, does anyone know what the cause of this could be?


Author:  RandyOrton [ Tue Nov 17, 2015 4:00 am ]
Post subject:  Re: HiTechnic IR sensor

Hi John,

It appears you have a similar issue to what I had. Here is some code with comments that I was able to get working. Hopefully this will help you work out what is wrong, it mostly looks like you have the wrong sensor defined and should have the header file. You also need to use the functions specific to the device as seen in the code.

#pragma config(Sensor, S1,     IRSensor,       sensorI2CCustom) //Note the sensor is defined as a different resource

#include "includes/hitechnic-irseeker-v1.h" //includes the IRSeeker v1 header file for access to it's functions

task main() {


  HTIRSreadAllStrength(IRSensor, IR_Strength[0], IR_Strength[1], IR_Strength[2], IR_Strength[3], IR_Strength[4]); //Determines signal strength from various receivers
   IR_Direction = HTIRSreadDir(IRSensor); //Reads the direction (0-9) of the IR sensor

  //Displays all values from sensor to NXT device screen
  nxtDisplayTextLine(1, "IR Direction: %d", IR_Direction);
  nxtDisplayTextLine(2, "IR1: %d", IR_Strength[0]);
  nxtDisplayTextLine(3, "IR2: %d", IR_Strength[1]);
  nxtDisplayTextLine(4, "IR3: %d", IR_Strength[2]);
  nxtDisplayTextLine(5, "IR4: %d", IR_Strength[3]);
  nxtDisplayTextLine(6, "IR5: %d", IR_Strength[4]);

Author:  Lando [ Tue Nov 17, 2015 9:35 am ]
Post subject:  Re: HiTechnic IR sensor

Hey im still new to robotC however code that worked for me used a #include drivers line.

#pragma config(Sensor, S1, IRSensor, sensorI2CCustom)

#include "drivers/hitechnic-irseeker-v1.h"\

i had a similar issue however after exploring the sample code i was able to make it run. I then just made an integer variable call _dir
then to connect it with the IRsensor i used _dir = HTIRSreadDir(IRSensor); then simply used this variable when i needed to access the IRsensor value.

Hope this helps

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group