pwm33.stop() elif(sys.argv[1]=="1" and sys.argv[2]=="2" and sys.argv[3]=="3"): pwm33.start(70) time.sleep(5) pwm33.stop() elif(sys.argv[1]=="1" and sys.argv[2]=="2" and sys.argv[3]=="4"): pwm33.start(85) time.sleep(5) pwm33.stop() elif(sys.argv[1]=="1" and sys.argv[2]=="2" and sys.argv[3]=="5"): pwm33.start(100) time.sleep(5) pwm33.stop() #raw_input('Press return to stop:') #Wait #time.sleep(5) # Stops the PWM #pwm12.stop() #pwm32.stop() pwm33.stop() #pwm35.stop() print("chala") # Cleans the GPIO GPIO.OUTPUT("0")
import time import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host_ip = 'DESKTOP-QV5HS8F' port = 6542 s.connect((host_ip, port)) trig = 15 echo = 16 GPIO.setup(trig, GPIO.OUT) GPIO.setup(trig, GPIO.IN) GPIO.OUTPUT(trig, False) time.sleep(10) GPIO.OUTPUT(trig, True) time.sleep(0.0001) GPIO.OUTPUT(trig, False) while GPIO.input(echo) == 0: pulse_begin = time.time() while GPIO.input(echo) == 1: pulse_end = time.time() pulse_time = pulse_end - pulse_begin
#led pinout test import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) import time pins=[17,18,27,22] for i,pin in enumerate(pins): GPIO.SETUP(pin,GPIO.OUT) for j in range(i+1): GPIO.output(pin,1) time.sleep(0.5) GPIO.OUTPUT(pin,0) time.sleep(0.5) GPIO.cleanup()
def stepperStep(a, b, c, d): GPIO.OUTPUT(A, a) GPIO.OUTPUT(B, b) GPIO.OUTPUT(C, c) GPIO.OUTPUT(D, d) time.sleep(0.0001)
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(27, GPIO.OUT) GPIO.OUTPUT(27, GPIO.HIGH)
def startRelay(): global relay, isAlarmOn if isAlarmOn: return for re in relay: GPIO.OUTPUT(relay['gpio'],GPIO,HIGH) isAlarmOn = True
for ((top, right, bottom, left), name) in zip(boxes, names): # draw the predicted face name on the image cv2.rectangle(frame, (left, top), (right, bottom), (0, 255, 0), 2) y = top - 15 if top - 15 > 15 else top + 15 cv2.putText(frame, name, (left, y), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 255, 0), 2) # display the image to our screen cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF #update_sheet("Face_Recognition" , name) if (name == name1): count = count + 1 cv2.imwrite(name + ".jpg", frame) if (name != name1): GPIO.OUTPUT(18, LOW) time.sleep(.8) GPIO.OUTPUT(18, HIGH) count2 = count2 + 1 row = row + 1 x = copy(open_workbook('book2.xls')) ws.write(row, 0, name) x.get_sheet(0).write(1, 2, count2) ws.write(row, 1, str(datetime.datetime.now())) wb.save("myworkbook.xls") w = copy(open_workbook('myworkbook.xls')) w.get_sheet(0).write(row, 0, name) w.get_sheet(0).write(1, 2, count2) w.get_sheet(0).write(row, 1, str(datetime.datetime.now())) w.save('book2.xls') # if the `q` key was pressed, break from the loop
def hc595_in(dat): for bit in range(0, 8): GPIO.output(SDI_PIN, 0x80 & (dat << bit)) GPIO.output(SRCLK_PIN, GPIO.HIGH) time.sleep(0.001) GPIO.OUTPUT(SRCLK_PIN, GPIO.LOW)
import time GPIO.setmode(GPIO.BCM) GPIO.setup(18,GPIO.OUT) GPIO.setup(23,GPIO.OUT) print #str= raw_input(); print "Press the button" try: GPIO.output(18,False) GPIO.output(23,False) val = input("input1 :") print(val) if val==1 : print "correct" GPIO.OUTPUT(18,HIGH) # val2= raw_input("input2 : ") # print(val2) # if GPIO.input(1)==1: # print "Buttonpressed" # time.sleep(100) except KeyboardInterrupt: GPIO.cleanup()
def Backward(speed): GPIO.OUTPUT(LeftBackward, True) GPIO.OUTPUT(RightBackward, True) GPIO.output(RightForwardward, False) GPIO.output(LeftForwardward, False)
def till_dist_halt(info): while info.getdist() != -1: #false when veh crosses signal info.close() call ( "wget CLOUD_URL_HERE" ) info = open("FILE_NAME", "rb") info = information while TRUE: while TRUE: # breaks when new object is available call ( "wget CLOUD_URL_HERE" ) info = open("FILE_NAME", "wb+") if ( info.getstatus() == 1): info.writestatus(0) file.write(info) # try closing file if needed (dev) # call("rm FILE_NAME") if necessary(dev) break if ( info.getprior() == HIGH): if(info.getdist() < 1 ): #green lights , in 1km GPIO.OUTPUT( GO, TRUE ) elif(info.getprior() == MID ): if(info.getdist() < .5 ): #green lights , in .5km GPIO.OUTPUT( GO, TRUE ) elif(info.getprior() == LOW): if(info.getdist() < .2 ): #green lights , in .2km GPIO.OUTPUT(GO,TRUE) till_dist_halt()
#현재 위젯의 모양등을 초기화 self.setWindowFlags(QtCore.Qt.FramelessWindowHint) form_lbx = QBoxLayout(QBoxLayout.TopToBottom, parent=self) self.setLayout(form_lbx) self.resize(800, 480) self.center() form_lbx.addWidget(self.tbw) # 페이지 생성e self.password_page = Password_Page() self.temperature_page = Temperature_Page() # 기본 탭 생성 self.tbw.addTab(self.password_page, "잠금해제") self.tbw.addTab(self.temperature_page, "온도설정") def center(self): self.move(0, 0) if __name__ == "__main__": app = QApplication(sys.argv) form = Form() form.show() threading = threading.Thread(target=goodsenser) threading.daemon = True threading.start() gpio.OUTPUT(Magantic, True) gpio.OUTPUT(RelayIN1, True) gpio.OUTPUT(RelayIN2, True) exit(app.exec_())
import RPi.GPIO as GPIO R_PIN = 36 G_PIN = 38 B_PIN = 40 GPIO.setmode(GPIO.BOARD) GPIO.setup(R_PIN, GPIO.OUT) GPIO.setup(G_PIN, GPIO.OUT) GPIO.setup(B_PIN, GPIO.OUT) GPIO.OUTPUT(R_PIN, GPIO.HIGH) GPIO.OUTPUT(G_PIN, GPIO.HIGH) GPIO.OUTPUT(B_PIN, GPIO.HIGH)