Python :Linker_Button

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/

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions