▼ กำลังโหลดข้อมูล... ▼
แสดงความคิดเห็น
คุณสามารถแสดงความคิดเห็นกับกระทู้นี้ได้ด้วยการเข้าสู่ระบบ
กระทู้ที่คุณอาจสนใจ
อ่านกระทู้อื่นที่พูดคุยเกี่ยวกับ
C (ภาษาคอมพิวเตอร์)
Microcontroller
ซอฟต์แวร์
อิเล็กทรอนิกส์
Arduino
รบกวนช่วยแก้ปัญหา Arduino หน่อยครีบ (หัดเล่น)
นี่codeที่ทำคับ
int Button1 = 2;
int Button2 = 3;
int CountB1;
int CountB2;
int ButtonState = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(Button1, INPUT);
pinMode(Button2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
CountB1 = digitalRead(Button1);
if(CountB1 == 0){
CountB2 = digitalRead(Button2);
if(CountB2 == 0){
ButtonState = ButtonState+1;
}
}else{
CountB2 = digitalRead(Button2);
if(CountB2 == 0){
CountB1 = digitalRead(Button1);
if(CountB1 == 0){
ButtonState = ButtonState-1;
}
}
}
Serial.println(ButtonState);
delay(100);
}
ขอบคุณครับ