ใครเคยใช้งานเจ้า WB2085 Touching Detector IC

  • 0 Replies
  • 799 Views
*

Offline nai102

  • ***
  • 177
    • View Profile
พอดีผมซื้อมาจาก thaieasyelec
http://www.thaieasyelec.com/products/sensors/capacitive-touch-sensor-8-ch-wb2085-digital-clock-detail.html
ผมทดลองโค้ดประมาณนี้
Code: [Select]

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(10,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(10,LOW);
digitalWrite(13,LOW);
delay(10000);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(10,HIGH);
  delayMicroseconds(65);
  digitalWrite(10,LOW);
  delayMicroseconds(65);
  byte incoming = WB2085(11, 13);
  Serial.println(incoming,BIN);
  delay(100);
}

uint8_t WB2085(uint8_t dataPin, uint8_t clockPin) {
 uint8_t value = 0;
 uint8_t i;
 for (i = 0; i < 8; ++i) {
   digitalWrite(clockPin, HIGH);delayMicroseconds(65);
   value |= digitalRead(dataPin) << i;
   digitalWrite(clockPin, LOW);delayMicroseconds(65);
 }
 return value;
}

ค่าที่ได้มั่วมาก
Code: [Select]
0
0
0
11110000
1100
1100000
1100
110000
11100001
1111000
11100000
0
0
0
0
11101110
11110001
11110
11000111
111000
110000
10100000
111000
0
11111111
0
0
1
10000
1100
11000001
1110001
1000011
10000010
1110011
11111111
11111111
ใครเคยใช้แนะนำทีครับ
ขอบคุณครับ