Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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
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.
 

abhignans

Newbie level 6
Joined
Feb 1, 2012
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,401
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
 
  • Like
Reactions: brian25

    brian25

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

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top