This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Energia: Using MSP430F5529 Launch Pad: Can anybody differentiate the meaning of two codings because result are different

 (1) led is as input.

int buttonState = 0;

void setup() 

pinMode(41,INPUT);
pinMode(13, OUTPUT); //P2.6
}

// the loop routine runs over and over again forever:
void loop() 
{
buttonState = digitalRead(41);

if (buttonState == HIGH)
{
digitalWrite(13, LOW);

}

else
{
digitalWrite(13, HIGH);

}
}

 (2) led is as input_pullup.
int buttonState = 0;

void setup() 

pinMode(41,INPUT_PULLUP);
pinMode(13, OUTPUT); //P2.6
}

// the loop routine runs over and over again forever:
void loop() 
{
buttonState = digitalRead(41);

if (buttonState == HIGH)
{
digitalWrite(13, LOW); 

}

else
{
digitalWrite(13, HIGH);

}
}

Try both codings and result will be different. Objective: To make led turn on/off by push button 2.1.

 

Can anybody explain difference between intput_pullup and input only?

Circuits:

**Attention** This is a public forum