Scale-N

Scale-N
Arduino
Componenten
Rollend Materieel
Naslag
Onderdelen
Wissels
Basis Electronica
Symbols Electronica
Programming Arduino
DCC++
DR5000
Products
Link













































Infrared sensor TCRT5000
TCRT5000 IR Sensor

The Ardiuno TCRT5000 is designed to sense the distance to an object using Infra Red light waves. It can also identify the difference between white and black based on the contrast of an object and it’s reflective properties.
Arduino Uno
Breadboard
Wire
Weestanden
1x 100 Ohm
1x 10k Ohm


Bouwen
De TCRT5000
Weerstanden

Connect de Anode van de IR emitter aan een 100 Ohm weerstand.
Connect de Collector aan een 10000 Ohm weerstand
Wire

5V => 100 Ohm weerstand
5V => 10K Ohm weerstand
Gnd => Cathode van de IR Emitter
Gnd => Emitter
Connect een analoge pin van de arduino met de Collector
5V van de arduino
Gnd van de arduino


Code
/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}



Output arduino monitor

Output in de arduino monitor na aanraking met pen.
De waarde bij het lezen van het analoog signaal is 0 to 1024. Afhankelijk van de afstand van het voorwerp.

ref: http://blog.huntgang.com/