예제 #1
0
파일: pin.py 프로젝트: ePyBoard/ePyBoard
from machine import PIN
from machine import LED
total_pin = 35
pin_title = 'P'
pin_num = 0
failNum = 0
led = LED(1)
led.on()
led.off()
irq_count = 0


def count(t):
    global irq_count
    if irq_count < 5:
        irq_count = irq_count + 1
    else:
        irq_count = 0


while pin_num < total_pin:
    if pin_num == 17 or pin_num == 18:
        pin_num += 1
        continue
    gpio_set = pin_title + str(pin_num)
    p_test = PIN(gpio_set)  #创建I/O
    p_test.mode(PIN.OUT)  #设置引脚模式为输出
    p_test.drive(PIN.LOW_POWER)  #设置引脚驱动强度
    p_test.value(1)  #设置引脚的值
    print(p_test)
    cmp_str = "Pin('" + gpio_set + "', mode=Pin.OUT, pull=Pin.INACTIVE, drive=Pin.LOW_POWER, alt=0)"
예제 #2
0
파일: LM35.py 프로젝트: WrightWuTW/ePy-Lite
'''
溫度 LM35
Out -- AIN0 
GND -- GND
VCC -- 3.3V
'''
from machine import UART, ADC, Pin, LED
import utime
rled = LED('ledr')
gled = LED('ledg')
rgbled = LED(LED.RGB)

rled.off()
gled.off()

adc0 = ADC(Pin.board.AIN0)

count = 0
while True:
    ''' Lite ADC have 12bit '''

    adc_0 = adc0.read() >> 2
    # temp = (adc_val /1024(10bit) *ADC_VCC ) *0.01 oC
    temp = (adc_0 / 1024 * 3.3) / 0.01
    print('{:3.2f} oC'.format(temp))
    utime.sleep_ms(1000)
예제 #3
0
from machine import LED
total_pin = 4					
pin_num=1

while pin_num < (total_pin+1): 
 led_test=LED(int(pin_num))		#LED1~4循序亮灭
 print(led_test)
 led_test.on()
 for j in range(0,5000,1):
  continue
 led_test.off()
 for j in range(0,5000,1):
  continue
 led_test.toggle()
 for j in range(0,5000,1):
  continue
 led_test.toggle()
 for j in range(0,5000,1):
  continue
 pin_num=pin_num+1
예제 #4
0
# need update ePy-Lite micropython image to V1.5

from machine import LED, Pin, ADC, Switch, UART
import utime, micropython, sys, gc

# setting 接收 ADVERT information

ADV_NAME = '08167319'
myID = '01'

ledy = LED('ledy')
ledr = LED('ledr')
ledg = LED('ledg')
ledrgb = LED(LED.RGB)

ledy.off()
ledr.off()
ledg.off()

keya = Switch('keya')

#使用  UART1 連接 BLE,並增加接收 Buffer
BLE_uart = UART(1, 115200, read_buf_len=1024)

# 確認切到 command mode
BLE_uart.write('!CCMD@')
utime.sleep_ms(200)
BLE_uart.write('!CCMD@')
utime.sleep_ms(200)
ledy.toggle()
예제 #5
0
'''
CMC GMFS02EVB
pin1 -- AIN0 (up)
pin4 -- AIN1 (down)
pin3 -- GND
pin2 -- 3.3V
'''
from machine import UART, ADC, Pin, LED
import utime
rled = LED('ledr')
gled = LED('ledg')
rgbled = LED(LED.RGB)

rled.off()
gled.off()
adc0 = ADC(Pin.board.AIN0)
adc1 = ADC(Pin.board.AIN1)
count = 0
while True:
    adc_0 = adc0.read()
    adc_1 = adc1.read()
    report0 = adc_0 * 3.3 / (2**12)
    report1 = adc_1 * 3.3 / (2**12)
    if (report0 - report1 >= 1.2):
        if count == 3:
            count = 1
        else:
            count = count + 1
        if count == 1:
            rgbled.rgb_write(1, 255, 0, 0)
            rgbled.rgb_write(2, 0, 255, 0)
예제 #6
0
from machine import LED, delay

ledR = LED('ledr')
ledY = LED('ledy')
ledG = LED('ledg')

ledR.off()
ledY.off()
ledG.off()
delay(1000)
ledR.on()
ledY.on()
ledG.on()

while True:
    ledG.toggle()
    delay(1000)