ผู้ตั้ง
ข้อความ
เข้าร่วม: 14 Aug 2012
ตอบ: 1198
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 2:32 pm
ใครเก่ง Arduino ช่วยหน่อยครับ
ในตัวอย่างเค้าให้ทำผมทำแบบนี้

1.ติดตั้ง IR lib ที่ Arduino IDE ก่อน
[ทำแล้ว]

2.เปิดโปรแกรม Arduino แล้วเปิด file : IRrecvDemo
[ทำแล้ว]

3.ต่อบอร์ด Arduino UNO ต่อ IR Module แล้ว อัด file IRrecvDemo ลงไป
- [ขั้นตอนนี้คือเปิดแล้วทำการ Upload ลงในบอร์ดเลยใช่ป้ะครับ]

4.เปิด Serial Monitor แล้วลองกด Remote ดู จะได้ Code ของ IR มา แล้วทำการ Copy มาเก็บไว้เพื่อใส่ใน Array ทำแบบนี้จนได้ครบทุกปุ่มที่เราต้องการ
- [ผมสงสัยครับว่า นำ Code ไปใส่ใว้ใน Array ยังไง เพราะได้โค้ดมาแล้ว นำไปใส่ในคำสั่งเลยก็ไม่ได้ Verify ไม่ผ่าน]

อีกข้อหนึ่งครับ จากข้อที่ 3 ถ้าอัพโหลดใส่บอร์ดแล้ว เวลาจะใส่โค้ด IRremote นี้ต้องอัพโหลดทับไปเลยใช่ไหมครับ


อันนี้โค้ดที่ผมต้องการครับ


 
Spoil
#include <IRremote.h>
#include <IRremoteInt.h>

#include <IRremote.h>

int RECV_PIN = 8;

IRrecv irrecv(RECV_PIN);
decode_results results;

#define OUTPUT_COUNT 10


unsigned long last = millis();
long remote_key[]={8C03F,820DF,8A05F,8609F}; // ตรงนี้ที่เป็นปัญหาครับ

const byte outputPins[OUTPUT_COUNT] = {2,3, 4, 5,6,7};
int BZ_PIN= 10;


struct keypad {
boolean state;
};

keypad output[OUTPUT_COUNT];

void setup()
{
Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver
Serial.println("Hello");
pinMode(BZ_PIN, OUTPUT);
for(int j=1;j< 10;j++){
for(int k=1;k<30;k++){
digitalWrite(BZ_PIN, HIGH);
delayMicroseconds(120);
digitalWrite(BZ_PIN, LOW);
delayMicroseconds(120);
}
}

for (int i=1;i<OUTPUT_COUNT;i++) {
pinMode(outputPins[i], OUTPUT);
output[i].state = LOW;
}
}

void loop() {
unsigned long currentMillis = millis();
int dt=50;
if (irrecv.decode(&results)) {
if (currentMillis - last > 10) {

//Serial.println(results.value, HEX);

if ( results.value != 0x00000000 ) {
// Serial.println(results.value, HEX);
for (int val=1;val<OUTPUT_COUNT;val++) {
if ( results.value == remote_key[val] ) {

if (output[val].state==LOW) {
Serial.print ("ch[");
Serial.print(val);
Serial.println("] ON");
output[val].state=HIGH;
dt = 200;
} else {
output[val].state=LOW;
Serial.print ("ch[");
Serial.print(val);
Serial.println("] OFF");
dt=20;
}

for(int j=1;j< 10;j++){
for(int k=1;k<30;k++){
digitalWrite(BZ_PIN, HIGH);
delayMicroseconds(120);
digitalWrite(BZ_PIN, LOW);
delayMicroseconds(120);
}
}
/
digitalWrite(BZ_PIN, HIGH);
delay(dt);
digitalWrite(BZ_PIN, LOW);
delay(10);
/
}
}
}

for (int i=1;i<OUTPUT_COUNT;i++)
digitalWrite(outputPins[i], output[i].state);

}

last = currentMillis;
//delay(100);
irrecv.resume(); // Receive the next value

}
}  
0
0
เข้าร่วม: 21 Apr 2015
ตอบ: 1384
ที่อยู่: รูทวารหนักของท่านมหาเทพซาตาน
โพสเมื่อ: Sat Feb 04, 2017 2:43 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
จัดไปผมไม่หวง

Spoil
ขี้ส้นเท้าพระองค์ท่าน แบร่ ๆๆๆๆ
0
0
เข้าร่วม: 28 Nov 2009
ตอบ: 8244
ที่อยู่: Old Trafford
โพสเมื่อ: Sat Feb 04, 2017 3:50 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
แบนจนลืมกันไปเลยทีเดียว 2 เดือน

พระองค์คงได้ไปเกิดใหม่แล้วล่ะนะ

เข้าร่วม: 11 Jan 2011
ตอบ: 1625
ที่อยู่: โรงละครแห่งความฝัน
โพสเมื่อ: Sat Feb 04, 2017 4:00 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
justKiller พิมพ์ว่า:
แบนจนลืมกันไปเลยทีเดียว 2 เดือน

พระองค์คงได้ไปเกิดใหม่แล้วล่ะนะ  


อย่างฮา
0
0
.:Theater of Dreams:.
เข้าร่วม: 14 Aug 2012
ตอบ: 1198
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 4:17 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
พระองค์ท่านไปซะแล้ว
เข้าร่วม: 15 May 2010
ตอบ: 1981
ที่อยู่: หน้าคอม && มือถือ : 12HR/Day
โพสเมื่อ: Sat Feb 04, 2017 4:34 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
long remote_key[]={8C03F,820DF,8A05F,8609F}; // ตรงนี้ที่เป็นปัญหาครับ
- ตรงนี้ไม่แน่ใจว่าเป็นที่ long รึป่าว ลองเปลี่ยน ๆ ดูครับ (มั่วนะ )

อีกข้อหนึ่งครับ จากข้อที่ 3 ถ้าอัพโหลดใส่บอร์ดแล้ว เวลาจะใส่โค้ด IRremote นี้ต้องอัพโหลดทับไปเลยใช่ไหมครับ
- ถ้าจำไม่ผิด เวลา upload มันจะทับของเก่าทุกครั้งครับ
| #RIPChesterBennington |
「パン + ジャン + プーペ」 ー BNK48




It's Carrick You Know , Hard to Believe it's Not Scholes.
เข้าร่วม: 12 Feb 2011
ตอบ: 1998
ที่อยู่: ย่านลาดพร้าว แต่คน ท่ายาง จ.เพชรบุรี
โพสเมื่อ: Sat Feb 04, 2017 4:53 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
กากกกกจัง ไอ้ตัวโดนแบน มันจะมาอ่านแน่นวลลล




0
0
เข้าร่วม: 19 Oct 2013
ตอบ: 3899
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 5:22 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
เห็นด้วยสมควรแล้วละอะไรของเขาไม่รู้ หยาบทุกมู้ที่โพส หยาบแบบไม่มีเหตุมีผล
0
0
คุณได้เลื่อนขั้นจากโค้ชหน้าคอมขึ้นเป็นโค้ชหน้าจอ ตั้งแต่วันนี้เป็นต้นไป
เข้าร่วม: 12 May 2009
ตอบ: 1126
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 5:34 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
- ถ้าไม่ยัดใส่ array แล้วทำได้แสดงว่าผิดตอนยัดเข้า array ครับ
- ถามว่าครบปุ่มนี่ตายตัวมั้ยเช่น 2 ครั้งเสมอ อย่างต่ำ 5 ครั้ง หรือแล้วแต่เท่าไรไม่รู้ ถ้าเป็นสองอย่างแรกพอจะ fix size array ได้ แต่อย่างหลังน่าจะต้องทำเป็น pointer (เคยทำแต่ใน c ธรรมดาแต่ใน arduino ผมยังไม่เคยใช้ )
เข้าร่วม: 20 Oct 2009
ตอบ: 7799
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 5:52 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
หยาบนิดๆหน่อยๆมันยังพอขำ แต่นี่ หยาบซ้ำๆซากๆเดิมๆ ถ้าพ้นคุกออกมายังเลอะเทอะอยู่อีก น่าแบนถาวรไปเลย
0
0
เข้าร่วม: 05 Dec 2015
ตอบ: 10719
ที่อยู่: คนบ้านเดียว
โพสเมื่อ: Sat Feb 04, 2017 6:27 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
เนเกรโด้ เด็ก ผี
เข้าร่วม: 13 Jun 2010
ตอบ: 3588
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 6:59 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
ทำไมเด็กแฝง ทีมเราเยอะจัง ฮ่าฮ่า
0
0
เข้าร่วม: 22 Oct 2012
ตอบ: 509
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 7:20 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
ผม่ไม่แน่ใจว่าค่าที่ให้มันเก็บในอาเรย์ผิดชนิดรึเปล่า เห็นข้างหน้า ชนิด Long แต่ข้างในนี่เป็น Float
เข้าร่วม: 28 Dec 2007
ตอบ: 8927
ที่อยู่: สนามกีฬากลาง
โพสเมื่อ: Sat Feb 04, 2017 7:42 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
55555 ไปดูช่อง GMM One ให้เพลิน
0
0
เข้าร่วม: 14 Aug 2012
ตอบ: 1198
ที่อยู่:
โพสเมื่อ: Sat Feb 04, 2017 9:56 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
ruudmandy พิมพ์ว่า:
ผม่ไม่แน่ใจว่าค่าที่ให้มันเก็บในอาเรย์ผิดชนิดรึเปล่า เห็นข้างหน้า ชนิด Long แต่ข้างในนี่เป็น Float  


ไปแก้ยังไงครับ รบกวนหน่อยฮะ
0
0
เข้าร่วม: 07 Sep 2013
ตอบ: 23899
ที่อยู่: The First Order - ปฐมภาคี
โพสเมื่อ: Sat Feb 04, 2017 10:10 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
ซาตานปีศาจ เนเกรโด้ หลายทีแล้วกับคำนิยามส้นตีนที่ใช้ไปทั่วไม่ว่ามู้นั้นจะเกี่ยวอะไรด้วยหรือไม่ คนเค้ารำคาญถึงแจ้งความมา [Link] 04 Feb 2017 05 Apr 2017 15:38 เบน ฟรีคิก
0
0
เข้าร่วม: 14 Aug 2012
ตอบ: 3060
ที่อยู่:
โพสเมื่อ: Sun Feb 05, 2017 1:07 am
ใครเก่ง Arduino ช่วยหน่อยครับ
คอมไพลไม่ผ่าน ขึ้นเออเร่อว่าไง เอาเออเรอมาลงดิ เดวช่วยตอบได้
0
0
Manchester City since 2006
FC Barcelona since 2008
Buriram United since 2012

เข้าร่วม: 05 Dec 2015
ตอบ: 8167
ที่อยู่: JJPEREZ คนเดิม ที่เพิ่มเติมคือความห่วงใย
โพสเมื่อ: Sun Feb 05, 2017 1:44 am
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
Roman-Abramovich พิมพ์ว่า:
เนเกรโด้ เด็ก ผี  

ไปอีก1 เด็กผี
เข้าร่วม: 01 Jun 2016
ตอบ: 3608
ที่อยู่: Etihad Stadium
โพสเมื่อ: Sun Feb 05, 2017 8:53 am
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
arkiyama พิมพ์ว่า:
กากกกกจัง ไอ้ตัวโดนแบน มันจะมาอ่านแน่นวลลล




 



เค้าเชียร์ทีมเดียวกะเงอะ รู้ยัง 5555 นิสัยคล้ายๆ
เข้าร่วม: 14 Aug 2012
ตอบ: 1198
ที่อยู่:
โพสเมื่อ: Sun Feb 05, 2017 1:18 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
StartCPE พิมพ์ว่า:
คอมไพลไม่ผ่าน ขึ้นเออเร่อว่าไง เอาเออเรอมาลงดิ เดวช่วยตอบได้  


ตามนี้เลยครับ


Spoil
Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Uno"

test21:12: error: unable to find numeric literal operator 'operator""C03F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""DF'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""A05F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

Multiple libraries were found for "IRremote.h"
Used: C:\Users\Admin\Documents\Arduino\libraries\IRremote
Not used: C:\Users\Admin\Documents\Arduino\libraries\RobotIRremote-master
Not used: C:\Arduino\libraries\RobotIRremote
exit status 1
unable to find numeric literal operator 'operator""C03F'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 


รบกวนหน่อยนะครับ
0
0
เข้าร่วม: 14 Aug 2012
ตอบ: 3060
ที่อยู่:
โพสเมื่อ: Sun Feb 05, 2017 5:27 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
huntexman พิมพ์ว่า:
StartCPE พิมพ์ว่า:
คอมไพลไม่ผ่าน ขึ้นเออเร่อว่าไง เอาเออเรอมาลงดิ เดวช่วยตอบได้  


ตามนี้เลยครับ


Spoil
Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Uno"

test21:12: error: unable to find numeric literal operator 'operator""C03F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""DF'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""A05F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

Multiple libraries were found for "IRremote.h"
Used: C:\Users\Admin\Documents\Arduino\libraries\IRremote
Not used: C:\Users\Admin\Documents\Arduino\libraries\RobotIRremote-master
Not used: C:\Arduino\libraries\RobotIRremote
exit status 1
unable to find numeric literal operator 'operator""C03F'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 


รบกวนหน่อยนะครับ  


8C03F,820DF,8A05F,8609F
มันน่าจะเปนเลขฐานสิบหกปะ
มันน่าจะเป็น
0x8C03F,0x820DF,0x8A05F,0x8609F แบบนี้ป่าว
Manchester City since 2006
FC Barcelona since 2008
Buriram United since 2012

เข้าร่วม: 05 Dec 2016
ตอบ: 9639
ที่อยู่: บ้าน
โพสเมื่อ: Sun Feb 05, 2017 6:41 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
โดนแบนสินะ ผมโคตรรำคาญเลย ตอบอยู่แบบเดียวทุกมู้
0
0

ติ่งโล้นครับผม
เข้าร่วม: 14 Aug 2012
ตอบ: 1198
ที่อยู่:
โพสเมื่อ: Mon Feb 06, 2017 2:32 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
StartCPE พิมพ์ว่า:
huntexman พิมพ์ว่า:
StartCPE พิมพ์ว่า:
คอมไพลไม่ผ่าน ขึ้นเออเร่อว่าไง เอาเออเรอมาลงดิ เดวช่วยตอบได้  


ตามนี้เลยครับ


Spoil
Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Uno"

test21:12: error: unable to find numeric literal operator 'operator""C03F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""DF'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""A05F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

Multiple libraries were found for "IRremote.h"
Used: C:\Users\Admin\Documents\Arduino\libraries\IRremote
Not used: C:\Users\Admin\Documents\Arduino\libraries\RobotIRremote-master
Not used: C:\Arduino\libraries\RobotIRremote
exit status 1
unable to find numeric literal operator 'operator""C03F'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 


รบกวนหน่อยนะครับ  


8C03F,820DF,8A05F,8609F
มันน่าจะเปนเลขฐานสิบหกปะ
มันน่าจะเป็น
0x8C03F,0x820DF,0x8A05F,0x8609F แบบนี้ป่าว  


ใช่ครับ ต้องเติม 0x ใว้ข้างหน้าด้วย Compile ผ่านแล้วครับท่าน ขอบคุณครับ
ท่านมีโปรแกรมอ่านค่าสัญญาณรีโมทตัวอื่นแนะนำบ้างไหมครับที่ไม่ใช่ Serial Monitor ของ Arduino
0
0
เข้าร่วม: 14 Aug 2012
ตอบ: 3060
ที่อยู่:
โพสเมื่อ: Mon Feb 06, 2017 11:51 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
huntexman พิมพ์ว่า:
StartCPE พิมพ์ว่า:
huntexman พิมพ์ว่า:
StartCPE พิมพ์ว่า:
คอมไพลไม่ผ่าน ขึ้นเออเร่อว่าไง เอาเออเรอมาลงดิ เดวช่วยตอบได้  


ตามนี้เลยครับ


Spoil
Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Uno"

test21:12: error: unable to find numeric literal operator 'operator""C03F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""DF'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""A05F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

test21:12: error: unable to find numeric literal operator 'operator""F'

long remote_key[]={8C03F,820DF,8A05F,8609F};

^

Multiple libraries were found for "IRremote.h"
Used: C:\Users\Admin\Documents\Arduino\libraries\IRremote
Not used: C:\Users\Admin\Documents\Arduino\libraries\RobotIRremote-master
Not used: C:\Arduino\libraries\RobotIRremote
exit status 1
unable to find numeric literal operator 'operator""C03F'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
 


รบกวนหน่อยนะครับ  


8C03F,820DF,8A05F,8609F
มันน่าจะเปนเลขฐานสิบหกปะ
มันน่าจะเป็น
0x8C03F,0x820DF,0x8A05F,0x8609F แบบนี้ป่าว  


ใช่ครับ ต้องเติม 0x ใว้ข้างหน้าด้วย Compile ผ่านแล้วครับท่าน ขอบคุณครับ
ท่านมีโปรแกรมอ่านค่าสัญญาณรีโมทตัวอื่นแนะนำบ้างไหมครับที่ไม่ใช่ Serial Monitor ของ Arduino  


ไม่มีเรยครับ ไม่เคยลองเร่นกะรีโมตซีกที แต่ผมแนะนำให้หาจากเวปนอกดูครับ มีหลากหลาย
Manchester City since 2006
FC Barcelona since 2008
Buriram United since 2012

เข้าร่วม: 12 Aug 2015
ตอบ: 6290
ที่อยู่:
โพสเมื่อ: Tue Feb 14, 2017 7:26 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
วาไรตี้ก้ยังจะขี้ส้นอีกนะ
0
0
เข้าร่วม: 05 Dec 2015
ตอบ: 10719
ที่อยู่: คนบ้านเดียว
โพสเมื่อ: Tue Feb 14, 2017 8:07 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
เนเกรโด้ เด็กผี เล่นสองไอดี
0
0
เข้าร่วม: 01 Jun 2016
ตอบ: 3608
ที่อยู่: Etihad Stadium
โพสเมื่อ: Tue Feb 14, 2017 8:43 pm
[RE: ใครเก่ง Arduino ช่วยหน่อยครับ]
บายยยยยยยยยยยยยยยยย
0
0