在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

構(gòu)建一個帶Arduino代碼的顏色檢測器電路

科技觀察員 ? 來源:homemade-circuits ? 作者:homemade-circuits ? 2023-07-27 11:23 ? 次閱讀

在這篇文章中,我們將構(gòu)建一個可以檢測顏色并觸發(fā)相應(yīng)分配繼電器的電路。該項目是使用 TCS3200 顏色傳感器Arduino 板完成的。

通過 TCS3200 進(jìn)行顏色感應(yīng)

如果您希望電路根據(jù)顏色采取行動,則建議的項目可能會很有用。在各種工業(yè)領(lǐng)域,基于顏色檢測的應(yīng)用海量很大。

該項目將深入了解我們?nèi)绾螌︻伾珎鞲衅鬟M(jìn)行編程以檢測不同的顏色并觸發(fā)繼電器。

我們將考慮該項目的原色:紅色、綠色和藍(lán)色。該項目可以區(qū)分這三種顏色并觸發(fā)繼電器,每個繼電器代表每種顏色。

TCS3200 可以檢測任意數(shù)量的顏色,但為了使項目易于理解并保持程序代碼簡單,我們只關(guān)注原色。

電路圖:

interfacing the Arduino and TCS3200 colour sensor

以上原理圖用于連接Arduino和TCS3200顏色傳感器。

繼電器連接:

relay connections the Arduino and TCS3200 colour sensor

使用至少 9mA 的 500V 適配器為 Arduino
供電晶體管充當(dāng)繼電器的放大器,因為Arduino的GPIO引腳不能提供足夠的電流來繼電器。

二極管 1N4007 將吸收繼電器線圈的高壓尖峰,保護(hù)其余半導(dǎo)體元件。

硬件到此結(jié)束。

現(xiàn)在讓我們看看如何上傳代碼并根據(jù)您的要求校準(zhǔn)傳感器。

顏色靈敏度可能因模塊而異,環(huán)境光會極大地改變顏色靈敏度。

所有TCS3200傳感器在制造時都有一些變化,您必須測量當(dāng)前擁有的傳感器的顏色參數(shù),以便可以在代碼中使用這些參數(shù)來更準(zhǔn)確地檢測顏色。

要校準(zhǔn)和優(yōu)化傳感器的讀數(shù),請精確執(zhí)行以下步驟:

步驟 1:上傳以下代碼并完成硬件設(shè)置。

//--------Program Developed by R.GIRISH-------//

const int s0 = 4;

const int s1 = 5;

const int s2 = 6;

const int s3 = 7;

const int out = 8;

int frequency1 = 0;

int frequency2 = 0;

int frequency3 = 0;

int state = LOW;

int state1 = LOW;

int state2 = HIGH;

void setup()

{

Serial.begin(9600);

pinMode(s0, OUTPUT);

pinMode(s1, OUTPUT);

pinMode(s2, OUTPUT);

pinMode(s3, OUTPUT);

pinMode(out, INPUT);

//----Scaling Frequency 20%-----//

digitalWrite(s0, state2);

digitalWrite(s1, state1);

//-----------------------------//

}

void loop()

{

//-----Sensing RED colour-----//

digitalWrite(s2, state1);

digitalWrite(s3, state1);

frequency1 = pulseIn(out, state);

Serial.print(“RED = ”);

Serial.print(frequency1);

Serial.print(“ |”);

delay(100);

//------Sensing Green colour----//

digitalWrite(s2, state2);

digitalWrite(s3, state2);

frequency2 = pulseIn(out, state);

Serial.print(“ Green = ”);

Serial.print(frequency2);

Serial.print(“ |”);

delay(100);

//------Sensing Blue colour----//

digitalWrite(s2, state1);

digitalWrite(s3, state2);

frequency3 = pulseIn(out, state);

Serial.print(“ Blue = ”);

Serial.println(frequency3);

delay(100);

Serial.println(“-----------------------------”);

delay(400);

}

//---------Program Developed by R.GIRISH---------//

Step 2: Open the serial monitor, you will find the color parameters like
this:

Bring the color object (colored paper is preferred) red, blue and
green.

Step 3:

? Place the red colored paper close to the TCS3200 sensor.

? Note down the R, G, B readings (all three colours) while you place the
red colour paper.

? Similarly note down the R, G, B reading for green and blue color
papers.

? NOTE: when you place any of the 3 colors in front of the TCS3200 note
down all the red, blue and green readings for each color paper, which you need
to enter in the main color detection program.

Step 4: Read Step 5 and upload the main below code (color detection
program)

//-----Program Developed by R.GIRISH-----//

const int Red_relay = 9;

const int Green_relay = 10;

const int Blue_relay = 11;

const int s0 = 4;

const int s1 = 5;

const int s2 = 6;

const int s3 = 7;

const int out = 8;

int var = 25;

int red = 0;

int green = 0;

int blue = 0;

int state = LOW;

int state1 = LOW;

int state2 = HIGH;

//-----------Enter Values--------//

//For RED Colour:

int Rx1 = 92;

int Gx1 = 240;

int Bx1 = 53;

//For GREEN Colour:

int Rx2 = 228;

int Gx2 = 163;

int Bx2 = 64;

//For BLUE Colour:

int Rx3 = 300;

int Gx3 = 144;

int Bx3 = 45;

//----------------------------//

void setup()

{

Serial.begin(9600);

pinMode(Red_relay, OUTPUT);

pinMode(Green_relay, OUTPUT);

pinMode(Blue_relay, OUTPUT);

digitalWrite(Red_relay, LOW);

digitalWrite(Green_relay, LOW);

digitalWrite(Blue_relay, LOW);

pinMode(s0, OUTPUT);

pinMode(s1, OUTPUT);

pinMode(s2, OUTPUT);

pinMode(s3, OUTPUT);

pinMode(out, INPUT);

//----Scaling Frequency 20%-----//

digitalWrite(s0, state2);

digitalWrite(s1, state1);

//-----------------------------//

}

void loop()

{

int redH1 = Rx1 + var;

int redL1 = Rx1 - var;

int redH2 = Rx2 + var;

int redL2 = Rx2 - var;

int redH3 = Rx3 + var;

int redL3 = Rx3 - var;

int blueH1 = Bx1 + var;

int blueL1 = Bx1 - var;

int blueH2 = Bx2 + var;

int blueL2 = Bx2 - var;

int blueH3 = Bx3 + var;

int blueL3 = Bx3 - var;

int greenH1 = Gx1 + var;

int greenL1 = Gx1 - var;

int greenH2 = Gx2 + var;

int greenL2 = Gx2 - var;

int greenH3 = Gx3 + var;

int greenL3 = Gx3 - var;

//-----Sensing RED colour-----//

digitalWrite(s2, state1);

digitalWrite(s3, state1);

red = pulseIn(out, state);

delay(100);

//------Sensing Green colour----//

digitalWrite(s2, state2);

digitalWrite(s3, state2);

green = pulseIn(out, state); ;

delay(100);

//------Sensing Blue colour----//

digitalWrite(s2, state1);

digitalWrite(s3, state2);

blue = pulseIn(out, state);

delay(400);

if(red 《= redH1 && red 》= redL1)

{

if(green 《= greenH1 && green 》= greenL1)

{

if(blue 《= blueH1 && blue 》= blueL1)

{

Serial.println(“Detected Colour: RED”);

Serial.println(“”);

digitalWrite(Red_relay, HIGH);

delay(1000);

}

}

}

if(red 《= redH2 && red 》= redL2)

{

if(green 《= greenH2 && green 》= greenL2)

{

if(blue 《= blueH2 && blue 》= blueL2)

{

Serial.println(“Detected Colour: Green”);

Serial.println(“”);

digitalWrite(Green_relay, HIGH);

delay(1000);

}

}

}

if(red 《= redH3 && red 》= redL3)

{

if(green 《= greenH3 && green 》= greenL3)

{

if(blue 《= blueH3 && blue 》= blueL3)

{

Serial.println(“Detected Colour: Blue”);

Serial.println(“”);

digitalWrite(Blue_relay, HIGH);

delay(1000);

}

}

}

}

//------Program Developed by R.GIRISH--------//

第 5 步: 在上面的代碼中,將值替換為您最近記下的值:

//-- -- -- -- Enter Values-- -- --//

//For RED Colour:

int Rx1 = 92;

int Gx1 = 240;

int Bx1 = 53;

//For GREEN Colour:

int Rx2 = 228;

int Gx2 = 163;

int Bx2 = 64;

//For BLUE Colour:

int Rx3 = 300;

int Gx3 = 144;

int Bx3 = 45;

//-- -- -- -- -- -- -- -- -- -- -- //

當(dāng)您將紅色紙放在傳感器上時,您將獲得三個讀數(shù),例如R = 56 |G = 78 |B = 38。

按如下所示放置值 56、78、38:

對于紅色:

int Rx1 = 56;

int Gx1 = 78;

int Bx1 = 38;

同樣,對于其他兩種顏色并上傳代碼。

步驟6:

? 打開串行監(jiān)視器,將三種顏色中的任何一種放在傳感器前面。

?您將在串行監(jiān)視器上看到顏色檢測;同時激活相應(yīng)的顏色繼電器。

? 您有 Arduino 板上的重置按鈕來停用繼電器。

注1:校準(zhǔn)后,如果您放置的紅色,綠色,藍(lán)色物體/紙張的陰影/色調(diào)略有不同,則電路可能無法檢測到顏色。換句話說,您必須使用完全相同顏色的物體/紙張來檢測顏色并觸發(fā)中繼。

注2:環(huán)境光會影響顏色檢測,因此,在校準(zhǔn)和檢測顏色時,請在傳感器附近保持一致的光線。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 檢測電路
    +關(guān)注

    關(guān)注

    13

    文章

    308

    瀏覽量

    58208
  • 檢測器
    +關(guān)注

    關(guān)注

    1

    文章

    868

    瀏覽量

    47733
  • Arduino
    +關(guān)注

    關(guān)注

    188

    文章

    6474

    瀏覽量

    187435
收藏 人收藏

    評論

    相關(guān)推薦

    構(gòu)建基于晶體管的簡單土壤濕度檢測器電路

    在這個項目中,我們將構(gòu)建基于晶體管的簡單土壤濕度檢測器電路。在本電路中,我們使用NPN晶體管
    的頭像 發(fā)表于 11-22 17:22 ?3738次閱讀
    <b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>基于晶體管的簡單土壤濕度<b class='flag-5'>檢測器</b><b class='flag-5'>電路</b>

    構(gòu)建簡單的空氣流量檢測器電路

    氣流檢測在許多項目和應(yīng)用中都很有用。在這里,我們正在構(gòu)建非常簡單的電路檢測氣流的存在。該
    的頭像 發(fā)表于 12-29 11:19 ?2591次閱讀
    <b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>簡單的空氣流量<b class='flag-5'>檢測器</b><b class='flag-5'>電路</b>

    基于物聯(lián)網(wǎng)的LPG氣體泄漏檢測器

    使用MQ-5傳感、ESP8266和Arduino構(gòu)建基于物聯(lián)網(wǎng)的LPG氣體泄漏檢測器
    發(fā)表于 09-22 06:06

    又溫度傳感的過零檢測器電路

    又溫度傳感的過零檢測器電路
    的頭像 發(fā)表于 04-14 09:28 ?3039次閱讀
    <b class='flag-5'>帶</b>又溫度傳感<b class='flag-5'>器</b>的過零<b class='flag-5'>檢測器</b><b class='flag-5'>電路</b>圖

    材跑偏檢測器測量電路

    材跑偏檢測器測量電路
    發(fā)表于 11-04 22:51 ?1469次閱讀
    <b class='flag-5'>帶</b>材跑偏<b class='flag-5'>檢測器</b>測量<b class='flag-5'>電路</b>

    采用Arduino開發(fā)板、火焰?zhèn)鞲?b class='flag-5'>器和蜂鳴器構(gòu)建火感檢測器系統(tǒng)

    本項目采用Arduino開發(fā)板、火焰?zhèn)鞲?b class='flag-5'>器(Flame Sensor)、蜂鳴器,構(gòu)建簡單的火感檢測
    發(fā)表于 04-19 10:17 ?2749次閱讀
    采用<b class='flag-5'>Arduino</b>開發(fā)板、火焰?zhèn)鞲?b class='flag-5'>器</b>和蜂鳴器<b class='flag-5'>構(gòu)建</b>火感<b class='flag-5'>檢測器</b>系統(tǒng)

    分享不錯的顏色檢測器/傳感電路

    這是顏色檢測器/傳感電路圖。該電路將感應(yīng)八種顏色:綠色、紅色和藍(lán)色(作為原色);洋紅色、青色和
    的頭像 發(fā)表于 06-14 16:55 ?3320次閱讀
    分享<b class='flag-5'>一</b><b class='flag-5'>個</b>不錯的<b class='flag-5'>顏色</b><b class='flag-5'>檢測器</b>/傳感<b class='flag-5'>器</b><b class='flag-5'>電路</b>圖

    使用霍爾傳感和LED構(gòu)建磁極性檢測器

    在這個項目中,我們將使用霍爾傳感和 LED構(gòu)建磁極性檢測器。這里使用了兩霍爾效應(yīng)傳感
    的頭像 發(fā)表于 08-16 15:28 ?5770次閱讀
    使用霍爾傳感<b class='flag-5'>器</b>和LED<b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>磁極性<b class='flag-5'>檢測器</b>

    構(gòu)建基于Arduino的貨幣計數(shù)

    在這個項目中,我們將研究創(chuàng)新的Arduino項目創(chuàng)意,在這里我們可以通過使用顏色傳感Arduin
    的頭像 發(fā)表于 08-22 15:51 ?2712次閱讀
    <b class='flag-5'>構(gòu)建</b><b class='flag-5'>一</b><b class='flag-5'>個</b>基于<b class='flag-5'>Arduino</b>的貨幣計數(shù)<b class='flag-5'>器</b>

    使用二極管和電容器構(gòu)建簡單的峰值檢測器電路

    對于基本的峰值檢測器電路,我們甚至不需要任何復(fù)雜的電子元件。可以使用二極管和電容器構(gòu)建簡單的峰值檢測器電路
    的頭像 發(fā)表于 09-23 15:38 ?4509次閱讀
    使用二極管和電容器<b class='flag-5'>構(gòu)建</b>簡單的峰值<b class='flag-5'>檢測器</b><b class='flag-5'>電路</b>

    Arduino Light Clapper使用聲音檢測器

    電子發(fā)燒友網(wǎng)站提供《Arduino Light Clapper使用聲音檢測器.zip》資料免費下載
    發(fā)表于 11-11 14:19 ?0次下載
    <b class='flag-5'>Arduino</b> Light Clapper使用聲音<b class='flag-5'>檢測器</b>

    Arduino Uno掉電檢測器和記錄

    電子發(fā)燒友網(wǎng)站提供《Arduino Uno掉電檢測器和記錄.zip》資料免費下載
    發(fā)表于 11-15 14:33 ?0次下載
    <b class='flag-5'>Arduino</b> Uno掉電<b class='flag-5'>檢測器</b>和記錄<b class='flag-5'>器</b>

    使用arduino UNO的軸檢測器

    電子發(fā)燒友網(wǎng)站提供《使用arduino UNO的軸檢測器.zip》資料免費下載
    發(fā)表于 11-29 11:06 ?0次下載
    使用<b class='flag-5'>arduino</b> UNO的軸<b class='flag-5'>檢測器</b>

    使用TCS230 TCS3200顏色傳感制作顏色檢測器

    電子發(fā)燒友網(wǎng)站提供《使用TCS230 TCS3200顏色傳感制作顏色檢測器.zip》資料免費下載
    發(fā)表于 02-13 16:48 ?7次下載
    使用TCS230 TCS3200<b class='flag-5'>顏色</b>傳感<b class='flag-5'>器</b>制作<b class='flag-5'>顏色</b><b class='flag-5'>檢測器</b>

    LCD的Arduino EMF鬼檢測器

    電子發(fā)燒友網(wǎng)站提供《LCD的Arduino EMF鬼檢測器.zip》資料免費下載
    發(fā)表于 07-05 09:12 ?1次下載
    <b class='flag-5'>帶</b>LCD的<b class='flag-5'>Arduino</b> EMF鬼<b class='flag-5'>檢測器</b>
    主站蜘蛛池模板: 一级片免费在线 | 九九精品久久久久久噜噜 | 特黄aa级毛片免费视频播放 | 四虎影院成人 | 国产精品久久久久久久人热 | 一级特黄色片 | 欧美成人精品 | 三级亚洲| 手机免费看大片 | 中文字幕二区三区 | 男人的天堂一区二区视频在线观看 | 久久综合九色综合网站 | 亚洲精品第三页 | 日本免费a级片 | 国产一线在线观看 | 天天干夜夜骑 | 三级免费黄录像 | 久久成人免费网站 | 高清午夜线观看免费 | 久久国产影视 | 天天射天天干天天操 | 免费在线成人 | 亚洲成在人线影视天堂网 | 4438成人成人高清视频 | 夜色sese| 人人干人人澡 | 久久天天躁狠狠躁狠狠躁 | 亚洲视频一区二区在线观看 | 成人综合在线视频 | 黄色大片视频 | 国内久久精品 | 黄色www| 国产最新网站 | 五月天综合婷婷 | 在线免费成人网 | 亚洲аv电影天堂网 | 啪啪免费观看 | 欧美成人午夜精品免费福利 | 福利视频一区二区微拍堂 | 在线www天堂资源网 在线播放 你懂的 | 韩国电影天堂网 |