GPIO

 ,--------------------------------.

| oooooooooooooooooooo J8   +======

| 1ooooooooooooooooooo  PoE |   Net

|  Wi                    1o +======

|  Fi  Pi Model 4B  V1.5 oo      |

|        ,----. +---+         +====

| |D|    |SoC | |RAM|         |USB3

| |S|    |    | |   |         +====

| |I|    `----' +---+            |

|                   |C|       +====

|                   |S|       |USB2

| pwr   |hd|   |hd| |I||A|    +====

`-| |---|m0|---|m1|----|V|-------'


Revision           : c03115

SoC                : BCM2711

RAM                : 4GB

Storage            : MicroSD

USB ports          : 4 (of which 2 USB3)

Ethernet ports     : 1 (1000Mbps max. speed)

Wi-fi              : True

Bluetooth          : True

Camera ports (CSI) : 1

Display ports (DSI): 1


J8:

   3V3  (1) (2)  5V    

 GPIO2  (3) (4)  5V    

 GPIO3  (5) (6)  GND   

 GPIO4  (7) (8)  GPIO14

   GND  (9) (10) GPIO15

GPIO17 (11) (12) GPIO18

GPIO27 (13) (14) GND   

GPIO22 (15) (16) GPIO23

   3V3 (17) (18) GPIO24

GPIO10 (19) (20) GND   

 GPIO9 (21) (22) GPIO25

GPIO11 (23) (24) GPIO8 

   GND (25) (26) GPIO7 

 GPIO0 (27) (28) GPIO1 

 GPIO5 (29) (30) GND   

 GPIO6 (31) (32) GPIO12

GPIO13 (33) (34) GND   

GPIO19 (35) (36) GPIO16

GPIO26 (37) (38) GPIO20

   GND (39) (40) GPIO21


POE:

TR01 (1) (2) TR00

TR03 (3) (4) TR02


For further information, please refer to https://pinout.xyz/


#main.py

____________________________________________________________

#!/usr/bin/env python3

import RPi.GPIO as GPIO

import time



GPIO.setmode(GPIO.BCM)


GPIOsw1 = 2

GPIOsw2 = 4

GPIOsw3 = 17

GPIOsw4 = 27


LED_red = 22

LED_green1 = 10

LED_green2 = 9



GPIO.setup(GPIOsw1,GPIO.IN,pull_up_down=GPIO.PUD_UP)

GPIO.setup(GPIOsw2,GPIO.IN,pull_up_down=GPIO.PUD_UP)

GPIO.setup(GPIOsw3,GPIO.IN,pull_up_down=GPIO.PUD_UP)

GPIO.setup(GPIOsw4,GPIO.IN,pull_up_down=GPIO.PUD_UP)



GPIO.setup(LED_red,GPIO.OUT)

GPIO.setup(LED_green1,GPIO.OUT)

GPIO.setup(LED_green2,GPIO.OUT)

           




GPIO.output(LED_red, GPIO.HIGH)

GPIO.output(LED_green1, GPIO.HIGH)

GPIO.output(LED_green2, GPIO.HIGH)

time.sleep(1)

GPIO.output(LED_red, GPIO.LOW)

GPIO.output(LED_green1,GPIO.LOW)

GPIO.output(LED_green2,GPIO.LOW)

    


while True:

    sw1 = GPIO.input(GPIOsw1)

    sw2 = GPIO.input(GPIOsw2)

    sw3 = GPIO.input(GPIOsw3)

    sw4 = GPIO.input(GPIOsw4)

    if sw1==0:

        GPIO.output(LED_red, GPIO.HIGH)

        GPIO.output(LED_green1, GPIO.LOW)

    elif sw1==1:

        GPIO.output(LED_red, GPIO.LOW)

        GPIO.output(LED_green1, GPIO.HIGH)














コメント

このブログの人気の投稿

自動起動