Luận Văn Thiết kế hộp điều khiển thiết bị bằng sóng hồng ngoại

116 39 0
Luận Văn Thiết kế hộp điều khiển thiết bị bằng sóng hồng ngoại

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TR NG H SPKT TP H CHÍ MINH C NG HÒA XÃ H I CH NGH A VI T NAM KHOA I N- I N T B MÔN I N T CL P-T CÔNG NGHI P ậ Y SINH DO - H NH PHÚC o0o -Tp HCM, ngày 02 tháng 07 n m 2018 NHI M V ÁN T T NGHI P H tên sinh viên: Tr n Quang Toàn MSSV: 14141324 Nguy n Minh V MSSV: 14141374 Chuyên ngành: Công ngh k thu t n - n t truy n thông Mã ngành: 41 H đào t o: i h c quy Mã h : Khóa: 2014 L p: 14141DT3B 14141DT1A I TÊN TÀI: THI T K NGO I H P I U KHI N THI T B B NG SÓNG H NG II NHI M V N i dung th c hi n:  N i dung 1: Tìm hi u v module ESP-12 8266, module led đo n, micro SD card, led thu phát h ng ngo i  N i dung 2: Gi i mã h ng ngo i nh n t u n t xa h ng ngo i  N i dung 3: Xu t tín hi u h ng ngo i u n m t thi t b  N i dung 4: Thi t k l p trình ng d ng Android  N i dung 5: Thi t k thi công m ch u n  N i dung 6: Thi t k mơ hình s n ph m  N i dung 7: ánh giá k t qu th c hi n III NGÀY GIAO NHI M V : 02/04/2018 IV NGÀY HOÀN THÀNH NHI M V : 02/07/2018 V H VÀ TÊN CÁN B H CÁN B H NG D N NG D N: ThS Phan Vân Hoàn BM I N T CÔNG NGHI P – Y SINH ii TR NG H SPKT TP H CHÍ MINH C NG HỊA XÃ H I CH NGH A VI T NAM KHOA I N- I N T B MÔN I N T CL P-T CÔNG NGHI P ậ Y SINH DO - H NH PHÚC o0o -Tp HCM, ngày 02 tháng 07 n m 2018 L CH TRÌNH TH C HI N H L H L tên sinh viên 1: Tr n Quang Toàn p: 14141DT3B tên sinh viên 2: Nguy n Minh V p: 14141DT1A ÁN T T NGHI P MSSV: 14141324 MSSV: 14141374 Tên đ tài: Thi t k h p u n thi t b b ng sóng h ng ngo i Tu n/ngày Tu n (0208/04/2018) Tu n (0915/04/2018) Tu n (1622/04/2018) Tu n (23/4 29 /04/2018) Tu n 5,6 (30/4 13/05/2018) Tu n 7,8,9,10 (14/5 10/06/2018) Tu n 11,12 (11 24/06/2018) Tu n 13 (25/6 1/07/2018) 02/07/2018 N i dung Xác nh n GVHD Nh n đ án , tìm hi u đ tài Ch n tìm hi u đ tài Tìm hi u n i dung h ng làm đ tài c a u n b ng sóng h ng ngo i Tìm hi u cách thu phát m t tín hi u h ng ngo i Ti n hành thi t k ph n c ng cho h th ng u n t xa Ti n hành l p trình ph n m m cho h th ng u n t xa Tìm hi u thi t k mơ hình s n ph m Vi t báo cáo, ki m ph n c ng Hoàn thành nhi m v đ án GV H NG D N (Ký ghi rõ h tên) iii L I CAM OAN tài t th c hi n d is h ng d n c a th y ThS Phan Vân Hoàn d a vào m t s tài li u không chép t tài li u hay cơng trình đư có tr c N u có b t k s gian l n xin ch u trách nhi m v n i dung đ án c a Sinh viên th c hi n đ án Tr n Quang Toàn Nguy n Minh V iv L IC M N  L i đ u tiên em xin chân thành c m n th y cô giáo Tr ng iH cS Ph m K Thu t TP.HCM nói chung, th y cô khoa i n – i n T nói riêng đư d y d cho em ki n th c v môn đ i c có đ ng c ng nh mơn chun ngành, giúp em c c s lý thuy t v ng vàng t o u ki n giúp đ em su t trình h c t p Em c ng xin g i l i tri ân bi t n sâu s c đ n th y ThS Phan Vân Hoàn ng đư t n tình h i ng d n, ch b o em su t q trình làm khố lu n Cu i cùng, em xin chân thành c m n gia đình b n bè, đư ln t o u ki n, quan tâm, giúp đ , đ ng viên em su t trình h c t p hồn thành khố lu n t t nghi p Sinh viên th c hi n đ án Tr n Quang Toàn Nguy n Minh V v vi M CL C Trang bìa Error! Bookmark not defined Nhi m v đ án t t nghi p ii L ch trình th c hi n đ án t t nghi p iii L i cam đoan iv L i c m n v M c l c vi Li t kê hình v ix Li t kê b ng xi Tóm t t xii Ch ng T NG QUAN 1.1 t v n đ : 1.2 M c tiêu đ tài: 1.3 N i dung nghiên c u: 1.4 Gi i h n: 1.5 B c c đ án: Ch ng C S LÝ THUY T 2.1 T ng quan v tia h ng ngo i: 2.1.1 nh ngh a: 2.1.2 Ngu n phát: 2.1.3 Tính ch t: 2.1.4 Phân lo i: 2.1.5 ng d ng: 2.1.6 Tín hi u h ng ngo i u n t xa: 2.2 Gi i thi u ph n c ng: 2.2.1 T ng quan v module ESP8266-12E (NodeMCU V1.0): 2.2.2 Led thu h ng ngo i: 10 2.2.3 Module micro SD Card: 11 2.2.4 Module led đo n: 13 vi 2.3 Gi i thi u v chu n giao th c spi: 13 2.3.1 Khái ni m: 13 2.3.2 Nguyên lý ho t đ ng: 15 2.4 Gi i thi u v giao th c ntp: 16 2.4.1 Khái ni m: 16 2.4.2 c tr ng: 16 2.4.3 Ki n trúc c b n: 16 2.4.4 NTP timestamp: 17 2.5 Gi i thi u vài nét v h u hành android: 18 2.5.1 Khái ni m: 18 2.5.2 c tr ng: 18 2.5.3 Ki n trúc c b n: 19 2.5.4 Môi tr ng phát tri n Android: 20 2.6 Gi i thi u vài nét v firebase: 21 2.6.1 Khái ni m: 21 2.6.2 Ch c tr ng c b n: 21 ng TệNH TOÁN VẨ THI T K 22 3.1 T ng quan v yêu c u thi t k h th ng: 22 3.2 Tính tốn thi t k h th ng: 22 3.2.1 Thi t k s đ h th ng: 22 3.2.2 Tính tốn thi t k : 23 Ch ng THI CÔNG H TH NG 28 4.1 Gi i thi u: 28 4.2 Thi công h th ng: 28 4.2.1 Thi công bo m ch: 28 4.2.2 L p ráp, ki m tra thi cơng mơ hình: 30 4.3 L p trình h th ng: 32 4.3.1 L u đ gi i thu t: 32 4.3.2 Ph n m m l p trình cho vi u n: 36 4.3.3 Ch 4.4 H ng trình Android Studio 40 ng d n s d ng, thao tác v i h th ng: 49 vii Ch ng K T QU , NH N XÉT, ÁNH GIÁ 50 5.1 S n ph m sau hoàn thành: 50 5.1.1 S n ph m: 50 5.1.2 Ki n th c có đ c trình thi t k s n ph m: 50 5.2 K t qu ch y h th ng: 51 5.2.1 Quá trình ch y ng d ng n tho i: 51 5.2.2 Quá trình v n hành ph n c ng h th ng: 53 Ch ng K T LU N VẨ H NG PHÁT TRI N 56 6.1 K t lu n: 56 6.2 H ng phát tri n: 56 TÀI LI U THAM KH O 57 PH L C 58 viii LI T KÊ HÌNH V Hình Trang Hình 2.1 Hình nh remote th c t Hình 2.2 S đ chân c a Node MCU Hình 2.3 Hình nh th c t s đ chân c a ESP8266-12E Hình 2.4 Hình nh th c t s đ chân c a TL 1838 10 Hình 2.5 S đ góc kho ng cách nh n đ c sóng 11 Hình 2.6 Hình nh th c t module micro SD card 12 Hình 2.7 Các kích th c SD card 12 Hình 2.8 Hình nh th c t module led đo n 13 Hình 2.9 K t n i SPI gi a hai thi t b 14 Hình 2.10 K t n i SPI gi a nhi u thi t b 14 Hình 2.11 Các ch đ làm vi c c a SPI 15 Hình 2.12 Truy n d li u theo chu n SPI 16 Hình 2.13 C u trúc t ng quát c a Android 20 Hình 3.1 S đ kh i h th ng 22 Hình 3.2 S đ thi t k kh i thu phát h ng ngo i 24 Hình 3.3 S đ thi t k hi n th th i gian 25 Hình 3.4 S đ thi t k kh i l u d li u 25 Hình 3.5 S đ nguyên lý toàn m ch 27 Hình 4.1 M ch in c a m ch n 28 Hình 4.2 Hình 3D m t s đ b trí linh ki n 29 Hình 4.3 Hình 3D m t d i s đ b trí linh ki n 29 Hình 4.4 M t d i m ch thi công th c t 31 Hình 4.5 L p ráp linh ki n vào m ch 31 Hình 4.6 Hình nh mơ hình 32 Hình 4.7 L u đ ch ng trình vi u n 33 Hình 4.8 L u đ ch ng trình u n Android 34 Hình 4.9 L u đ h n gi Android 35 Hình 4.10 Ph n m m l p trình Arduino IDE 36 Hình 4.11 Cách download ph n m m 37 Hình 4.12 Giao n thêm board ESP Arduino IDE 37 Hình 4.13 T i th vi n cho Esp8266 38 Hình 4.14 Danh m c th vi n hi n có Arduino IDE 38 Hình 4.15 Ch n Board n p 39 Hình 4.16 T i Java 41 B MƠN ĐI N T CƠNG NGHI P ix Hình 4.17 Cài đ t Android Studio 41 Hình 4.18 T o project m i Android Studio 42 Hình 4.19 T o project m i Android 42 Hình 4.20 Ch n phiên b n Android mu n l p trình 43 Hình 4.21 Ch n hình 44 Hình 4.22 t tên cho hình 44 Hình 4.23 Ch n thi t b đ ch ng trình 45 Hình 4.24 Giao di n c a project Android m i 45 Hình 4.25 T o m t Project cho Firebase 46 Hình 4.26 Giao di n h u hành Firebase liên k t 46 Hình 4.27 Liên k t Firebase v i Package name c a app Android 47 Hình 4.28 Thêm t p tin google-services.json vào app Android 48 Hình 4.29 Thêm th vi n liên k t Firebase v i app Android 48 Hình 5.1 S n ph m thi công 50 Hình 5.2 Giao di n app 51 Hình 5.3 Giao di n u n 52 Hình 5.4 Giao di n h n th i gian 52 Hình 5.5 Giao di n Firebase 53 Hình 5.6 H c tín hi u t u n 53 Hình 5.7 i u n thi t b 54 Hình 5.8 D li u t ng nút th nh 55 Hình 5.9 D li u c a tín hi u c a m t nút th nh 55 B MÔN ĐI N T CÔNG NGHI P x on2.setValue("0"); } return false; } }); bt3.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { on3.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { on3.setValue("0"); } return false; } }); bt4.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { on4.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { on4.setValue("0"); } return false; } }); bt5.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { up.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 90 up.setValue("0"); } return false; } }); bt6.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { dw.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { dw.setValue("0"); } return false; } }); bt7.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { next.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { next.setValue("0"); } return false; } }); bt8.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { back.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 91 back.setValue("0"); } return false; } }); bt9.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { menu.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { menu.setValue("0"); } return false; } }); bt10.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { mute.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { mute.setValue("0"); } return false; } }); bt11.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { exit.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 92 exit.setValue("0"); } return false; } }); bt12.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { mode.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { mode.setValue("0"); } return false; } }); bt13.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b0.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b0.setValue("0"); } return false; } }); bt14.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b1.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 93 b1.setValue("0"); } return false; } }); bt15.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b2.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b2.setValue("0"); } return false; } }); bt16.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b3.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b3.setValue("0"); } return false; } }); bt17.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b4.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 94 b4.setValue("0"); } return false; } }); bt18.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b5.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b5.setValue("0"); } return false; } }); bt19.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b6.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b6.setValue("0"); } return false; } }); bt20.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b7.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 95 b7.setValue("0"); } return false; } }); bt21.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b8.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b8.setValue("0"); } return false; } }); bt22.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { b9.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { b9.setValue("0"); } return false; } }); bt23.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { bsao.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { B MÔN ĐI N T CÔNG NGHI P 96 bsao.setValue("0"); } return false; } }); bt24.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction()= = MotionEvent.ACTION_DOWN) { bthang.setValue("1"); } else if(event.getAction()= = MotionEvent.ACTION_UP) { bthang.setValue("0"); } return false; } }); sw2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean b) { if(b) { set.setValue("1"); Toast.makeText(dieukhien.this," ang h c l nh",Toast.LENGTH_LONG).show(); } else { set.setValue("0"); } } }); bthengio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { B MÔN ĐI N T CÔNG NGHI P 97 Intent manhinh= new Intent(dieukhien.this,hengio.class); dieukhien.this.startActivity(manhinh); } }); } public void anhxa() { bthengio= (Button) findViewById(R.id.Buttontimers) ; sw2= (Switch) findViewById(R.id.switchs); bt1= (Button) findViewById(R.id.buttonon1); bt2= (Button) findViewById(R.id.buttonon2); bt3= (Button) findViewById(R.id.buttonon3); bt4= (Button) findViewById(R.id.buttonon4); bt5= (Button) findViewById(R.id.buttonup); bt6= (Button) findViewById(R.id.buttondw); bt7= (Button) findViewById(R.id.buttonnext); bt8= (Button) findViewById(R.id.buttonback); bt9= (Button) findViewById(R.id.buttonmenu); bt10= (Button) findViewById(R.id.buttonmute); bt11= (Button) findViewById(R.id.buttonexit); bt12= (Button) findViewById(R.id.buttonmode); bt13= (Button) findViewById(R.id.buttonp0); bt14= (Button) findViewById(R.id.buttonp1); bt15= (Button) findViewById(R.id.buttonp2); bt16= (Button) findViewById(R.id.buttonp3); bt17= (Button) findViewById(R.id.buttonp4); bt18= (Button) findViewById(R.id.buttonp5); bt19= (Button) findViewById(R.id.buttonp6); bt20= (Button) findViewById(R.id.buttonp7); bt21= (Button) findViewById(R.id.buttonp8); bt22= (Button) findViewById(R.id.buttonp9); bt23= (Button) findViewById(R.id.buttonpsao); bt24= (Button) findViewById(R.id.buttonpthang); } } B MÔN ĐI N T CÔNG NGHI P 98 //activity_hengio.xml/////////////////////////////////////////////////////////// < ?xml version= "1.0" encoding= "utf-8"?> < RelativeLayout android:layout_height= "match_parent" android:layout_width= "match_parent" android:background= "@drawable/nen" xmlns:android= "http://schemas.android.com/apk/res/android"> < TextView android:id= "@+ id/textView" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_alignParentStart= "true" android:layout_alignParentTop= "true" android:layout_marginStart= "43dp" android:layout_marginTop= "64dp" android:text= "Hour" android:textColor= "@color/red" android:textSize= "30dp" android:textStyle= "bold" /> < EditText android:id= "@+ id/editTexthour" android:layout_width= "200dp" android:layout_height= "wrap_content" android:layout_alignBottom= "@+ id/textView" android:layout_marginStart= "12dp" android:layout_toEndOf= "@+ id/textView3" android:ems= "10" android:hint= "Write here " android:inputType= "number" android:textColor= "#0e0e0e" android:textSize= "20dp" android:textStyle= "bold" /> < TextView android:id= "@+ id/textView2" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_alignStart= "@+ id/textView" android:layout_below= "@+ id/textView" B MÔN ĐI N T CÔNG NGHI P 99 android:layout_marginTop= "47dp" android:text= "Minute" android:textColor= "@color/red" android:textSize= "30dp" android:textStyle= "bold" /> < EditText android:id= "@+ id/editTextminute" android:layout_width= "200dp" android:layout_height= "wrap_content" android:layout_alignBottom= "@+ id/textView2" android:layout_alignStart= "@+ id/editTexthour" android:ems= "10" android:hint= "Write here" android:inputType= "number" android:textColor= "#151414" android:textSize= "20dp" android:textStyle= "bold" /> < TextView android:id= "@+ id/textView3" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_alignStart= "@+ id/textView2" android:layout_below= "@+ id/textView2" android:layout_marginTop= "47dp" android:textSize= "30dp" android:textColor= "@color/blue" android:textStyle= "bold" android:text= "Button 1" /> < EditText android:id= "@+ id/editTextlenh1" android:layout_width= "200dp" android:layout_height= "wrap_content" android:layout_alignBottom= "@+ id/textView3" android:layout_alignStart= "@+ id/editTextminute" android:ems= "10" android:hint= "Write here " android:inputType= "textPersonName" android:textColor= "#0e0e0e" android:textSize= "20dp" android:textStyle= "bold" /> < TextView B MÔN ĐI N T CÔNG NGHI P 100 android:id= "@+ id/textView4" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_alignStart= "@+ id/textView3" android:layout_below= "@+ id/textView3" android:layout_marginTop= "44dp" android:text= "Button 2" android:textColor= "#2e0dea" android:textSize= "30dp" android:textStyle= "bold" /> < EditText android:id= "@+ id/editTextlenh2" android:layout_width= "200dp" android:layout_height= "wrap_content" android:layout_alignBottom= "@+ id/textView4" android:layout_alignStart= "@+ id/editTextlenh1" android:ems= "10" android:hint= "Write here " android:inputType= "textPersonName" android:textColor= "#0e0e0e" android:textSize= "20dp" android:textStyle= "bold" /> < Button android:id= "@+ id/buttonEnter" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:layout_below= "@+ id/textView4" android:layout_marginTop= "82dp" android:layout_toEndOf= "@+ id/textView4" android:text= "ENTER" /> < /RelativeLayout> //hengio.java//////////////////////////////////////////////////// package com.example.admin.myapp; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; B MÔN ĐI N T CÔNG NGHI P 101 import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; public class hengio extends AppCompatActivity { EditText edtgio,edtphut,edtbt1,edtbt2; Button btnEnter; FirebaseDatabase csdl2; DatabaseReference gio,phut,lenh1,lenh2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hengio); csdl2 = FirebaseDatabase.getInstance(); edtbt1= (EditText) findViewById(R.id.editTextlenh1); edtbt2= (EditText) findViewById(R.id.editTextlenh2); edtgio= (EditText) findViewById(R.id.editTexthour); edtphut= (EditText) findViewById(R.id.editTextminute); btnEnter= (Button) findViewById(R.id.buttonEnter); gio = csdl2.getReference("gio"); phut = csdl2.getReference("phut"); lenh1 = csdl2.getReference("nutnhan1"); lenh2 = csdl2.getReference("nutnhan2"); btnEnter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String hg= edtgio.getText().toString().trim(); String hp= edtphut.getText().toString().trim(); String b1= edtbt1.getText().toString().trim(); String b2= edtbt2.getText().toString().trim(); //Toast.makeText(hengio.this,"Please,set hour",Toast.LENGTH_SHORT).show(); if(hg.length()= = 0) { Toast.makeText(hengio.this,"Please,set hour",Toast.LENGTH_SHORT).show(); edtgio.requestFocus(); } else if(hp.length()= = 0) B MÔN ĐI N T CÔNG NGHI P 102 { Toast.makeText(hengio.this,"Please,set minute",Toast.LENGTH_SHORT).show(); edtphut.requestFocus(); } else if(b1.length()= = && b2.length()= = 0) { Toast.makeText(hengio.this,"Please,set button",Toast.LENGTH_SHORT).show(); edtbt1.requestFocus(); } else if(b1.length()!= && b2.length()= = 0) { int gg= Integer.parseInt(hg); int pp= Integer.parseInt(hp); if (gg> = 24) { Toast.makeText(hengio.this,"Please,Hour value < 24 ",Toast.LENGTH_SHORT).show(); edtgio.setText(""); edtgio.requestFocus(); } else if (pp> = 60) { edtphut.setText(""); Toast.makeText(hengio.this,"Please, Minute value < 60",Toast.LENGTH_SHORT).show(); edtphut.requestFocus(); } else { gio.setValue(hg); phut.setValue(hp); lenh1.setValue(b1); lenh2.setValue(" "); Toast.makeText(hengio.this, "Complete for command", Toast.LENGTH_SHORT).show(); } } else if(b1.length()= = && b2.length()!= 0) { gio.setValue(hg); phut.setValue(hp); B MÔN ĐI N T CÔNG NGHI P 103 lenh1.setValue(" "); lenh2.setValue(b2); Toast.makeText(hengio.this,"Complete for command",Toast.LENGTH_SHORT).show(); } else { gio.setValue(hg); phut.setValue(hp); lenh1.setValue(b1); lenh2.setValue(b2); Toast.makeText(hengio.this,"Complete for command",Toast.LENGTH_SHORT).show(); } } }); } } B MÔN ĐI N T CÔNG NGHI P 104 ... mà m t ta khơng nhìn th y đ b c x vùng kh ki n) có b sóng c a ánh sáng đ nh h n b c (còn g i c sóng t 700 nm đ n mm (l n h n b c c sóng c a sóng vơ n c c ng n) 2.1.2 Ngu n phát: M i v t có nhi... thông th ng 2.1.4 Phân lo i: Tia h ng ngo i đ c phân chia theo b c sóng thành ba vùng chính:  H ng ngo i g n: có kí hi u NIR, có b c sóng t 0,78 µm đ n µm  H ng ngo i trung: có kí hi u MIR, có b... có kí hi u MIR, có b  H ng ngo i xa: có kí hi u FIR, có b B MƠN ĐI N T CƠNG NGHI P c sóng t µm đ n 50 µm c sóng t 50 µm đ n 1000 µm CH NG C 2.1.5 ng d ng: S LÝ THUY T  Dùng đ s y, s i  Dùng

Ngày đăng: 16/11/2019, 15:06

Tài liệu cùng người dùng

Tài liệu liên quan