if statement
hi have written function uses if statement:
the led blinks bit , turns off. want led blink while soft sensor being touched , of other things listed @ same time.
when used code check sensor circuit- works properly- blinks while sensor touched conductive pom-pom , stops when pom-pom taken away.
here code:
{
serial.println(analogread(1)); //send value of analog input 2
delay(10); //delay give analog digital converter time
if (analogread(1)>350)
(digitalwrite(6, high));
delay(100);
(digitalwrite(6,low));
}
[/code][/code]
thanks i'm sure there simple solution- use help
code: [select]
void walkmode(void) {
if (analogread(1)>300 || analogread(3)>300){
digitalwrite(6, high); //blink led when writing eeprom
delay(100);
digitalwrite(6,low);
readsensors();
parse();
writetoeeprom();
delay(200);
}
if (index == 507){
digitalwrite(6, high); //if eeprom full keep led1 on.
}
}
the led blinks bit , turns off. want led blink while soft sensor being touched , of other things listed @ same time.
when used code check sensor circuit- works properly- blinks while sensor touched conductive pom-pom , stops when pom-pom taken away.
here code:
code: [select]
[code]int led =6;
int sensor = 1;
void setup()
{ //start serial communication
serial.begin(9600);
pinmode(6, output);
}
void loop() {
serial.println(analogread(1)); //send value of analog input 2
delay(10); //delay give analog digital converter time
if (analogread(1)>350)
(digitalwrite(6, high));
delay(100);
(digitalwrite(6,low));
}
[/code][/code]
thanks i'm sure there simple solution- use help
the problem isn't if statement. statement:
this statement says nothing watch clock until specified time has elapsed.
if clock watching important, means use statement.
if want other things, , periodically check clock, @ blink without delay example see how can done.
basically, set flags, saying needs done, , times when last done. on each pass through loop, check see if it's time change anything.
when turn led on, discrete event. note time. on each pass through loop, see if led on , it's time turn led off. if so, that's discrete event. record time.
if not, see if led off , it's time turn led on.
code: [select]
delay(100);this statement says nothing watch clock until specified time has elapsed.
if clock watching important, means use statement.
if want other things, , periodically check clock, @ blink without delay example see how can done.
basically, set flags, saying needs done, , times when last done. on each pass through loop, check see if it's time change anything.
when turn led on, discrete event. note time. on each pass through loop, see if led on , it's time turn led off. if so, that's discrete event. record time.
if not, see if led off , it's time turn led on.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > if statement
arduino
Comments
Post a Comment