Other Arduino Codes and Videos by Robojax

Arduino code and video for Sharp IR distance module with TM1637 Display

دروس آردوینو به فارسی

This is the Arduino code and video for Sharp IR distance Module

This video shows you how to measure the distance between 4cm to 180cm depending on the module, using Arduino and TM1637 display. Sharp Analog output modules:
  1. How to use Sharp Infrared Distance Sensor
  2. How to use two or more Sharp Infrared Distance Sensors
  3. Display Distnace on 4 Digit LED Display with Sharp Infrared Distance Sensors
  4. Dispaly distnace from Sharp Infrared Distance Sensors on LCD1602-I2C
  5. Dispaly distnace from Sharp Infrared Distance Sensors on LCD1602 (without I2C)
  6. Distance Measuring Sensors (Website)
  7. Datasheet (PDF ) for sharp IR GP2Y0A41SK0F
  8. Datasheet (PDF ) for Sharp IR GP2Y0A710K0F
  9. Datasheet (PDF ) for sharp IR GP2Y0A21YK
  10. download TM1637 Manual
  11. TM1637 Library (from Robojax.com)
  12. TM1637 Library (from GetHub)
  13. Sharp IR Library (from Robojax.com)
  14. Sharp IR Library (from getHub)

  
 /*
 * Sharp IR (infra-red) distance measurement module with TM1637 Display for Arduino
 * Measures the distance in cm.

 * Original library: https://github.com/guillaume-rico/SharpIR
  * Original code for TM1637 from https://github.com/avishorp/TM1637
  
 * Watch Video instrution for this code: https://youtu.be/dnjY9n927HI
 * 
 * Full explanation of this code and wiring diagram is available at
 * my Arduino Course at Udemy.com here: http://robojax.com/L/?id=62

 * Written by Ahmad Shamshiri on Feb 03, 2018 at 12:32
 * in Ajax, Ontario, Canada. www.robojax.com
 * 

 * Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on Udemy.com http://robojax.com/L/?id=62

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon http://robojax.com/L/?id=63

or make donation using PayPal http://robojax.com/L/?id=64

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

*/
#include <Arduino.h>
#include <TM1637Display.h>

// Display Module connection pins (Digital Pins)
#define CLK 2 // connect CLK to pin 2
#define DIO 3 // connect DIO to pin 3

// The amount of time (in milliseconds) between display
#define TEST_DELAY   100  
  uint8_t blank[] = { 0x0, 0x0, 0x0, 0x0 };// blank screen

TM1637Display display(CLK, DIO);

///////////////////***** start of Sharp IR
#include <SharpIR.h>

#define IR A0 // define Sharp IR signal pin
#define model 430 // the model of the IR module
// Sharp IR code for Robojax.com
// ir: the pin where your sensor is attached
// model: an int that determines your sensor:
/*
 * GP2Y0A02YK0F --> "20150"
 GP2Y0A21YK --> "1080"
 GP2Y0A710K0F --> "100500"
  GP2YA41SK0F --> "430"
 */

SharpIR SharpIR(IR, model);
/////////////////////**** end of Sharp IR


void setup()
{
  // Sharp IR with TM1637 Display code for Robojax.com
   display.setBrightness(0x0f);// set the brightness at max
}

void loop()
{
  // Sharp IR with TM1637 Display code for Robojax.com
  display.setSegments(blank);// clear the screen
  
  int dis=SharpIR.distance();  // this returns the distance to the object you're measuring

  display.showNumberDec(dis, false, 3, 1);// display the distance
  delay(TEST_DELAY);//delay between display
 // Sharp IR with TM1637 Display code for Robojax.com


}
   

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal