วันอาทิตย์ที่ 21 ตุลาคม พ.ศ. 2561

งานปฏิบัติ 18



Code
#include <SoftwareSerial.h>
#include <DHT11.h>
//=============================================
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//LiquidCrystal_I2C lcd(0x27, 16, 2);
LiquidCrystal_I2C lcd(0x3F, 16, 2);
SoftwareSerial ArduinoSerial(3, 2); // RX, TX
//=============================================
int SW_ON = 4,SW_OFF = 5,pin=6;//กำหนดขา INPUT
int Sun = 9,CSun = 0,Relay1 = 12, Relay2 = 11; //กำหนดขา OUTPUT  
int ATL = A0,ATH = A1;//กำหนดขา Analog
int VTL1 = 0,VTH1 = 0,TL = 0,TH =0,VRHL = 50,VRHH = 80;
DHT11 dht11(pin);
//=============================================
void setup()
{
  lcd.begin();
  Serial.begin(115200);
  ArduinoSerial.begin(4800);
  while (!Serial){
    ;
    }
  //=====================================================
  lcd.setCursor(0, 0);lcd.print("Elec Pattayatech");
  lcd.setCursor(0, 1);lcd.print("Smart Farm 2016 ");
  delay(5000);
  //====================================================
  pinMode(Relay1, OUTPUT);pinMode(Relay2, OUTPUT);  
  pinMode(SW_ON, INPUT); pinMode(SW_OFF, INPUT); pinMode(Sun, INPUT);
  digitalWrite(Relay1, HIGH);digitalWrite(Relay2, HIGH);
  lcd.setCursor(0, 0);lcd.print("                ");
  lcd.setCursor(0, 1);lcd.print("                ");
}
//=============================================================
void loop()
{
  while (ArduinoSerial.available() > 0) {
  float val = ArduinoSerial.parseFloat();
  if (ArduinoSerial.read() == '\n') {
  if (val == 10) {
  digitalWrite(13, 1);
  } else if (val == 11) {
  digitalWrite(13, 0);
  }
  Serial.println(val);
  }
  }
  delay(100);
  //========ปรับค่าอุณหภูมิอ้งอิง====================================
  CSun = digitalRead(Sun);
  int err;
  float temp, humi;
  if((err=dht11.read(humi, temp))==0)
  {
  VTL1 = analogRead(ATL);
  VTH1 = analogRead(ATH);
  TL = map(VTL1,0,1023,10,30);
  TH = map(VTH1,0,1023,25,45);
  Serial.print("TL :");Serial.print(TL);Serial.println("*C");
  Serial.print("TH :");Serial.print(TH);Serial.println("*C");
  //===========================================================
    int Stemp =(int)(temp);int Shumi=(int)(humi);//ตัดทศนิยม
    Serial.print("temp :");Serial.print(Stemp);Serial.println("*C");
    Serial.print("humidity :");Serial.print(Shumi);Serial.println("%");
    Serial.print("SUN :");Serial.println(CSun);//Serial.println();
    //===================================================
    lcd.setCursor(0, 0);lcd.print("TL:");lcd.print(TL);
    lcd.setCursor(6, 0);lcd.print("TH:");lcd.print(TH);
    lcd.setCursor(12, 0);lcd.print("S1:");lcd.print(!CSun);
    lcd.setCursor(0, 1);lcd.print("TN:");lcd.print(Stemp);
    lcd.setCursor(6, 1);lcd.print("RH:");lcd.print(Shumi);
    lcd.setCursor(12, 1);lcd.print("P1:0");lcd.print(Shumi);
    delay(1000);
    //===================================================
   //=======ควบคุมอุณหภูมิ===========================
   if(temp < TL && temp < TH ){
        digitalWrite(Relay1, HIGH);//ปั๊มน้ำหยุดทำงาน
        lcd.setCursor(12, 1);lcd.print("P1:0");
        delay(100);
        digitalWrite(Relay2, LOW);//หลอดไฟทำงาน
        lcd.setCursor(12, 0);lcd.print("L1:1");
        delay(60000);//หน่วงเวลา 1 นาที
      }else if(temp > TL && temp > TH){
        digitalWrite(Relay2, HIGH);//หลอดไฟไม่ทำงาน
        lcd.setCursor(12, 0);lcd.print("L1:0");
        delay(100);
        digitalWrite(Relay1, LOW);//ปั๊มน้ำทำงาน
        lcd.setCursor(12, 1);lcd.print("P1:1");
        delay(60000);//หน่วงเวลา 1 นาที
      }else if(temp > TL && temp < TH){
       //=======ควบคุมความชื้น===========================
      if(humi < VRHL && humi < VRHH){
        digitalWrite(Relay2, HIGH);//หลอดไฟไม่ทำงาน
        lcd.setCursor(12, 0);lcd.print("L1:0");
        delay(100);
        digitalWrite(Relay1, LOW);//ปั๊มน้ำทำงาน
        lcd.setCursor(12, 1);lcd.print("P1:1");
        delay(60000);//หน่วงเวลา 1 นาที
      }else if(humi > VRHL && humi > VRHH){
        digitalWrite(Relay1, HIGH);//ปั๊มน้ำหยุดทำงาน
        lcd.setCursor(12, 1);lcd.print("P1:0");
        delay(100);
        digitalWrite(Relay2, LOW);//หลอดไฟทำงาน
        lcd.setCursor(12, 0);lcd.print("L1:1");
        delay(60000);//หน่วงเวลา 1 นาที
      }else if(humi > VRHL && humi < VRHH){
        //delay(1000);
        digitalWrite(Relay1, HIGH);//ปั๊มน้ำหยุดทำงาน
        lcd.setCursor(12, 1);lcd.print("P1:0");
        digitalWrite(Relay2, HIGH);//หลอดไฟไม่ทำงาน
        lcd.setCursor(12, 0);lcd.print("L1:0");
        //หน่วงเวลา 1 นาที      
        }
     //=======ENDควบคุมความชื้น===========================      
        }
     //=======ENDควบคุมอุณหภูมิ===========================
  }
  else
  {
    Serial.println();Serial.print("Error No :");
    Serial.print(err);Serial.println();  
  }
 delay(DHT11_RETRY_DELAY);
}

งานปฏิบัติ 17


code
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int aVal=0,tempaVal=0;
const int SW_ON = 2;
const int led_ON =  13; int CSW_ON = 0; int C_CSW_ON =0;
int Relay1=12,Relay2=11,Relay3=10,Relay4=9;
int sensorPin = A0;
int sensorValue = 0;
void setup() {
  lcd.backlight();
  lcd.begin();
  Serial.begin(9600);
  pinMode(led_ON, OUTPUT);pinMode(SW_ON, INPUT);
  pinMode(Relay1,OUTPUT);pinMode(Relay2,OUTPUT);
  pinMode(Relay3,OUTPUT);pinMode(Relay4,OUTPUT);
//
  digitalWrite(Relay1,HIGH);digitalWrite(Relay2,HIGH);
  digitalWrite(Relay3,HIGH);digitalWrite(Relay4,HIGH);
  lcd.setCursor(0,0);
  lcd.print("Mechatronic2018");
  lcd.setCursor(0,1);
  lcd.print("standby");
}
//END Setup
void loop() {
  CSW_ON = digitalRead(SW_ON);
  sensorValue = analogRead(sensorPin);//Serial.println(sensorValue);
  //=======================================================================
  int c_sensorValue1 = map(sensorValue,0,1023,0,255);
  //Serial.print("c_sensorValue1 = ");Serial.println(c_sensorValue1);
  int c_sensorValue2 = map(sensorValue,0,1023,255,0);
  //Serial.print("c_sensorValue2 = ");Serial.println(c_sensorValue2);
  //=======================================================================
  //check SW_ON
  if (CSW_ON == LOW) { delay(1000);
    lcd.clear();
    C_CSW_ON++;
      Serial.print("C_CSW_ON = ");Serial.println(C_CSW_ON);
    //OPEN Project
    digitalWrite(led_ON, HIGH);
  //END check SW_ON
    if(C_CSW_ON == 1){
    lcd.setCursor(0,0);
    lcd.print("Power On ");
    delay(1000);
    lcd.clear();
    lcd.print("Power On ");
    delay(1000);
    lcd.clear();
    }
  }
  if(C_CSW_ON == 1){//OPEN PROJECT
    digitalWrite(led_ON, HIGH);
    //delay(1000);
    digitalWrite(Relay1, HIGH);
    //ตรวจสอบค่า VR================
      //lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(c_sensorValue1);
      lcd.print(" ");
      //==============================
      if(c_sensorValue1 >= 150){
      digitalWrite(Relay2, LOW);
      }else{
        digitalWrite(Relay2, HIGH);
        }
      //=============================
    //RelaySTART();
    }else{//OFF PROJECT
    lcd.setCursor(0,0);
    //lcd.print("Power Off");
    lcd.setCursor(0,1);
    lcd.print("standby");
    digitalWrite(led_ON, LOW); C_CSW_ON = 0;
    RelaySTOP();
    }
  }//END Loop
//======โปรแกรมย่อย==========
void RelaySTOP(){
digitalWrite(Relay1,HIGH);digitalWrite(Relay2,HIGH);
digitalWrite(Relay3,HIGH);digitalWrite(Relay4,HIGH); 
  }
void RelaySTART(){
digitalWrite(Relay1,LOW);digitalWrite(Relay2,LOW);
digitalWrite(Relay3,LOW);digitalWrite(Relay4,LOW);

งาน 16


code
#include <Stepper.h>
#include "Keypad.h"
#define STEP_ANGLE_4STEP 32 //360/11.25 degree
#define STEP_OUT_WITH_GEAR 2048 //32*64
Stepper stepper(STEP_ANGLE_4STEP,8,10,9,11);
char keys[4][4]={
  {'7','8','9','A'},
  {'4','5','6','B'},
  {'1','2','3','C'},
  {'*','0','#','D'}};
byte rowPins[] = {7,6,5,4};
byte colPins[] = {3,2,1,0};
int speedmotor = 400;
int dirmotor = 1;
Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,4,4);
void setup() 
{
}
void loop() 
{
  char key = keypad.getKey();
  if (key != NO_KEY)
  {
        if (key == '1')
            speedmotor = 400;
        if (key == '2')
            speedmotor = 700;
        if (key == '3')
            speedmotor = 1000;  
        if (key == 'A')
            dirmotor = 1;
        if (key == 'B')
            dirmotor = -1;     
        if (key == 'C')
            dirmotor = 0; 
  }
  stepper.setSpeed(speedmotor);
  stepper.step(dirmotor);
}
////////////////////////////////////////////////////////////////////////////////////

งาน5 ในสถานที่ฝึกงานของ นักศึกษา ใช้ระบบควบคุมคุณภาพอย่างไร

Quality Assurance (QA) กับ Quality Control (QC) QC (Quality Control) หมายถึง  การควบคุมคุณภาพสินค้าให้เป็นไปตามคุณสมบัติที่กำหนดไว้  และส...