Botão de pressão p/ Breadboard 6x6mm

:CEL10132
0,20 €
preço com IVA incluído

Botão de pressão 6x6mm perfeito para executar os circuitos electrónicos em breadboad.

Dimensão L: 6mm

Quantidade

DESCRIÇÃO EM PORTUGUÊS BREVEMENTE DISPONÍVEL

Se tiver alguma dúvida neste produto não hesite em contactar-nos.

*Atenção: as imagens são meramente ilustrativas.

 

 

/* Learn to use pushbutton (button switch) with Arduino - Tutorial
   More info and circuit schematic: http://www.ardumotive.com/arduino-tutorials/category/button
   Dev: Michalis Vasilakis / Date: 19/10/2014  
   UPDATED 2/6/2016 - LED to Arduino pin 3 and button to Arduino pin 4*/


//Constants
const int buttonPin = 4;     
const int ledPin =  3;     

//Variables
int buttonState = 0;
int flag=0;

void setup() {
  //Input or output?
  pinMode(ledPin, OUTPUT);      
  pinMode(buttonPin, INPUT_PULLUP);   
}

void loop(){
  //Read button state (pressed or not pressed?)
  buttonState = digitalRead(buttonPin);

  //If button pressed...
  if (buttonState == LOW) { 
    //...ones, turn led on!
    if ( flag == 0){
      digitalWrite(ledPin, HIGH);
      flag=1; //change flag variable
    }
    //...twice, turn led off!
    else if ( flag == 1){
      digitalWrite(ledPin, LOW);
      flag=0; //change flag variable again 
    }    
  }
  delay(200); //Small delay

}

 

CEL10132

Também poderá gostar