Go Down

Topic: Led and arduino please help pleas (Read 1 time) previous topic - next topic

rockyinc

Nov 17, 2011, 10:19 am Last Edit: Nov 17, 2011, 11:01 am by rockyinc Reason: 1
how can i program that if i have a analog sensor witch has delay of 100 ms an if i want to say , thdat if the value reaches lets say 900, the led will blink at the rate of 1s so how can i program like there are 2 loops? so thet the blinking time and the sensor reset time dont get togeder so that the led time is separeted from  sensors? plz tell me the code

rockyinc

#1
Nov 17, 2011, 11:15 am Last Edit: Nov 17, 2011, 11:52 am by rockyinc Reason: 1
please tell me what is wrong here and what do i need to do?

PaulS

Quote
please tell me what is wrong here

Nothing. Everything here is just fine. The occasional doofus who asks for help without saying what they need help with, but, it's manageable.

Quote
what do i need to do?

All depends. What IS your problem?
The art of getting good answers lies in asking good questions.

AWOL



rockyinc

here is the problem for the sensor on this attechment . so whit all those delays how can i achive that the sensor delay will be separeted so they dont interfir whit the led delay?


#define SENSOR 0  // select the input pin for the
int led = 13;                  // sensor resistor

int val = 0; // variable to store the value coming
             // from the sensor
             
void setup() {
 
  Serial.begin(9600); // open the serial port to send
                      // data back to the computer at
                      // 9600 bits per second
}

void loop() {
 
  val = analogRead(SENSOR); // read the value from
                            // the sensor
                           
  Serial.println(val); // print the value to
                       // the serial port
                       
  delay(100); // wait 100ms between
              // each send
if ( val > 800){
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led,LOW);
delay(1000);
   }else{
      digitalWrite(led, LOW);
   }
}

AWOL

Take the delays out, and look at the blink without delay example sketch.

rockyinc

than the blinking is to fast isnt ther a other way to use those delay but so that they dont interfere with ich other ?

PaulS

Quote
Take the delays out, and look at the blink without delay example sketch.
The art of getting good answers lies in asking good questions.

Go Up