IR Distance Click

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

IR Distance Click

Postby mdfairuz4@gmail.com » Mon Jul 24, 2017 10:29 am

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:
mdfairuz4@gmail.com
Freshie
 
Posts: 4
Joined: Mon Jul 24, 2017 10:19 am

Re: IR Distance Click

Postby Idris » Mon Jul 24, 2017 1:14 pm

Hi mdFairuz4,

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

Thanks.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: IR Distance Click

Postby mdfairuz4@gmail.com » Mon Jul 24, 2017 2:39 pm

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.
Attachments
WhatsApp Image 2017-07-24 at 2.27.15 PM.jpeg
here the sensor connection
WhatsApp Image 2017-07-24 at 2.25.21 PM.jpeg
here the arduino connection
WhatsApp Image 2017-07-24 at 2.25.20 PM.jpeg
here the connection between arduino and the sensor
WhatsApp Image 2017-07-24 at 2.25.20 PM (1).jpeg
here for the testing
mdfairuz4@gmail.com
Freshie
 
Posts: 4
Joined: Mon Jul 24, 2017 10:19 am

Re: IR Distance Click

Postby Idris » Tue Jul 25, 2017 12:57 pm

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.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: IR Distance Click

Postby mdfairuz4@gmail.com » Tue Jul 25, 2017 1:05 pm

Very good tutorial. Thanks for the information ! Really appreciate it.


Thanks Mr Idris
mdfairuz4@gmail.com
Freshie
 
Posts: 4
Joined: Mon Jul 24, 2017 10:19 am

Re: IR Distance Click

Postby mdfairuz4@gmail.com » Wed Jul 26, 2017 8:30 am

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
mdfairuz4@gmail.com
Freshie
 
Posts: 4
Joined: Mon Jul 24, 2017 10:19 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 22 guests

cron