Categories

TinkerKit PushButton

TinkerKit PushButton

More details

A2-0133

Warning: Last items in stock!

30 other products in the same category:

Previous
Next

TinkerKit PushButton.

The Pushbutton Module is possibly the simplest sensor available. It detects when a person or an object presses on its circular cap.

Module Description:

This module features a 12mm pushbutton , the standard TinkerKit 3pin connector, a green LED that signals that the module is correctly powered and a yellow LED that is lit only when the button is pressed.

This module is a SENSOR. The connector is an OUTPUT which must be connected to one of the INPUT connectors on the TinkerKit Shield.

Code Example:


/*
  Button

 Turns on and off a T010111 LED Module connected to O0 (digital  
 pin 11), when pressing a T000180 pushbutton attached to I0 (analog pin 0). 

 created 2005
 by DojoDave
 modified 17 Jun 2009
 by Tom Igoe
 modified 7 dec 2010
 by Davide Gomba

 This example code is in the public domain.

 based on  http://www.arduino.cc/en/Tutorial/Button
 */


 #define O0 11
 #define O1 10
 #define O2 9
 #define O3 6
 #define O4 5
 #define O5 3
 #define I0 A0
 #define I1 A1
 #define I2 A2
 #define I3 A3
 #define I4 A4
 #define I5 A5

// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = I0;     // the number of the pushbutton pin
const int ledPin =  O0;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}

Basket  

No products

0,00€ Shipping
0,00€ Tax
0,00€ Total

Prices are tax included

Check out

Newsletter

PayPal

TESt"; ?>