job

Dependencies:   mbed APDS_9960 Servo TM1636 RTC-DS1307 RC522

Files at this revision

API Documentation at this revision

Comitter:
poom10490
Date:
Tue Dec 18 11:53:37 2018 +0000
Commit message:
job;

Changed in this revision

APDS_9960.lib Show annotated file Show diff for this revision Revisions of this file
RC522.lib Show annotated file Show diff for this revision Revisions of this file
RTC-DS1307.lib Show annotated file Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
TM1636.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 3854371f105a APDS_9960.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/APDS_9960.lib	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tgw/code/APDS_9960/#b9d6e6788a37
diff -r 000000000000 -r 3854371f105a RC522.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RC522.lib	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/duchonic/code/RC522/#332c9a37111d
diff -r 000000000000 -r 3854371f105a RTC-DS1307.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC-DS1307.lib	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/jobtanadol/code/RTC-DS1307/#cac498d0a71d
diff -r 000000000000 -r 3854371f105a Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/matsu/code/Servo/#80a784fc179c
diff -r 000000000000 -r 3854371f105a TM1636.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TM1636.lib	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/rogerzuber/code/TM1636/#e4450fb0849a
diff -r 000000000000 -r 3854371f105a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,150 @@
+#include "mbed.h"
+#include "Rtc_Ds1307.h"
+#include "TM1636.h" //ClockShield
+#include "glibr.h" // Color
+#include "Servo.h" // Motor
+#include "MFRC522.h" // RFID
+#include <string>
+#include <iostream>
+//Serial/////////////////////////////// 
+Serial esp(D8,D2);
+//Serial pc(USBTX,USBRX);
+//////////////////////////////////////
+//Sensor//////////////////////////////
+AnalogIn DistanceI(A0);
+AnalogIn DistanceII(A1);
+DigitalIn Proximity(D2);
+glibr Color(D14,D15);//SDA, SCL
+MFRC522 RfChip(D11, D12, D13, D10, D9);//MOSI, MISO, SCK, SDA, RST 
+/////////////////////////////////////
+//ClockShield////////////////////////
+Rtc_Ds1307 rtc(D3, D6);
+DigitalIn  button_K3(A5);
+TM1636 tm1636(D7,D8);  
+Serial pc(USBTX, USBRX, "pc");
+
+uint16_t color, red, green, blue, ambient;
+string tagRFID;
+int goodProduct, badProduct, allProduct;
+float Quality;
+//int allProduct, goodProduct, badProduct;
+float Performance, Ability;
+int8_t temp[4];
+int main(){
+    //int8_t temp[4];
+    button_K3.mode(PullUp);
+    tm1636.init();
+    Rtc_Ds1307::Time_rtc tm = {};
+    tm.date = 1 ;
+    tm.mon = 1 ;
+    tm.year = 12 ;
+    tm.hour = 0;
+    tm.min = 0;
+    tm.sec = 0;
+    rtc.setTime(tm, false, false);
+    rtc.startClock();
+    string DataCode;
+    esp.baud(115200);
+    pc.baud(115200);
+    RfChip.PCD_Init();
+    Color.setMode(0,1);
+    Color.enableLightSensor(true);
+    Color.enablePower();
+    //rtc.startClock();
+    while(1){
+        rtc.getTime(tm);
+            pc.printf("%02d:%02d:%02d\n",tm.hour,tm.min,tm.sec);
+            temp[0] = tm.min / 10;
+            temp[1] = tm.min % 10;
+            temp[2] = tm.sec / 10;
+            temp[3] = tm.sec % 10;                 
+            tm1636.display(temp);  
+        if(RfChip.PICC_IsNewCardPresent()){ 
+            pc.printf("Card Read\n");
+            RfChip.PICC_ReadCardSerial();
+            pc.printf("%02d:%02d:%02d\n",tm.hour,tm.min,tm.sec);
+
+            string str = "";
+            pc.printf("\nTAG SERIAL : %X02", RfChip.uid.uidByte[0]); pc.printf(" %X02",RfChip.uid.uidByte[1]); pc.printf(" %X02",RfChip.uid.uidByte[2]); pc.printf(" %X02\n",RfChip.uid.uidByte[3]);
+            uint16_t newstr = (RfChip.uid.uidByte[0] += RfChip.uid.uidByte[1]) |= 0x1010;
+            pc.printf("%d\n",newstr);
+            if(newstr == 145){
+                pc.printf("Order B\n");
+                tagRFID = "B";      
+                DataCode = "$B032";              
+            }
+            if(newstr == 213){
+                pc.printf("Order W\n");
+                tagRFID = "W";
+                DataCode = "$W402";
+            }
+        }
+        if(tagRFID == "B"){
+                float distance = DistanceI.read()*100;
+                //pc.printf("%.2f",distance);
+                if(distance <= 65){
+                    pc.printf("Distance read\n");
+                    allProduct += 1;
+                    wait(12);
+                    uint16_t red, green, blue;
+                    Color.readRedLight(red);
+                    Color.readGreenLight(green);
+                    Color.readBlueLight(blue);
+                    pc.printf("Red = %d\n",red);
+                    pc.printf("Green = %d\n",green);
+                    pc.printf("Blue = %d\n",blue);
+                    int Colors = red + green + blue;
+                        if(Colors >= 4 && Colors <= 6 && blue >= 1){
+                            pc.printf("Blue\n");
+                            wait(1);
+                            if(Proximity == 1){
+                                goodProduct+=1;
+                            }
+                        }
+                        if(Colors >= 16 && Colors <= 21){
+                            badProduct += 1;
+                            if(Proximity != 1){
+                                badProduct+=1;
+                            }
+                        }
+                }
+                    pc.printf("%d\n",goodProduct);
+                    Quality = ((goodProduct-badProduct)/allProduct)*100;
+                    pc.printf("%.2f\n",Quality) ;
+            }
+            if(tagRFID == "W"){
+                float distance = DistanceI.read()*100;
+                //pc.printf("%.2f",distance);
+                if(distance <= 65){
+                    pc.printf("Distance read\n");
+                    allProduct += 1;
+                    wait(12);
+                    uint16_t red, green, blue;
+                    Color.readRedLight(red);
+                    Color.readGreenLight(green);
+                    Color.readBlueLight(blue);
+                    pc.printf("Red = %d\n",red);
+                    pc.printf("Green = %d\n",green);
+                    pc.printf("Blue = %d\n",blue);
+                    int Colors = red + green + blue;
+                        if(Colors >= 20){
+                            pc.printf("White\n");
+                            wait(1);
+                            Proximity.read();
+                            pc.printf("%d\n",Proximity.read());
+                            if(Proximity == 1){
+                                goodProduct+=1;
+                            }
+                        }
+                        if(Colors >= 4 && Colors <= 6 && blue >= 1){
+                            wait(1);
+                            if(Proximity != 1){
+                                badProduct += 1;
+                            }
+                        }
+                        Quality = (goodProduct/allProduct)*100;
+                        pc.printf("%.2f\n",Quality) ; 
+                }
+            }
+        }
+    }
\ No newline at end of file
diff -r 000000000000 -r 3854371f105a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 18 11:53:37 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b
\ No newline at end of file