Membrane switch with blend micro


#1

I am using a membrane switch to activate a led, but the led is turning on randomly.

From what I learned via videos, this is caused by the pin floating. Not being 0 or 1.
Does the blend micro have a internal resistor or do I need a external resistor to pull down the pin?

Kind regards,


#2

Hi @binsento, you can set the input pin to be input pull down:

void setup() {
  pinMode(pin, INPUT);
  digitalWrite(pin, LOW);
}

Cheers!


#3

When I use the given code it doesn’t help, it still turns on and off randomlly. Or am i not using the above code not correctly. As i only implemented that piece of code and didn’t change anything in the button example.


#4

I found a way around it, instead of using the 3.3 volts from the MC instead i connect the switch to ground and to the pins. And when it reads low it flashes the LED.


#5

So you have got the problem resolved?


#6

Yes my problem as being solved.