Crowtail- Button

From Elecrow
(Difference between revisions)
Jump to: navigation, search
(Description)
(One intermediate revision by one user not shown)
Line 17: Line 17:
 
1.Hardware connection
 
1.Hardware connection
  
[[File:buttoncontrol.jpg |400px]]
+
[[File:buttoncontro.jpg |600px]]
[[File:buttoncontrol1.jpg |600px]]
+
  
 
2.Upload the following sample sketch to make the LED turn ON and OFF based on input from Crowtial - Button:
 
2.Upload the following sample sketch to make the LED turn ON and OFF based on input from Crowtial - Button:

Revision as of 09:46, 13 July 2019

Contents

Description

The Crowtail-Button is a momentary push button which rebounds on its own after it is released. The button outputs a HIGH signal when pressed, and LOW when released.

Model: CT0002BT

Crowtail-Button.JPG

Features

  • Easy to use momentary ON/OFF button
  • Uses Standard 3-pin Crowtail Cables to connect to the Crowtail - Base Shield

Usage

Button control LED

1.Hardware connection

Buttoncontro.jpg

2.Upload the following sample sketch to make the LED turn ON and OFF based on input from Crowtial - Button:

/*
 Button
 
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 5, when pressing a pushbutton attached to pin 4. 
*/

// set pin numbers:
const int buttonPin = 4;     // the number of the pushbutton pin
const int ledPin =  5;      // 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); 
 }
}

3.Press the Botton, you will see the LED lights up.
Button result.jpg

Resource

Personal tools
Namespaces

Variants
Actions
Elecrow Store
Navigation
Elecrow Products
Toolbox