Introduction: Python :Linker_Button

Picture of Python :Linker_Button



Linker button is the key, the SIG(signal output port) of linker button is at a low level(logic0)in case no button

pressed, after the button press, SIG will output a high level (logic 1). And pcduino GPIO through testing

linker button SIG level to determine key state.

In this post, we will demo how to control the linker led through linker button.
Refer links:http://learn.linksprite.com/pcduino/pyhon/python-%EF%BC%9Alinker_button/

Step 1: Part List

1. pcDuino V2   x1

2. Linker Button  x1

3. Linker LED    x1

4. Linker Base  x1

5. Linker cable  x2

Step 2: Wiring Diagram

Picture of Wiring Diagram

Step 3: Test Code

import gpio
from time import sleep

led_pin = "gpio2"
button_pin = "gpio3"

def delay(ms):
    sleep(1.0*ms/1000)

def setup():
        gpio.pinMode(led_pin, gpio.OUTPUT)
        gpio.pinMode(button_pin, gpio.INPUT)
        print " Linker LED Pin : D2 \n Linker Button Pin : D3"

def loop():
        while(1):
                if(gpio.digitalRead(button_pin)):
                        gpio.digitalWrite(led_pin, gpio.HIGH)
                else :
                        gpio.digitalWrite(led_pin, gpio.LOW)

setup()
loop()

Step 4: Test Result

Picture of Test Result

Comments

About This Instructable

515views

4favorites

License:

More by Yanny Guo:Use pcDuino as Photo Booth ControllerUse Si4703 FM Breakout Board on Arduino UnoUse SIM900 GPRS/GSM Shield on pcDuino
Add instructable to: