Arduino + LEDs + Sensor IR Sharp GP2D12

Hi!, I'm working with two LEDs, a red led, and a green led, + a breadboard, Sensor IR + Arduino.

I was mixing the programmings to obtain like result: to be able to integrate to protoboard 2 leds + sensor TO GO, leds one of red color that always must be ignition, and a LED of green color, that ignites when it detects movement. the thing is that " mixes the programmings of the file; IR" sensor; and " Blink" that it is for leds., and not like integrating loop of the file blink with the other? since I need to do if so that the red LED always ignited east, and when the sensor detects a movement, the LED activates there green and the red LED goes out.

thanks very much!!!!!!

I Hope your help! please...

Francisca. :slight_smile:

pd.:

the programmings is:

byte sensorPin=0;
int latestVal=0;
int maxVal=0;
int minVal=1024; 
int ledPin = 13;  //lo pegue del blink

void setup() {
  Serial.begin(9600);
  Serial.println("in setup");    
    pinMode(ledPin, OUTPUT);      // sets the digital pin as output - lo pegue del blink
} 

void loop() {
  //Serial.println("In loop");
  latestVal = analogRead(sensorPin);
  if(latestVal < minVal) {
    minVal = latestVal; 
  }
  if(latestVal > maxVal) {
    maxVal = latestVal;  
  }
  Serial.print("Max: ");
  Serial.print(maxVal);
  Serial.print(" Min: ");
  Serial.print(minVal);
  Serial.print(" Latest: ");
  Serial.println(latestVal);
  delay(1000);
}

______________________

This is for a Led:


/*
 * Blink
 *
 * The basic Arduino example.  Turns on an LED on for one second,
 * then off for one second, and so on...  We use pin 13 because,
 * depending on your Arduino board, it has either a built-in LED
 * or a built-in resistor so that you need only an LED.
 *
 * 
 */

int ledPin = 13;                // LED connected to digital pin 13

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()                     // run over and over again
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

I am not too sure what you are trying to do but you can't incorporate the blink with another program because it uses delay(). Look at this:-

and then add your sensor code to it.