Difference between revisions of "3 Bottom IO port control"

From Banana Pi Wiki
Jump to: navigation, search
Line 8: Line 8:
  
 
*If you attach the gold finger to the base, other smaller blue and white line pins can be used as well, which was specifically noted in the introduction of the hardware in chapter 1. You can forget to check the [http://wiki.banana-pi.org/BPI-Bit#Hardware  BPI:bit hardware].
 
*If you attach the gold finger to the base, other smaller blue and white line pins can be used as well, which was specifically noted in the introduction of the hardware in chapter 1. You can forget to check the [http://wiki.banana-pi.org/BPI-Bit#Hardware  BPI:bit hardware].
 +
 +
*In this module of microbit, the interface of the board is defined as pinN object, where N represents the value of the interface, so the no. 0 interface is also called pin0 object. If you find this is not easy to use later, you can redefine your favorite Pin name by import machine Pin.
 +
 +
=Shy board=
 +
 +
We want to touch the pin of the board and make it respond accordingly, and it looks like a shy little girl.
 +
 +
code as below:
 +
 +
from microbit import *
 +
while True:
 +
    if pin1.is_touched():
 +
        display.show(Image.HAPPY)
 +
    else:
 +
        display.show(Image.SAD)

Revision as of 02:35, 18 February 2019

How to control the board's input and output!

IO in the computer refers to Input/Output, namely Input and Output, referred to as IO port.

Bitio.png

  • IO ports are different, some are larger, and in general, there are tags near them for users to understand. For example, the bottom of this board is distributed on goldfinger in the order of 0/1/2/3V/GND (most computers start from 0).
  • If you attach the gold finger to the base, other smaller blue and white line pins can be used as well, which was specifically noted in the introduction of the hardware in chapter 1. You can forget to check the BPI:bit hardware.
  • In this module of microbit, the interface of the board is defined as pinN object, where N represents the value of the interface, so the no. 0 interface is also called pin0 object. If you find this is not easy to use later, you can redefine your favorite Pin name by import machine Pin.

Shy board

We want to touch the pin of the board and make it respond accordingly, and it looks like a shy little girl.

code as below:

from microbit import *
while True:
   if pin1.is_touched():
       display.show(Image.HAPPY)
   else:
       display.show(Image.SAD)