熱門文章

2017年8月31日 星期四

紅斑黑色素(組裝)

紅斑黑色素檢測儀

這台的感應器是採用—TCS 34725 RGB顏色感測器 及 Nokia5110 螢幕



------ 程式碼如下 -----

// LCD5110_Scrolling_Text 
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a demo of how to use print().
//
// This program requires a Nokia 5110 LCD module.
//
// It is assumed that the LCD module is connected to
// the following pins:
//      SCK  - Pin 8  =CLK  RED
//      MOSI - Pin 9  =DN   Blue
//      DC   - Pin 10 =DC   Green
//      RST  - Pin 11 =RST  Orange
//      CS   - Pin 12 =CE   Yellow
//      VCC           =5V   Black
//      GND                 White
//      BL            =3.3v EarthGray
#include 
#include 
#include "Adafruit_TCS34725.h"
LCD5110 myGLCD(8,9,10,11,12);

extern unsigned char SmallFont[];
/* Initialise with default values (int time = 2.4ms, gain = 1x) */
// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);

void setup()
{
  Serial.begin(9600);
  /* if (tcs.begin()) {
    Serial.println("Found sensor");
  } else {
    Serial.println("No TCS34725 found ... check your connections");
    while (1);
  }
  */
  // Now we're ready to get readings!
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
  //randomSeed(analogRead(0));
}

void loop()
{
 uint16_t r, g, b, c, colorTemp, lux;
  
  tcs.getRawData(&r, &g, &b, &c);
  colorTemp = tcs.calculateColorTemperature(r, g, b);
  lux = tcs.calculateLux(r, g, b);
  
  Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
  Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
  Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
  Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
  Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
  Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
  Serial.println(" ");   
   
   myGLCD.print("Col:", 0, 0);
   myGLCD.printNumI(colorTemp, 24, 0);
   myGLCD.print("Lux:     ", 0, 8);
   myGLCD.printNumI(lux, 24, 8);
   myGLCD.print("R:       ", 0, 16);
   myGLCD.printNumI(r, 24, 16);
   myGLCD.print("G:       ", 0, 24);
   myGLCD.printNumI(g, 24, 24);
   myGLCD.print("B:       ", 0, 32);
   myGLCD.printNumI(b, 24, 32);
   myGLCD.print("C:       ", 0, 40);
   myGLCD.printNumI(c, 24, 40);
 //myGLCD.printNumF(x,6,CENTER,24);
 //myGLCD.printNumI(x, 0, 40);
   myGLCD.update();
    delay(50);  
}

1 則留言:

  1. 多謝發明者的功能解說
    請問是否有承接製作儀器
    我有歐洲客戶有需求

    回覆刪除