Newbie issue


hi, can't make work.
what want turn led on press of button , turn off press.
code: [select]
const int = 2;
const int led = 5;
int state = 0;
int statelast = 0;

void setup() {
  // put setup code here, run once:
pinmode(but, input);
pinmode(led, input);
serial.begin(9600);
}

void loop() {
  state = digitalread(but);
 
    if (state == high && statelast == low){
      digitalwrite (led, high);
     
   
  }
  else if (state == high && statelast == high){
    digitalwrite (led, low);
  }
 
 statelast = state;
 delay(100);   


}

quote
what want turn led on press of button , turn off press.
well, have our permission that.

posting code without explaining how hardware connected , code does, , how differs want, rather pointless.


Arduino Forum > Using Arduino > Programming Questions > Newbie issue


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor