//dieu khien chuc nang vua nhann input vua cho ra out put
#define led 2 // ten la led va gia tri thay the la so 2
#define button 0 // dinh nghia chan so 0
void setup() {
pinMode (button, INPUT_PULLUP);
pinMode (led, OUTPUT);
}
void loop() {
static bool buttonState = HIGH; // luu tam thoi o muc cao
if(digitalRead(button)==LOW){ // lenh doc nut nhan va kiem tra vs dkien trong ngoac
if(buttonState==HIGH) // muc cao + nhan nut se cho ra nngo ra ....
{
digitalWrite(led, !digitalRead(led));
delay (200);
buttonState=LOW;
}
}
else
{
buttonState=HIGH;
}
}