const int pinButton = A0;
const int LED1 = 10;
const int LED2 = 11;
const int LED3 = 12;
const int LED4 = 13;
void setup() {
pinMode(pinButton, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
// aktifkan pull-up resistor
digitalWrite(pinButton, HIGH);
}
void loop() {
if(digitalRead(pinButton) == HIGH)
{
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
}else{
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
}
}
0 Response to "Pemograman Input Push Button dengan Arduino dan Proteus"
Post a Comment