ard not working
This commit is contained in:
		
							parent
							
								
									6ac1b416c0
								
							
						
					
					
						commit
						6e8adb3bb1
					
				@ -3,24 +3,28 @@ const int trigPin = 9;
 | 
				
			|||||||
const int echoPin = 10;
 | 
					const int echoPin = 10;
 | 
				
			||||||
const int ProxSensor = 2;
 | 
					const int ProxSensor = 2;
 | 
				
			||||||
const int relayPin = 12;
 | 
					const int relayPin = 12;
 | 
				
			||||||
 | 
					const int buzzerPin = 3;
 | 
				
			||||||
int inputVal = 0;
 | 
					int inputVal = 0;
 | 
				
			||||||
long duration;
 | 
					long duration;
 | 
				
			||||||
int distance;
 | 
					int distance;
 | 
				
			||||||
char piInput = 'N';
 | 
					char piInput = 'N';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void setup() {
 | 
					void setup() {
 | 
				
			||||||
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
 | 
					  pinMode(trigPin, OUTPUT);
 | 
				
			||||||
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
 | 
					  pinMode(echoPin, INPUT); 
 | 
				
			||||||
  pinMode(LED_BUILTIN, OUTPUT);
 | 
					  pinMode(LED_BUILTIN, OUTPUT);
 | 
				
			||||||
  pinMode(relayPin, OUTPUT);
 | 
					  pinMode(relayPin, OUTPUT);
 | 
				
			||||||
 | 
					  pinMode(buzzerPin, OUTPUT);
 | 
				
			||||||
 | 
					  pinMode(ProxSensor,INPUT);
 | 
				
			||||||
 | 
					  digitalWrite(buzzerPin, LOW);
 | 
				
			||||||
  digitalWrite(relayPin, LOW);
 | 
					  digitalWrite(relayPin, LOW);
 | 
				
			||||||
  Serial.begin(9600); // Starts the serial communication
 | 
					  Serial.begin(9600); 
 | 
				
			||||||
  pinMode(ProxSensor,INPUT);    //Pin 2 is connected to the output of proximity sensor
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  boolean IROK = false;
 | 
					  boolean IROK = false;
 | 
				
			||||||
  boolean UltraOK = false;
 | 
					  boolean UltraOK = false;
 | 
				
			||||||
  // Clears the trigPin
 | 
					  // Clears the trigPin
 | 
				
			||||||
@ -45,6 +49,7 @@ void loop() {
 | 
				
			|||||||
  if (IROK && UltraOK && Serial.available() > 0 ){
 | 
					  if (IROK && UltraOK && Serial.available() > 0 ){
 | 
				
			||||||
    if (Serial.read() == 'O') {
 | 
					    if (Serial.read() == 'O') {
 | 
				
			||||||
      digitalWrite(relayPin, HIGH);
 | 
					      digitalWrite(relayPin, HIGH);
 | 
				
			||||||
 | 
					      playBuzzer(2,false);
 | 
				
			||||||
      delay(5000);
 | 
					      delay(5000);
 | 
				
			||||||
      digitalWrite(relayPin, LOW);
 | 
					      digitalWrite(relayPin, LOW);
 | 
				
			||||||
      IROK = false;
 | 
					      IROK = false;
 | 
				
			||||||
@ -64,7 +69,26 @@ void serialFlush(){
 | 
				
			|||||||
  while(Serial.available() > 0) {
 | 
					  while(Serial.available() > 0) {
 | 
				
			||||||
    char t = Serial.read();
 | 
					    char t = Serial.read();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}   
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void playBuzzer(int time, boolean ok){
 | 
				
			||||||
 | 
					  if (ok) {
 | 
				
			||||||
 | 
					    tone(buzzerPin, 1000);
 | 
				
			||||||
 | 
					    delay(time/3);
 | 
				
			||||||
 | 
					    noTone(buzzerPin);
 | 
				
			||||||
 | 
					    delay(time/5);
 | 
				
			||||||
 | 
					    tone(buzzerPin,1000);
 | 
				
			||||||
 | 
					    delay(time/3);
 | 
				
			||||||
 | 
					    noTone(buzzerPin);
 | 
				
			||||||
 | 
					  } 
 | 
				
			||||||
 | 
					  else {
 | 
				
			||||||
 | 
					    tone(buzzerPin, 1000);
 | 
				
			||||||
 | 
					    delay(time);
 | 
				
			||||||
 | 
					    noTone(buzzerPin);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								main.py
									
									
									
									
									
								
							@ -83,13 +83,13 @@ def start( camera, face_cascade):
 | 
				
			|||||||
			#print('Closing')
 | 
								#print('Closing')
 | 
				
			||||||
			#break
 | 
								#break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def recognize(image):
 | 
					def recognize(image):
 | 
				
			||||||
	names = loadNames()
 | 
						names = loadNames()
 | 
				
			||||||
	face_recognizer = cv2.createLBPHFaceRecognizer()
 | 
						face_recognizer = cv2.createLBPHFaceRecognizer()
 | 
				
			||||||
	face_recognizer.load('faces/m')
 | 
						face_recognizer.load('faces/m')
 | 
				
			||||||
	img = image.copy()
 | 
						img = image.copy()
 | 
				
			||||||
	label= face_recognizer.predict(img)
 | 
						label= face_recognizer.predict(img)
 | 
				
			||||||
 | 
						print(label)
 | 
				
			||||||
	if label[1] > 120:
 | 
						if label[1] > 120:
 | 
				
			||||||
		return 'unknown'
 | 
							return 'unknown'
 | 
				
			||||||
	else:
 | 
						else:
 | 
				
			||||||
@ -97,7 +97,7 @@ def recognize(image):
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
def OpenShifter():
 | 
					def OpenShifter():
 | 
				
			||||||
	try:
 | 
						try:
 | 
				
			||||||
		ser = serial.Serial('/dev/ttyUSB1',9600)
 | 
							ser = serial.Serial('/dev/ttyUSB0',9600)
 | 
				
			||||||
		#ser.open()
 | 
							#ser.open()
 | 
				
			||||||
		ser.write('O')
 | 
							ser.write('O')
 | 
				
			||||||
		ser.close()
 | 
							ser.close()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user