当前位置: 首页>>代码示例>>Python>>正文


Python Arduino.locateport方法代码示例

本文整理汇总了Python中Arduino.Arduino.Arduino.locateport方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.locateport方法的具体用法?Python Arduino.locateport怎么用?Python Arduino.locateport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arduino.Arduino.Arduino的用法示例。


在下文中一共展示了Arduino.locateport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class THERM_BUZZER:
	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.therm=4
		self.buzzer=3
	    
		for i in range(20):
			val=self.obj_arduino.cmd_analog_in(1,self.therm)
			print val

			if (int(val) > 550):
				self.obj_arduino.cmd_digital_out(1,self.buzzer,1)
				
							
			else:
				self.obj_arduino.cmd_digital_out(1,self.buzzer,0)
				sleep(2)

	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:32,代码来源:9.2THERM-BUZZER.py

示例2: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class LED_ON_OFF_LOOP:

	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.blue=9
		self.green=10
		self.red=11
		for i in range(6):
			self.obj_arduino.cmd_digital_out(1,self.green,1)
			sleep(2)
			self.obj_arduino.cmd_digital_out(1,self.green,0)
			sleep(2)

	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:ankushbansal3103,项目名称:pyarduino,代码行数:27,代码来源:4.4LED.py

示例3: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class SERVO_INIT:
	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.pin1=9
		self.obj_arduino.cmd_servo_attach(1,1)
		self.obj_arduino.cmd_servo_move(1,1,30)
		sleep(1)
		self.obj_arduino.cmd_servo_detach(1,1)
		sleep(1)
		
		
			

	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:27,代码来源:9.1SERVO.py

示例4: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class LDR:
	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.ldr=5
		self.blue=9
		self.green=10
		self.red=11
		for i in range(100):
			val=self.obj_arduino.cmd_analog_in(1,self.ldr)
			print val
			if int(val) < 300:
				self.obj_arduino.cmd_digital_out(1,self.blue,1)
			else:
				self.obj_arduino.cmd_digital_out(1,self.blue,0)
			sleep(0.5) 	

	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:30,代码来源:6.2LDR.py

示例5: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class SERVO_POT:
	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.pin1=9
		self.pot=2
		self.pos=0
		self.obj_arduino.cmd_servo_attach(1,1)
		sleep(1)
		self.angle=18
		for i in range(100):
			val=self.obj_arduino.cmd_analog_in(1,self.pot)
			print val
			val = int(val*180/1023)
			print val
			self.obj_arduino.cmd_servo_move(1,1,val)
			sleep(0.5)
		self.obj_arduino.cmd_servo_detach(1,1)
		
	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:32,代码来源:9.4SERVO.py

示例6: setup

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
    def setup(self):
        global obj_arduino
        obj_arduino=Arduino()
        self.port=obj_arduino.locateport()
        obj_arduino.open_serial(1,self.port,self.baudrate)

        self.obj_icm=IC_methods(self.baudrate)
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:9,代码来源:trial2.py

示例7: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class SIPO_IC:

    
    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()


    def setup(self):
        
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):

        dataPin=11
        clockPin=9
        latchPin=10
        inPin=5

        for _ in range(0,100):
            
            self.obj_arduino.cmd_digital_out(1,latchPin,0) #So that the data is stored and not passed on to the output LEDs
            self.obj_arduino.cmd_shift_out_(dataPin,clockPin,inPin)
            self.obj_arduino.cmd_digital_out(1,latchPin,1) #So that the stored data is now passed on to the output LEDs
                                                            #and the output is obtained
            sleep(0.5)

    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:35,代码来源:SIPO_2.py

示例8: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class DCMOTOR_ROTATION:
	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.pin1=9
		self.pin2=10
		self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pin1,self.pin2)
		self.obj_arduino.cmd_dcmotor_run(1,1,100)
		sleep(2)
		self.obj_arduino.cmd_dcmotor_release(1,1)
		
		
			

	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:27,代码来源:7.1DCMOTOR.py

示例9: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class PUSHBUTTON_LED:

	def __init__(self,baudrate):
		self.baudrate=baudrate
		self.setup()
		self.run()
		self.exit()

	def setup(self):
		self.obj_arduino=Arduino()
		self.port=self.obj_arduino.locateport()
		self.obj_arduino.open_serial(1,self.port,self.baudrate)

	def run(self):
		self.blue=9
		self.green=10
		self.red=11
		self.pushbutton=12
		for i in range(20):
			val=self.obj_arduino.cmd_digital_in(1,self.pushbutton)
			#sleep(0.5)
			print val
			self.obj_arduino.cmd_digital_out(1,self.blue,val)
			sleep(0.5)
	def exit(self):
		self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:28,代码来源:5.2pushbutton.py

示例10: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class LED_ON_OFF_MULTICOLOR:

    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()


    def setup(self):
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):
        self.blue=9
        self.green=10
        self.red=11
        self.obj_arduino.cmd_digital_out(1,self.blue,self.baudrate)
        self.obj_arduino.cmd_digital_out(1,self.red,self.baudrate)
        sleep(5)
        self.obj_arduino.cmd_digital_out(1,self.blue,0)
        sleep(3)
        self.obj_arduino.cmd_digital_out(1,self.red,0)

    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:29,代码来源:4.3LED.py

示例11: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class T_FF:

    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()


    def setup(self):
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):

        self.T='0'
        
        self.tPin=5
        
        #assuming initial state:
        self.Q='0'
        self.Qbar='1'

        self.qPin=9
        self.qbarPin=10

        self.clockPin=2 #external clock


        for _ in range(0,500):

            if self.Q=='0':
                self.obj_arduino.cmd_digital_out(1,self.qPin,0)
                self.obj_arduino.cmd_digital_out(1,self.qbarPin,1)
                sleep(0.1)
            else:
                self.obj_arduino.cmd_digital_out(1,self.qPin,1)
                self.obj_arduino.cmd_digital_out(1,self.qbarPin,0)
                sleep(0.1)


            if self.obj_arduino.cmd_digital_in(1,self.clockPin)=='1': #Reads clock and executes when it is HIGH

                self.T=self.obj_arduino.cmd_digital_in(1,self.tPin) #Reads input T

                if self.T=='1':
                    temp=self.Q
                    self.Q=self.Qbar
                    self.Qbar=temp
                else:
                    pass
                


    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:59,代码来源:T+FF+level.py

示例12: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class PISO_IC_p:

    
    
    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()


    def setup(self):
        
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

       # self.obj_icm=IC_methods(self.baudrate)

    def run(self):

        dataPin=9
        clockPin=10
        latchPin=11

        ledPin=5 #LED that shows serial output
        clockLed=6 #LED that shows clock pulses

        p=int(raw_input("Enter no. of times parallel load is to be given: "))

        self.obj_arduino.cmd_digital_out(1,latchPin,1) #parallel load mode

        for _ in range(0,p):
            print ("Give input, Parallel load mode:")
            sleep(2)
            self.obj_arduino.cmd_digital_out(1,clockPin,1) #positive edge occurs
                                                           #parallel load is stored
            print("Inputs stored, Serial shift mode:")
            sleep(0.5)

            self.obj_arduino.cmd_digital_out(1,clockPin,0)
            self.obj_arduino.cmd_digital_out(1,latchPin,0) #serial out mode

            self.obj_arduino.cmd_shift_in(dataPin,clockPin,ledPin,clockLed)

            self.obj_arduino.cmd_digital_out(1,latchPin,1)
            self.obj_arduino.cmd_digital_out(1,ledPin,0)

    
        
        
    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:55,代码来源:PISO_p_times.py

示例13: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class SIPO_IC:

    
    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()


    def setup(self):
        
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):
        
        pinstate=0
        n=int(raw_input("Enter no. of bits: "))
        data=[0 for _ in range(0,n)] #an 8-elements list representing an 8 bit binary number
        
        dataPin=11
        clockPin=9
        latchPin=10
        inPin=5

        for _ in range(0,50):
            pinstate=self.obj_arduino.cmd_digital_in(1,inPin)
            if pinstate=='1':
                data[0]=1
                #the msb becomes 1 when input is given
                #high which is henceforth shifted
            else:
                data[0]=0
            print data

            self.obj_arduino.cmd_digital_out(1,latchPin,0)
            self.obj_arduino.cmd_shift_out_n(dataPin,clockPin,'LSBFIRST',data,n)
            self.obj_arduino.cmd_digital_out(1,latchPin,1)
            sleep(0.5)
            for k in range(0,(n-1)):
                data[(n-1)-k]=data[(n-2)-k]
            data[0]=0
            #every element of the matrix is
            #shifted one place to the right
            #so effectively the 8 bit
            #binary number is divided by 2
                  
              

    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:55,代码来源:SIPO_n_bits.py

示例14: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class PUSHBUTTON_LED:

    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()

    def setup(self):
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):
        self.blue=9
        self.green=10
        self.red=11
        self.pushbutton=12


        l = 10  # length
        x = range(l)  # x axis
        T = [0 for i in range(l)]  # initial value
        for i in range(20):
            val=self.obj_arduino.cmd_digital_in(1,self.pushbutton)
            #sleep(0.5)
            print val
            self.obj_arduino.cmd_digital_out(1,self.blue,val)
            sleep(0.5)


            plt.ion()
            #plt.show()

            t = int(val)
            T.pop(0)  # pop first value
            T.append(t)  # push at the end keeping list of same size
            plt.title("Is Pushbutton pressed ?")
            plt.grid(True)
            plt.ylabel('Pushbutton')
            plt.legend(loc='upper left')
            plt.axis([0, l, 0, 2])
            plt.scatter(x, T, linewidth=5)
            plt.draw()
            plt.pause(.0001)
            plt.clf()
        plt.close('all')


    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:ankushbansal3103,项目名称:pyarduino,代码行数:53,代码来源:5.2pushbuttonplot.py

示例15: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import locateport [as 别名]
class LDR:
    def __init__(self,baudrate):
        self.baudrate=baudrate
        self.setup()
        self.run()
        self.exit()

    def setup(self):
        self.obj_arduino=Arduino()
        self.port=self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):
        self.ldr=5
        self.blue=9
        self.green=10
        self.red=11

        l = 100  # length
        x = range(l)  # x axis
        T = [420 for i in range(l)]  # initial value

        for i in range(20):
            val=self.obj_arduino.cmd_analog_in(1,self.ldr)
            print val
            if int(val) < 300:
                self.obj_arduino.cmd_digital_out(1,self.blue,1)
            else:
                self.obj_arduino.cmd_digital_out(1,self.blue,0)
            sleep(0.5)

            plt.ion()
            #plt.show()

            t = int(val)
            T.pop(0)  # pop first value
            T.append(t)  # push at the end keeping list of same size
            plt.title("Reading LDR Data from Arduino...!")
            plt.grid(True)
            plt.ylabel('LDR Readings')
            plt.legend(loc='upper left')
            plt.axis([0, l, 0.55 * min(T), 2 * max(T)])
            plt.plot(x, T ,linewidth=1)
            plt.draw()
            plt.pause(.0001)
            plt.clf()
        plt.close('all')


    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:ankushbansal3103,项目名称:pyarduino,代码行数:53,代码来源:6.2LDRplot.py


注:本文中的Arduino.Arduino.Arduino.locateport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。