Page 1 of 1

IR Distance Click

PostPosted: Mon Jul 24, 2017 10:29 am
by mdfairuz4@gmail.com
Hello Mr/Mrs, I am Fairuz. I already bought an IR Sensor Click from cytron. I am having problem test the sensor connect to the arduino. I dunno either my connection between the sensor and arduino is not working or the coding is not working. Can you help me to overcome this problem by provide a tutorial using IR Distance Click with Arduino CT CYTRON UNO ? Thanks. :cry: :cry: :cry: :cry: :cry: :cry:

Re: IR Distance Click

PostPosted: Mon Jul 24, 2017 1:14 pm
by Idris
Hi mdFairuz4,

Could you share a few clear photos of your hardware setup? And your coding as well.

Thanks.

Re: IR Distance Click

PostPosted: Mon Jul 24, 2017 2:39 pm
by mdfairuz4@gmail.com
Hello, Mr. Idris, First thing first, thank you for willing to reply my request. Okay, here the picture i attached together. And the coding is provided as follow :

CODE: SELECT_ALL_CODE
/*=========================================================
Infra-Red distance measures: Send distance value in centimeters to serial
Connection the sensor to the Arduino:
  sensor - arduino
     VCC - 5V
     Gnd - GND
     OUT - A0

Briefing: 
This program has the sole purpose of measuring distances with the Infra-Red sensor.
It uses a previous calculated regression to convert analogRead values into distance values.
*/

const int irsensorpin = A0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop(){

 
  // Reads the InfraRed sensor analog values and convert into distance.
  int sensorValue = analogRead(irsensorpin);
  double IRdistance = 187754 * pow(sensorValue, -1.51);
 
  Serial.println(IRdistance);
 
  // A delay is added for a stable and precise input
  delay(100);
}

I connect the sensor to arduino by OUT to A0,
5V to 5V,
3.3V to 3.3V,
GND to GND,

I tried with this coding the serial monitor does not give any number. Looking forward for the reply. Thank Sir :) :)

Sorry for the messy table in the picture.

Re: IR Distance Click

PostPosted: Tue Jul 25, 2017 12:57 pm
by Idris
Hi, I just update the Getting Started with IR Distance click on Cytron Tutorial page. Please refer to this link: http://tutorial.cytron.com.my/2017/07/25/getting-started-ir-distance-click/

Thanks.

Re: IR Distance Click

PostPosted: Tue Jul 25, 2017 1:05 pm
by mdfairuz4@gmail.com
Very good tutorial. Thanks for the information ! Really appreciate it.


Thanks Mr Idris

Re: IR Distance Click

PostPosted: Wed Jul 26, 2017 8:30 am
by mdfairuz4@gmail.com
By the way Mr Idris, I used the previous coding that I post earlier, However the distance(output) did not give a good reading. Can i know how to create the formula based on ADC & Voltage reading ?


I need accurate & precise reading in my project. Really appreciate if i know how to create own formula..
Thank you