Speed Detection With LinkIt One

With IR Sensor we can detect the speed of motor. I have a small rover which is powered by Intel Edison and I was curious to know its speed so let us create a device that will detect the speed of a vehicle. In this application we will be using LinkIt One board. If you want to know more about LinkIt One you can go through the previous articles of this series:

Requirements

  • LinkItOne Board
  • IR Sensor
  • USB Cable

IR Sensor

The reflectivity of infrared light varies with the color and distance of the reflecting surface. The Grove Infrared Reflective sensor is based on the same principle. It has a RPR220 reflective photosensor module which detects color and distance. When a light-colored object approaches, the signal intensity received by infrared reflective sensor increases and the indicator LED on board turns red. When a dark-colored object approaches, the intensity decreases and the LED turns off.

Specifications

  • Voltage: 4.5-5.5V
  • Current: 14.69 - 15.35 mA
  • Effective Distance: 4-15 mm
  • Detectable Length(black line): 1 mm

Features:

  • Operating voltage: 4.5 V - 5.5 V
  • Digital output, 0 or VCC
  • High resolution sensor
  • Indicator LED on board
  • Sensitivity adjustable via potentiometer
  • Small Grove 1X1 compatible interface

board

board

Connections

  1. Connect LinkIt One to your computer using a USB A to micro B cable.
  2. Connect the Infrared Reflective Sensor onto the D2 port of Grove Base Shield.
  3. In the Arduino IDE, go to the Tools pull-down menu at the top, select Board, and make sure “LinkIt One” is checked.
  4. Then pull down the Tools menu again, and select appropriate Serial Port.

If you have multiple serial ports to choose from and aren’t sure which to choose, try unplugging the board from your computer and plugging the board back again to see which port gets added.

Download the Timer Library from Arduino timer1 library and add it to Arduino Library folder. I have marked a black line on a circular piece of paper and attached it to a servo which is controlled by my Intel Edison so that sensor can get one signal when the circle rotates a round.

sensor

Code

  1. #include < TimerOne.h >  
  2.     unsignedint counter = 0;  
  3. void blink()   
  4. {  
  5.     counter++;  
  6. }  
  7. voidtimerIsr()  
  8. {  
  9.     Timer1.detachInterrupt(); //disable the timer1  
  10.     Serial.print("The speed of the motor: ");  
  11.     Serial.print(counter, DEC);  
  12.     Serial.println("round/s");  
  13.     counter = 0;  
  14.     Timer1.attachInterrupt(timerIsr); //enable the timer1  
  15. }  
  16. void setup()  
  17. {  
  18.     Serial.begin(9600);  
  19.     Timer1.initialize(1000000); // set a timer of length 1sec  
  20.     attachInterrupt(0, blink, RISING); //INT0  
  21.     Timer1.attachInterrupt(timerIsr); // attach the service routine here  
  22. }  
  23. void loop()   
  24. {; //do nothing  
  25. }  
sensor

speed

Other project ideas with IR Sensors
  • Line-following robots
  • Rotary speed detection
  • Auto data logging on utility meters

Up Next
    Ebook Download
    View all
    Learn
    View all