Sensores Ópticos

Produtos visualizados

CNY70 - Reflective Optical Sensor

BE15000450

Novo produto

CNY70 - Reflective Optical Sensor

Mais detalhes

1,91 € com IVA

Adicionar à Lista de desejos

Mais informação

Datasheet:

CNY70 - Reflective Optical Sensor

Example CNY70 connection:

 

Code:

/*CNY70 test to use this sensor as an analog input

Program that uses the infrared sensor CNY70 as analog input and checks the analog values
He returned by the sensor according to the colors to which point the sensor

This example code is in the public domain*/

float val;

void setup() {
Serial.begin(9600);
}

void loop() {
val = analogRead(A1);
Serial.println(val);
delay(500);
}

Code:

/* Program that uses the infrared sensor CNY70 as digital input on or off two LEDs

The CNY70 is wired for being on black read '1'; and if you are on white read a '0'

You can find the wiring CNY70 in the document in the file uncompressed

If the infrared sensor is on black, digital input 8 will have the value "1": LED will light up and
digital input 9 have the value "0": the other LED will turn off
If the infrared sensor is on target, the digital input 8 has the value '0', the LED will turn off
and digital input 9 have the value "1": the other LED lights

This example code is in the public domain*/

int ledPin1 = 8; //led green
int ledPin2 = 9; //led red
int infraPin = 2;
int valueInfra = 0;

void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(infraPin, INPUT);
}


void loop() {
valueInfra = digitalRead(infraPin);
digitalWrite(ledPin1, valueInfra);

valueInfra = !valueInfra;
digitalWrite(ledPin2, valueInfra);

}

Acessórios