Interface switch , arduino and do following: ** SW1 : when press, transmit “Good Morning ” ** SW1 : when open, transmit “Bad Morning "

Here i am using online IDE Tinkercad . If you don't know what is tinkercad then refer my blog HERE or else you can use offline IDE also.

Code :-

int ps =5;

void setup()

{

  pinMode(13, INPUT);

  Serial.begin(9600);

}

void loop()

{

          int buttonState = digitalRead(13);

  if (buttonState == HIGH && ps != buttonState ) {

      Serial.println("Good Morning");

   }

  if (buttonState == LOW && ps != buttonState) {

      Serial.println("Bad Morning");

   }

  ps = buttonState;

  delay(1000);

}

output :-



Comments

Popular Posts

What is Tinkercad ? How to use Tinkercad ?

Connect switch to Arduino. If switch is on than print ”ON” else print “OFF” on serial monitor.

Develop an interfacing circuit and a sketch to increment count on 7-Segment based on switch press. Count goes from 00 to 99.