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 ProxSensor = 2;
 | 
			
		||||
const int relayPin = 12;
 | 
			
		||||
const int buzzerPin = 3;
 | 
			
		||||
int inputVal = 0;
 | 
			
		||||
long duration;
 | 
			
		||||
int distance;
 | 
			
		||||
char piInput = 'N';
 | 
			
		||||
 | 
			
		||||
void setup() {
 | 
			
		||||
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
 | 
			
		||||
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
 | 
			
		||||
  pinMode(trigPin, OUTPUT);
 | 
			
		||||
  pinMode(echoPin, INPUT); 
 | 
			
		||||
  pinMode(LED_BUILTIN, OUTPUT);
 | 
			
		||||
  pinMode(relayPin, OUTPUT);
 | 
			
		||||
  pinMode(buzzerPin, OUTPUT);
 | 
			
		||||
  pinMode(ProxSensor,INPUT);
 | 
			
		||||
  digitalWrite(buzzerPin, LOW);
 | 
			
		||||
  digitalWrite(relayPin, LOW);
 | 
			
		||||
  Serial.begin(9600); // Starts the serial communication
 | 
			
		||||
  pinMode(ProxSensor,INPUT);    //Pin 2 is connected to the output of proximity sensor
 | 
			
		||||
  Serial.begin(9600); 
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void loop() {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  boolean IROK = false;
 | 
			
		||||
  boolean UltraOK = false;
 | 
			
		||||
  // Clears the trigPin
 | 
			
		||||
@ -45,6 +49,7 @@ void loop() {
 | 
			
		||||
  if (IROK && UltraOK && Serial.available() > 0 ){
 | 
			
		||||
    if (Serial.read() == 'O') {
 | 
			
		||||
      digitalWrite(relayPin, HIGH);
 | 
			
		||||
      playBuzzer(2,false);
 | 
			
		||||
      delay(5000);
 | 
			
		||||
      digitalWrite(relayPin, LOW);
 | 
			
		||||
      IROK = false;
 | 
			
		||||
@ -66,6 +71,25 @@ void serialFlush(){
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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')
 | 
			
		||||
			#break
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def recognize(image):
 | 
			
		||||
	names = loadNames()
 | 
			
		||||
	face_recognizer = cv2.createLBPHFaceRecognizer()
 | 
			
		||||
	face_recognizer.load('faces/m')
 | 
			
		||||
	img = image.copy()
 | 
			
		||||
	label= face_recognizer.predict(img)
 | 
			
		||||
	print(label)
 | 
			
		||||
	if label[1] > 120:
 | 
			
		||||
		return 'unknown'
 | 
			
		||||
	else:
 | 
			
		||||
@ -97,7 +97,7 @@ def recognize(image):
 | 
			
		||||
		
 | 
			
		||||
def OpenShifter():
 | 
			
		||||
	try:
 | 
			
		||||
		ser = serial.Serial('/dev/ttyUSB1',9600)
 | 
			
		||||
		ser = serial.Serial('/dev/ttyUSB0',9600)
 | 
			
		||||
		#ser.open()
 | 
			
		||||
		ser.write('O')
 | 
			
		||||
		ser.close()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user