Tuesday, July 31, 2012

Line Hunting Sensor Module

Kali ini kita akan belajar untuk mendeteksi line (line tracking) dengan menggunakan photosensitive diode. Line hitam akan membangkitkan signal low sedangkan line putih akan membangkitkan signal high. Sedangkan untuk DIO digunakan input no 12.



------------------------------------------------------------------------------------------------------------------------------------------
/* Define the DIO pin that will be used to communicate with the sensor */
#define LINEHUNTSENS_DIO 12


/* Initialise serial and DIO */
void setup()
{
  /* Setup the serial port for displaying the status of the sensor */
  Serial.begin(9600);
 
  /* Configure the DIO pin the sensor will be connected to as an input */
  pinMode(LINEHUNTSENS_DIO, INPUT);
}


/* Main program loop */
void loop()
{
  /* If the DIO pin is pulled low then an object has been detected */
  if (!digitalRead(LINEHUNTSENS_DIO))
    Serial.println("Object detected !");   
}



Source