{{ 'fb_in_app_browser_popup.desc' | translate }} {{ 'fb_in_app_browser_popup.copy_link' | translate }}
{{ 'in_app_browser_popup.desc' | translate }}
{{ childProduct.title_translations | translateModel }}
{{ getChildVariationShorthand(childProduct.child_variation) }}
{{ getSelectedItemDetail(selectedChildProduct, item).childProductName }} x {{ selectedChildProduct.quantity || 1 }}
{{ getSelectedItemDetail(selectedChildProduct, item).childVariationName }}
貨號:SSO0012
商品存貨不足,未能加入購物車
您所填寫的商品數量超過庫存
{{'products.quick_cart.out_of_number_hint'| translate}}
{{'product.preorder_limit.hint'| translate}}
每筆訂單限購 {{ product.max_order_quantity }} 件
現庫存只剩下 {{ quantityOfStock }} 件
ColorPAL是一種小型的顏色和光感測器,透過它的RGB LED,亦可作為辨識色彩時的產生器。
當檢測顏色時,ColorPAL使用其LED照亮樣本;一種色彩元素組成的時候,會隨著產生一種譜光,轉換到電壓轉換器來測量反射回來的光。
從樣本反射的光量,分成紅色(R),綠色(G)和藍色(B)三原色 來確定樣本的顏色。本ColorPAL工作於非瑩光的反射面,最好是接觸在它的LED光罩。
Arduino Code:
/* ColorPal Sensor Example for Arduino
Author: Martin Heermance, with some assistance from Gordon McComb
This program drives the Parallax ColorPAL color sensor and provides
serial RGB data in a format compatible with the PC-hosted
TCS230_ColorPAL_match.exe color matching program.
*/
#include <SoftwareSerial.h>
const int sio = 2; // ColorPAL connected to pin 2
const int unused = 255; // Non-existant pin # for SoftwareSerial
const int sioBaud = 4800;
const int waitDelay = 200;
// Received RGB values from ColorPAL
int red;
int grn;
int blu;
// Set up two software serials on the same pin.
SoftwareSerial serin(sio, unused);
SoftwareSerial serout(unused, sio);
void setup() {
Serial.begin(9600);
reset(); // Send reset to ColorPal
serout.begin(sioBaud);
pinMode(sio, OUTPUT);
serout.print("= (00 $ m) !"); // Loop print values, see ColorPAL documentation
serout.end(); // Discontinue serial port for transmitting
serin.begin(sioBaud); // Set up serial port for receiving
pinMode(sio, INPUT);
}
void loop() {
readData();
}
// Reset ColorPAL; see ColorPAL documentation for sequence
void reset() {
delay(200);
pinMode(sio, OUTPUT);
digitalWrite(sio, LOW);
pinMode(sio, INPUT);
while (digitalRead(sio) != HIGH);
pinMode(sio, OUTPUT);
digitalWrite(sio, LOW);
delay(80);
pinMode(sio, INPUT);
delay(waitDelay);
}
void readData() {
char buffer[32];
if (serin.available() > 0) {
// Wait for a $ character, then read three 3 digit hex numbers
buffer[0] = serin.read();
if (buffer[0] == '$') {
for(int i = 0; i < 9; i++) {
while (serin.available() == 0); // Wait for next input character
buffer[i] = serin.read();
if (buffer[i] == '$') // Return early if $ character encountered
return;
}
parseAndPrint(buffer);
delay(10);
}
}
}
// Parse the hex data into integers
void parseAndPrint(char * data) {
sscanf (data, "%3x%3x%3x", &red, &grn, &blu);
char buffer[32];
sprintf(buffer, "R%4.4d G%4.4d B%4.4d", red, grn, blu);
Serial.println(buffer);
}