Python :Linker_Button

524

4

Posted in TechnologyArduino

Introduction: 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

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

Share

    Recommendations

    • Spotless Contest

      Spotless Contest
    • Microcontroller Contest

      Microcontroller Contest
    • Space Challenge

      Space Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments