View unanswered posts | View active topics It is currently Sun Sep 20, 2020 11:24 am

Reply to topic  [ 3 posts ] 
HiTechnic IR sensor 
Author Message

Joined: Sun Nov 08, 2015 5:50 pm
Posts: 1
Post 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?


Sun Nov 15, 2015 6:47 am

Joined: Tue Nov 17, 2015 3:45 am
Posts: 1
Post 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]);

Tue Nov 17, 2015 4:00 am

Joined: Sun Nov 08, 2015 5:52 pm
Posts: 2
Post 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

Tue Nov 17, 2015 9:35 am
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.