Help Arduino Program

Status
Not open for further replies.

brian25

Member level 2
Joined
Feb 18, 2013
Messages
52
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Visit site
Activity points
1,601
int pinA = 11;
int pinB = 12;
int val;

void setup()
{
pinMode(pinA, OUTPUT);
pinMode(pinB, INPUT);
}

void loop()
{
int();
}


void int()
{

val=digitalRead(pinB); // read data
if(pinB == HIGH)
{
Serial.println("PINA ON"); //write serially
}
else if(pinB == LOW)
{
Serial.println("PinA OFF"); //write serially
}
}

the message is keep repeating. how to stop the message in serial monitor even the pin is still in continuous active high or low status. it's just a one time message.
 

for the solution of this u can use goto statement and let the arduino wait for command
check this out i have rewritten the code with ur requirement
void int()
{

val=digitalRead(pinB); // read data
one:
if(pinB == HIGH)
{
Serial.println("PINA ON"); //write serially
goto two;}
else
{goto one;
two:
if(pinB == LOW)
{
Serial.println("PinA OFF"); //write serially
goto one;}
else{goto two;}
}



by this way the seriel message will be printed only once
 
Reactions: brian25

    brian25

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…