Components and supplies
Arduino UNO
Bluetooth Module
Laser Module
Buzzer
Apps and platforms
Windows 10
Arduino IDE
MIT App Inventor
Tesseract OCR
OpenCV
PtQt
Project description
Code
Transmitter
c_cpp
Transfer received words into morse code and represent it in laser and buzzer.
1// This Code written by Ahmed Harbi on August.2018 2 3// Defined Laser & Buzzer 4#define Laser 13 5#define Buzzer 9 6 7// Enter Morse Code Library 8char* MorseCode[] = { 9 ".-", // A 10 "-...", // B 11 "-.-.", // C 12 "-..", // D 13 ".", // E 14 "..-.", // F 15 "--.", // G 16 "....", // H 17 "..", // I 18 ".---", // J 19 "-.-", // K 20 ".-..", // L 21 "--", // M 22 "-.", // N 23 "---", // O 24 ".--.", // P 25 "--.-", // Q 26 ".-.", // R 27 "...", // S 28 "-", // T 29 "..-", // U 30 "...-", // V 31 ".--", // W 32 "-..-", // X 33 "-.--", // Y 34 "--.." // Z 35}; 36 37//Enter Numbers Library 38char* Numbers[] = { 39 "-----", // 0 40 ".----", // 1 41 "..---", // 2 42 "...--", // 3 43 "....-", // 4 44 ".....", // 5 45 "-....", // 6 46 "--...", // 7 47 "---..", // 8 48 "----." // 9 49}; 50 51//Define I/Os 52void setup() { 53 pinMode(Laser, OUTPUT); 54 pinMode(Buzzer, OUTPUT); 55 Serial.begin(9600); 56} 57 58 59 60void loop() { 61 62 // Reset the readed data every loop 63 char letter; 64 65 66 // Check if bluetooth is connected 67 if (Serial.available() > 0) { 68 69 // Read data from bluetooth 70 letter = Serial.read(); 71 72 73 // Lower case letters 74 if (letter >= 'a' && letter <= 'z') { 75 // Call the letter element then apply morse code decoder 76 decoder(MorseCode[letter - 'a']); 77 } 78 79 // Capital case letters 80 else if (letter >= 'A' && letter <= 'Z') { 81 // Call the letter element then apply morse code decoder 82 decoder(MorseCode[letter - 'A']); 83 } 84 85 // Numbers 86 else if (letter >= '0' && letter <= '9') { 87 // Call Number's Element then apply morse code decoder 88 decoder(Numbers[letter - '0']); 89 } 90 91 // Space Case 92 else if (letter == ' ') { 93 delay(600); 94 } 95 96 // Print output back 97 if (letter == '\\0') { 98 Serial.println(""); 99 } else { 100 Serial.print(letter); 101 } 102 } 103} 104 105// Set the decoder [flash for each letter in received string] 106void decoder (char* x) { 107 108 // Counter 109 int i = 0; 110 111 //Decoder 112 while (x[i] != '\\0') { 113 flashType(x[i]); 114 i++; 115 } 116 117 // Delay between every letter 118 delay(250); 119} 120 121 122 123// Dash or Dot 124void flashType (char data) { 125 126 // Turn laser & Buzzer on 127 digitalWrite(Laser, HIGH); 128 tone(Buzzer, 1000); 129 130 // DOT 131 if (data == '.') { 132 delay(200); 133 } 134 135 //Dash 136 if (data == '-') { 137 delay(600); 138 } 139 140 // Turn laser & Buzzer off 141 digitalWrite(Laser, LOW); 142 noTone(Buzzer); 143 144 //Delay before the following dash/dot 145 delay(200); 146} 147 148/*Problems: 149 *1.cann't control laser or buzzer itself 150 */ 151
Text Detection
python
To recognize text from Image or Video and send it to arduino via bluetooth.
1# this code was written by Ahmed Harbi & Omar Ghonim on FEB.2018 2 3import cv2 4import pytesseract 5import os 6from PIL import Image 7import serial 8 9#Define Bluetooth 10port = "COM8" 11bluetooth = serial.Serial(port, 9600) 12bluetooth.flushInput() 13 14#Stored Words 15stored = ["SOS", "DANGER", "HELP"] 16 17#open the webcam and capture a video 18cap = cv2.VideoCapture(0) 19 20while (True): 21 22 #read each frame in the loop as image 23 image = cap.read()[1] 24 25 #noise filtration 26 #Change color space into Gray 27 gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 28 #Apply thrsholding 29 #Otsu to reduce the graylevel & Binary to change in B\\W image 30 threshold = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] #save data into numerical tuple 31 #Use median filter and remove noise 32 blur = cv2.medianBlur(threshold, 3) 33 34 #save filtered photo 35 filtered = 'filtered.png' 36 cv2.imwrite(filtered, blur) 37 38 #export text from saved photo 39 text = pytesseract.image_to_string(Image.open(filtered)) 40 41 #Delete saved picture 42 os.remove(filtered) 43 44 #Skip unwanted readed data 45 if text.upper() in stored: 46 bluetooth.write(str.encode(str(text))) 47 print (text) 48 break 49 #show captured 50 cv2.imshow('Morse Code', blur) 51 52 #Press ESC to end the program 53 k = cv2.waitKey(1) & 0xff 54 if k == 27: 55 break 56 57cv2.destroyAllWindows() 58cap.release() 59
Desktop Application
python
Enter text which you want to transfer into morse code then send it to arduino via bluetooth
1#this Code was written by Ahmed Harbi on June.2018 2 3import sys 4from 5 PyQt4.QtCore import pyqtSlot 6from PyQt4.QtGui import * 7import serial 8import 9 time 10 11#define Bluetooth Device 12port = "COM8" 13bluetooth = serial.Serial(port, 14 9600) 15bluetooth.flushInput() 16 17 18# create window 19app = QApplication(sys.argv) 20w 21 = QWidget() 22w.setWindowTitle('Morse Code') 23 24#Laser on Button 25laserOn 26 = QPushButton('Laser on', w) 27laserOn.move(20,10) 28 29#Buzzer on Button 30buzzerOn 31 = QPushButton('Buzzer on', w) 32buzzerOn.move(20,40) 33 34#Laser off Button 35laserOff 36 = QPushButton('Laser off', w) 37laserOff.move(225,10) 38 39#Buzzer off Button 40buzzerOff 41 = QPushButton('Buzzer off', w) 42buzzerOff.move(225,40) 43 44# Create textbox 45textbox 46 = QLineEdit(w) 47textbox.move(20, 70) 48textbox.resize(280,40) 49 50# Set window 51 size. 52w.resize(320, 200) 53 54# send button 55send = QPushButton('Send', 56 w) 57send.move(20,120) 58 59# Create the actions 60@pyqtSlot() 61 62#send 63 Button 64def on_click_send(self): 65 textboxValue = textbox.text() 66 bluetooth.write(str.encode(str(textboxValue))) 67 68 print("Sent") 69 70 71#Laser On Button 72def on_click_laserOn(self): 73 74 bluetooth.write(str.encode(str('100'))) 75 76#Buzzer On Button 77def on_click_buzzerOn(self): 78 79 bluetooth.write(str.encode(str('50'))) 80 81#Laser Off Button 82def on_click_laserOff(self): 83 84 bluetooth.write(str.encode(str('0'))) 85 86#Buzzer Off Button 87def on_click_buzzerOff(self): 88 89 bluetooth.write(str.encode(str('25'))) 90 91# connect the signals to the 92 slots 93send.clicked.connect(on_click_send) 94laserOn.clicked.connect(on_click_laserOn) 95buzzerOn.clicked.connect(on_click_buzzerOn) 96laserOff.clicked.connect(on_click_laserOff) 97buzzerOff.clicked.connect(on_click_buzzerOff) 98 99 100 101# Show the window and run the app 102w.show() 103app.exec_()
Applications
Android Application Desktop Application Image Processing Code
Desktop Application
python
Enter text which you want to transfer into morse code then send it to arduino via bluetooth
1#this Code was written by Ahmed Harbi on June.2018 2 3import sys 4from PyQt4.QtCore import pyqtSlot 5from PyQt4.QtGui import * 6import serial 7import time 8 9#define Bluetooth Device 10port = "COM8" 11bluetooth = serial.Serial(port, 9600) 12bluetooth.flushInput() 13 14 15# create window 16app = QApplication(sys.argv) 17w = QWidget() 18w.setWindowTitle('Morse Code') 19 20#Laser on Button 21laserOn = QPushButton('Laser on', w) 22laserOn.move(20,10) 23 24#Buzzer on Button 25buzzerOn = QPushButton('Buzzer on', w) 26buzzerOn.move(20,40) 27 28#Laser off Button 29laserOff = QPushButton('Laser off', w) 30laserOff.move(225,10) 31 32#Buzzer off Button 33buzzerOff = QPushButton('Buzzer off', w) 34buzzerOff.move(225,40) 35 36# Create textbox 37textbox = QLineEdit(w) 38textbox.move(20, 70) 39textbox.resize(280,40) 40 41# Set window size. 42w.resize(320, 200) 43 44# send button 45send = QPushButton('Send', w) 46send.move(20,120) 47 48# Create the actions 49@pyqtSlot() 50 51#send Button 52def on_click_send(self): 53 textboxValue = textbox.text() 54 bluetooth.write(str.encode(str(textboxValue))) 55 print("Sent") 56 57 58#Laser On Button 59def on_click_laserOn(self): 60 bluetooth.write(str.encode(str('100'))) 61 62#Buzzer On Button 63def on_click_buzzerOn(self): 64 bluetooth.write(str.encode(str('50'))) 65 66#Laser Off Button 67def on_click_laserOff(self): 68 bluetooth.write(str.encode(str('0'))) 69 70#Buzzer Off Button 71def on_click_buzzerOff(self): 72 bluetooth.write(str.encode(str('25'))) 73 74# connect the signals to the slots 75send.clicked.connect(on_click_send) 76laserOn.clicked.connect(on_click_laserOn) 77buzzerOn.clicked.connect(on_click_buzzerOn) 78laserOff.clicked.connect(on_click_laserOff) 79buzzerOff.clicked.connect(on_click_buzzerOff) 80 81 82# Show the window and run the app 83w.show() 84app.exec_()
Transmitter
c_cpp
Transfer received words into morse code and represent it in laser and buzzer.
1// This Code written by Ahmed Harbi on August.2018 2 3// Defined Laser & Buzzer 4#define Laser 13 5#define Buzzer 9 6 7// Enter Morse Code Library 8char* MorseCode[] = { 9 ".-", // A 10 "-...", // B 11 "-.-.", // C 12 "-..", // D 13 ".", // E 14 "..-.", // F 15 "--.", // G 16 "....", // H 17 "..", // I 18 ".---", // J 19 "-.-", // K 20 ".-..", // L 21 "--", // M 22 "-.", // N 23 "---", // O 24 ".--.", // P 25 "--.-", // Q 26 ".-.", // R 27 "...", // S 28 "-", // T 29 "..-", // U 30 "...-", // V 31 ".--", // W 32 "-..-", // X 33 "-.--", // Y 34 "--.." // Z 35}; 36 37//Enter Numbers Library 38char* Numbers[] = { 39 "-----", // 0 40 ".----", // 1 41 "..---", // 2 42 "...--", // 3 43 "....-", // 4 44 ".....", // 5 45 "-....", // 6 46 "--...", // 7 47 "---..", // 8 48 "----." // 9 49}; 50 51//Define I/Os 52void setup() { 53 pinMode(Laser, OUTPUT); 54 pinMode(Buzzer, OUTPUT); 55 Serial.begin(9600); 56} 57 58 59 60void loop() { 61 62 // Reset the readed data every loop 63 char letter; 64 65 66 // Check if bluetooth is connected 67 if (Serial.available() > 0) { 68 69 // Read data from bluetooth 70 letter = Serial.read(); 71 72 73 // Lower case letters 74 if (letter >= 'a' && letter <= 'z') { 75 // Call the letter element then apply morse code decoder 76 decoder(MorseCode[letter - 'a']); 77 } 78 79 // Capital case letters 80 else if (letter >= 'A' && letter <= 'Z') { 81 // Call the letter element then apply morse code decoder 82 decoder(MorseCode[letter - 'A']); 83 } 84 85 // Numbers 86 else if (letter >= '0' && letter <= '9') { 87 // Call Number's Element then apply morse code decoder 88 decoder(Numbers[letter - '0']); 89 } 90 91 // Space Case 92 else if (letter == ' ') { 93 delay(600); 94 } 95 96 // Print output back 97 if (letter == '\\0') { 98 Serial.println(""); 99 } else { 100 Serial.print(letter); 101 } 102 } 103} 104 105// Set the decoder [flash for each letter in received string] 106void decoder (char* x) { 107 108 // Counter 109 int i = 0; 110 111 //Decoder 112 while (x[i] != '\\0') { 113 flashType(x[i]); 114 i++; 115 } 116 117 // Delay between every letter 118 delay(250); 119} 120 121 122 123// Dash or Dot 124void flashType (char data) { 125 126 // Turn laser & Buzzer on 127 digitalWrite(Laser, HIGH); 128 tone(Buzzer, 1000); 129 130 // DOT 131 if (data == '.') { 132 delay(200); 133 } 134 135 //Dash 136 if (data == '-') { 137 delay(600); 138 } 139 140 // Turn laser & Buzzer off 141 digitalWrite(Laser, LOW); 142 noTone(Buzzer); 143 144 //Delay before the following dash/dot 145 delay(200); 146} 147 148/*Problems: 149 *1.cann't control laser or buzzer itself 150 */ 151
Text Detection
python
To recognize text from Image or Video and send it to arduino via bluetooth.
1# this code was written by Ahmed Harbi & Omar Ghonim on FEB.2018 2 3import cv2 4import pytesseract 5import os 6from PIL import Image 7import serial 8 9#Define Bluetooth 10port = "COM8" 11bluetooth = serial.Serial(port, 9600) 12bluetooth.flushInput() 13 14#Stored Words 15stored = ["SOS", "DANGER", "HELP"] 16 17#open the webcam and capture a video 18cap = cv2.VideoCapture(0) 19 20while (True): 21 22 #read each frame in the loop as image 23 image = cap.read()[1] 24 25 #noise filtration 26 #Change color space into Gray 27 gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 28 #Apply thrsholding 29 #Otsu to reduce the graylevel & Binary to change in B\\W image 30 threshold = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] #save data into numerical tuple 31 #Use median filter and remove noise 32 blur = cv2.medianBlur(threshold, 3) 33 34 #save filtered photo 35 filtered = 'filtered.png' 36 cv2.imwrite(filtered, blur) 37 38 #export text from saved photo 39 text = pytesseract.image_to_string(Image.open(filtered)) 40 41 #Delete saved picture 42 os.remove(filtered) 43 44 #Skip unwanted readed data 45 if text.upper() in stored: 46 bluetooth.write(str.encode(str(text))) 47 print (text) 48 break 49 #show captured 50 cv2.imshow('Morse Code', blur) 51 52 #Press ESC to end the program 53 k = cv2.waitKey(1) & 0xff 54 if k == 27: 55 break 56 57cv2.destroyAllWindows() 58cap.release() 59
Downloadable files
Bluetooth Module
Bluetooth Module
Laser Module
Laser Module
Laser Module
Laser Module
Bluetooth Module
Bluetooth Module
Buzzer
Buzzer
Buzzer
Buzzer
Comments
Only logged in users can leave comments