int buttonPin = 2;
int Led = 10;
int count = 0;
int count1 = 0;
void setup() {
pinMode(buttonPin,INPUT_PULLUP);
pinMode(Led,OUTPUT);
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(2), led2,HIGH );
}
void loop() {
//read the state of the button input
if (count % 2 == 0 ) { // if the button is pressed it is low state
digitalWrite(Led,HIGH); //see flickering led or less bright
}
else if ((count % 2 != 0) ) {
digitalWrite(Led,LOW);
}
Serial.println(count1);
delay(1000);
}
void led2 ()
{
if (count1 == 0)
{
Serial.println("hehe");
count ++;
count1 ++;
}
delay(1000);
}
// int buttonPin = 7;
// int led = 4;
// void setup() {
// // put your setup code here, to run once:
// pinMode(buttonPin, INPUT);
// pinMode(led, OUTPUT);
// Serial.begin(9600);
// }
// void loop() {
// // put your main code here, to run repeatedly:
// int buttonState = digitalRead(buttonPin);
// int Ledstate = digitalRead(led);
// if(buttonState == HIGH){
// digitalWrite(led, HIGH);
// Serial.println(Ledstate);
// delay(100);
// }
// if(buttonState == LOW){
// digitalWrite(led, LOW);
// Serial.println(Ledstate);
// delay(100);
// }
// }