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


Python Arduino.digitalWriteDown方法代码示例

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


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

示例1: verify

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import digitalWriteDown [as 别名]
def verify():
	global PATHS, DEVICES, SEM,SEM2,ALL
	tiempo = 0
	
	while 1:		
		data = {}
		devices = Device.objects.all()
		for device in devices:
			if device.path not in PATHS:
				PATHS.append(device.path)
				arduino = Arduino(device.path)
				DEVICES.append(arduino)
				
			else:
			
				for dev in DEVICES:
					if dev.getLocation() == device.path:
						arduino = dev
						break
			test = True
			while test:
				#print "while"
				#print 
				try:
					data[device.path] = ast.literal_eval(arduino.readAll())		
					test = False
				except:				
					pass
		controllersComplete = ControllerComplete.objects.all()
		for controller in controllersComplete:
			
			value = ""
			try:
				value = data[controller.sensor.device.path][controller.sensor.pin]

			except Exception,e:
				print e
			try:
				flag = eval(str(value)+controller.condition+controller.value)	
				if controller.actuator.ejecute and not flag:
					P(SEM)
					arduino = Arduino(controller.actuator.device.path)
					ActuatorArduino.objects.filter(id = controller.actuator.id).update(ejecute = False)
					arduino.digitalWriteDown(controller.actuator.pin)
					V(SEM)
			
				elif flag and not controller.actuator.ejecute:
					P(SEM)
					arduino = Arduino(controller.actuator.device.path)
					ActuatorArduino.objects.filter(id = controller.actuator.id).update(ejecute = True)
					arduino.digitalWriteUp(controller.actuator.pin)
					V(SEM)
			except Exception, e:
				print e
开发者ID:EmaBord,项目名称:freedom,代码行数:56,代码来源:views.py

示例2: action

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import digitalWriteDown [as 别名]
	def action(self, request,pk):
		global DEVICES,PATHS,SEMAPHORES
		actuator = self.get_object()
		arduino = Arduino(actuator.device.path)
		if actuator.ejecute:
			P(SEM)
			ejecute = False			
			ActuatorArduino.objects.filter(id = actuator.id).update(ejecute = False)
			arduino.digitalWriteDown(actuator.pin)
			V(SEM)
		else:
			P(SEM)
			ejecute = True			
			ActuatorArduino.objects.filter(id = actuator.id).update(ejecute = True)
			arduino.digitalWriteUp(actuator.pin)
			V(SEM)
		return Response([{"actuator_name":actuator.name,"ejecute":ejecute}])
开发者ID:EmaBord,项目名称:freedom,代码行数:19,代码来源:views.py


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