Manufacturers

RSS feed

No RSS feed added

Linkerkit Button Module

Linkerkit button module uses a nice big tactile switch which is mounted on a small circuit board along with the pull up resistor making it ready to plug into the Linkerkit base board and onto your Arduino or pcDuino via some ribbon cable.

More details


AU$2.74

AU$2.74 per each

LKT-00163

7 items in stock

Add to my wishlist

Loyalty program By buying this product you can collect up to 2 loyalty points. Your cart will total 2 points that can be converted into a voucher of AU$0.04.


75 quantities 50 quantities 25 quantities 10 quantities 5 quantities
-AU$0.37 -AU$0.36 -AU$0.35 -AU$0.34 -AU$0.30

Customers who bought this product also bought...

Manufacturer: Linksprite

Description: Button module for use with the Linkerkit sheild for Arduino and pcDuino.

Sample  Arduino Code:

const int ButtonPin=9;

void setup()

{

  pinMode(ButtonPin, INPUT);

  Serial.begin(9600);   // init serial to 9600b/s

}  

void loop()

{

  int sensorValue = digitalRead(ButtonPin);

  if(sensorValue==1)

  {

    Serial.println("Hign");

  }

  else

  {

    Serial.println("Low");  

    }

}

 

Example pcDuino C/C++ code to take input from switch and turn on LED

// Connect switch to pin 2 and an LED to pin 3. Press button and LED
// lights for 2 seconds and turns off.

#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

// some defines which you can put into a .h file
#define GPIO_MODE_PATH "/sys/devices/virtual/misc/gpio/mode/"
#define GPIO_PIN_PATH "/sys/devices/virtual/misc/gpio/pin/"
#define GPIO_FILENAME "gpio"
#define HIGH '1'
#define LOW  '0'
#define INPUT  '0'
#define OUTPUT '1'
#define INPUT_PU '8'

// There are 18 IO pins, so declare file descriptors for all 18
int pinMode[18];
int pinData[18];

void writePin(int fileID, int value);

int main(void)
{
        char inputBuf = HIGH;
        char path[256];

        // Initialise the file descriptors for pin 2 & 3 mode and data files
        for (int i = 2; i <= 3; i++)
        {
                memset(path,0,sizeof(path)); // clear the path variable
                // Create path for pin mode file
                sprintf(path, "%s%s%d", GPIO_MODE_PATH, GPIO_FILENAME, i);
                pinMode[i] = open(path, O_RDWR);  // set pin mode
                memset(path, 0, sizeof(path)); // clear the path variable
                // Create path for the pin data file
                sprintf(path, "%s%s%d", GPIO_PIN_PATH, GPIO_FILENAME, i);
                pinData[i] = open(path, O_RDWR); // set pin data
        }

        writePin(pinMode[3], OUTPUT); // set as output
        writePin(pinData[3], LOW); // and write a LOW (0) to pin
        writePin(pinMode[2], INPUT_PU); // set pin 2 as input

        // Lets wait for pin 2 to go high (switch pressed)
        do
        {
                lseek(pinData[2], 0, SEEK_SET); // set to begining of file
                // first byte is the interesting one so read it
                read(pinData[2], &inputBuf, 1);
                usleep(100000); // 0.1sec sleep
        } while (inputBuf == HIGH);
        // set pin 3 high for 2 seconds then low again
        writePin(pinData[3], HIGH);
        usleep(2000000);
        // now turn pin 3 off (LOW)
        writePin(pinData[3], LOW);
        usleep(2000000);
}


void writePin(int fileID, int value)
{
  char buf[4];  // Need to write 4 bytes for it to work.
  memset((void *)buf, 0, sizeof(buf)); // clear the buffer out.
  sprintf(buf, "%c", value);  // create buffer to write
  lseek(fileID, 0, SEEK_SET);   // set to top of the file
  write(fileID, buf, sizeof(buf));  // and write.
}

No customer comments for the moment.

Only registered users can post a new comment.

Cart  

No products

Shipping AU$0.00
Total AU$0.00

Check out