コード例 #1
0
def pattern3():
    for y in range(5):
        for i in range(4):
            phy.dWrite("A" + str(y), 1)
            time.sleep(0.5)
            phy.dWrite("A" + str(y), 0)
            time.sleep(0.5)
        phy.dWrite("A" + str(y), 1)

    for x in range(5):
        phy.dWrite("A" + str(x), 0)
コード例 #2
0
from Phygital_v0 import Phygital_v0 as phy
import time

phy.pinMode("A0", "dOutput")
# init
phy.init("COM3")  # Add the COM Port Number Here
phy.pinMode("A2", "dOutput")
phy.pinMode("A3", "dOutput")
phy.pinMode("A4", "dOutput")
phy.pinMode("A1", "dOutput")

while True:
    try:

        phy.dWrite("A0", 1)
        phy.dWrite("A4", 1)
        time.sleep(1)
        phy.dWrite("A1", 1)
        phy.dWrite("A3", 1)
        time.sleep(1)
        phy.dWrite("A2", 1)
        time.sleep(1)

        phy.dWrite("A0", 0)
        phy.dWrite("A4", 0)
        time.sleep(1)
        phy.dWrite("A1", 0)
        phy.dWrite("A3", 0)
        time.sleep(1)
        phy.dWrite("A2", 0)
        time.sleep(1)
コード例 #3
0
"""
Code to Control LED State On-Off

LED connected at A0

"""
"""Library"""
from Phygital_v0 import Phygital_v0 as pyro
import time
"""Pin Initialization"""
pyro.pinMode('A0', 'dOutput')
pyro.pinMode('A1', 'dOutput')
pyro.pinMode('A2', 'dOutput')
"""Init"""
pyro.init("COM8")
"""LED ON"""

while True:
    try:
        pyro.dWrite('A0', 0)
        pyro.dWrite('A2', 0)
        pyro.dWrite('A1', 1)  #LED ON
        time.sleep(0.5)  #Wait for 1 Sec

        pyro.dWrite('A0', 1)
        pyro.dWrite('A2', 1)
        pyro.dWrite('A1', 0)  #LED Off
        time.sleep(0.5)  #Wait for 1 Sec

    except:
        if KeyboardInterrupt:
コード例 #4
0
# -*- coding: utf-8 -*-
from Phygital_v0 import Phygital_v0 as phy
import time 

phy.init("COM8") #Add the COM Port Number Here

while True:
    try:
        print("Servo Motors in Action")
        
        phy.MoveServo(9,90)
        
        time.sleep(1)
        
        phy.MoveServo(9,10)
        
        time.sleep(1)
        
    except:
        if KeyboardInterrupt:
            phy.close()
            break
        
print("Closing")
コード例 #5
0
"""
Program to test the code numbers of Colour Cards.

Code Reader Connections.

Object Sensor 1 --> Pin A5
Object Sensor 2 --> Pin A4
Object Sensor 3 --> Pin A3
"""

from Phygital_v0 import Phygital_v0 as pyro
import time

pyro.pinMode('A5', 'dInput')
pyro.pinMode('A4', 'dInput')
pyro.pinMode('A3', 'dInput')

pyro.init("COM8")

while True:

    try:
        Data1 = pyro.dRead('A5')
        Data2 = pyro.dRead('A4')
        Data3 = pyro.dRead('A3')

        DecimalCode = (Data3 * 4) + (Data2 * 2) + (Data1 * 1)
        BinaryCode = str(Data3) + str(Data2) + str(Data1)

        print("Binary Code is: " + BinaryCode)
        print("Decimal code is: " + str(DecimalCode))
コード例 #6
0
"""
Code to Control LED State On-Off
LED connected at A0
"""
"""Library"""
from Phygital_v0 import Phygital_v0 as pyro
"""Pin Initialization"""
pyro.pinMode('A0', 'dOutput')
"""Init"""
pyro.init("COM5")
"""LED ON"""

while True:
    try:
        pyro.dWrite('A0', 1)  #LED ON

    except:
        if KeyboardInterrupt:
            pyro.close()
            break

print("Closed the Connection!!")
"""Closing"""
コード例 #7
0
"""
Code to Control LED State On-Off

LED connected at A0

"""

"""Library"""
from Phygital_v0 import Phygital_v0 as pyro
import time

"""Pin Initialization"""
pyro.pinMode('A0','dOutput')
pyro.pinMode('A1','dOutput')
pyro.pinMode('A2','dOutput')
pyro.pinMode('A3','dOutput')
pyro.pinMode('A4','dOutput')

"""Init"""
pyro.init("COM15")

"""LED ON"""
LEDPins=['A0','A1','A2','A3','A4']

while True:
    try:
       
        for i in range(5):
            pyro.dWrite(LEDPins[i],1)
            time.sleep(0.5)
            pyro.dWrite(LEDPins[i],0)
コード例 #8
0
""" Set the Screen"""
screen = pygame.display.set_mode((Width, Height))
""" Set The Title of Screen"""
pygame.display.set_caption("Sensor Based Display")
""" Load the Image"""
screenImg = pygame.image.load("Images/background.jpg")
""" Display Image at Specific Co-Ordinate"""

screen.blit(screenImg, (0, 0))

img = pygame.image.load("Images/arrow.png")
newimg = pygame.transform.scale(img, (400, 400))

screen.blit(newimg, (60, 60))

phy.pinMode("A0", "dinput")
phy.pinMode("A1", "dinput")
phy.init("COM13")

while True:
    try:
        pygame.display.update()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                phy.close()
                EventStatus = "Quit"
                break

        data1 = phy.dRead('A0')
コード例 #9
0
"""
Program to Read the State of Object Sensor 
and Put On LED when Object is Sensed.
"""

from Phygital_v0 import Phygital_v0 as pyro

# Pin Initialization
pyro.pinMode('A0', 'dOutput')
pyro.pinMode('A5', 'dInput')
#Communication Init
pyro.init("COM8")

while True:
    try:

        #Read State of Sensor
        data = pyro.dRead('A5')
        print("Sensor State: " + str(data))

        if data == 0:  # Object Sensed
            print("Object Sensed")
            pyro.dWrite('A0', 1)

        else:
            print("No Object")
            pyro.dWrite('A0', 0)

    except:
        if KeyboardInterrupt:
            pyro.close()
コード例 #10
0
def pattern2():
    phy.dWrite("A0", 1)
    time.sleep(1)
    phy.dWrite("A4", 1)
    time.sleep(1)
    phy.dWrite("A1", 1)
    time.sleep(1)
    phy.dWrite("A3", 1)
    time.sleep(1)
    phy.dWrite("A2", 1)
    time.sleep(1)

    phy.dWrite("A0", 0)
    time.sleep(1)
    phy.dWrite("A4", 0)
    time.sleep(1)
    phy.dWrite("A1", 0)
    time.sleep(1)
    phy.dWrite("A3", 0)
    time.sleep(1)
    phy.dWrite("A2", 0)
    time.sleep(1)
コード例 #11
0
"""
Program to Read the State of Object Sensor 
and Display it on Console.
"""

from Phygital_v0 import Phygital_v0 as pyro

# Pin Initialization
pyro.pinMode('A5', 'dInput')
#Communication Init
pyro.init("COM8")

while True:
    try:

        #Read State of Sensor
        data = pyro.dRead('A5')
        print("Sensor State: " + str(data))

        if data == 0:  # Object Sensed
            print("Object Sensed")

        else:
            print("No Object")

    except:
        if KeyboardInterrupt:
            pyro.close()
            break
print("Closing")
コード例 #12
0
from Phygital_v0 import Phygital_v0 as phy
import time

phy.pinMode("A0", "dOutput")
# init
phy.init("COM3")  # Add the COM Port Number Here
phy.pinMode("A2", "dOutput")
phy.pinMode("A3", "dOutput")
phy.pinMode("A4", "dOutput")
phy.pinMode("A1", "dOutput")

while True:
    try:
        led_no = int(input("Enter a led no.:"))
        led_state = input("Enter a led_state:")
        num = 0
        if led_state == "on":
            num = 1
        else:
            num = 0
        phy.dWrite("A" + str(led_no), num)
        time.sleep(1)

    except:
        if KeyboardInterrupt:
            phy.close()
            break

print("Closing")
コード例 #13
0
"""
Code to Control LED State On-Off

LED connected at A0

"""
"""Library"""
from Phygital_v0 import Phygital_v0 as pyro
import time
"""Pin Initialization"""
pyro.pinMode('A0', 'dOutput')
pyro.pinMode('A1', 'dOutput')
pyro.pinMode('A2', 'dOutput')
pyro.pinMode('A3', 'dOutput')
pyro.pinMode('A4', 'dOutput')
"""Init"""
pyro.init("COM15")
"""LED ON"""
LEDPins = ['A0', 'A1', 'A2', 'A3', 'A4']

BinaryNum = {
    0: [0, 0, 0, 0, 0],
    1: [0, 0, 0, 0, 1],
    2: [0, 0, 0, 1, 0],
    3: [0, 0, 0, 1, 1],
    4: [0, 0, 1, 0, 0],
    5: [0, 0, 1, 0, 1],
    6: [0, 0, 1, 1, 0],
    7: [0, 0, 1, 1, 1],
    8: [0, 1, 0, 0, 0],
    9: [0, 1, 0, 0, 1],