รหัสสินค้า | SKU-00579 |
หมวดหมู่ | โมดูลสวิตช์/ สวิตช์ |
ราคา | 25.00 บาท |
สถานะสินค้า | พร้อมส่ง |
ลงสินค้า | 19 ก.ย. 2565 |
อัพเดทล่าสุด | 19 ก.ย. 2565 |
คงเหลือ | ไม่จำกัด |
จำนวน | ชิ้น |
โมดูลสวิตช์ปุ่มกด หัวกดคละสี
โมดูลสวิตช์ปุ่มกดพร้อมตัวต้านทาง Pull up ต่อกับ Arduino ได้ทันที
ตัวอย่างโคดปุ่มกด
/*
*/
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
หน้าที่เข้าชม | 114,268 ครั้ง |
ผู้ชมทั้งหมด | 51,030 ครั้ง |
เปิดร้าน | 31 ก.ค. 2559 |
ร้านค้าอัพเดท | 4 ก.ย. 2568 |