.
.
.
void setup() {
/*
RGB LED 입출력설정
*/
pinMode(R_LED_PIN, OUTPUT);
pinMode(G_LED_PIN, OUTPUT);
pinMode(B_LED_PIN, OUTPUT);
lcd.init(); // LCD 초기화
lcd.backlight(); // LCD 백라이트 켜기(화면 밝아짐)
lcd.setCursor(2,0); // 커서 (2,0)
lcd.print("*INTERRUPT*"); // 글자출력
delay(500);
attachInterrupt(digitalPinToInterrupt(BUTTONPIN), button, FALLING);
/* 인터럽트 설정(아두이노 3번 핀, button 함수 호출, 모드 FALLING */
}
void loop() {
/*
led_color 함수에 Red, Green에 무작위 값과 Blue에는 0을 인자로 전달
delay를 0~99 사이의 무작위 값으로 설정
*/
led_color(random(256), random(256), 0);
int Blue = 0;
delay(random(100));
.
.
.
I can't resolve the problem like a title in the interrupt zone: attachInterrupt(digitalPinToInterrupt(BUTTONPIN), button, FALLING);
Arduino uno error makes me crazy!!!!!! Please help me...
You have not shared the whole code but for your understanding I have written code in place of button you have to provide a function checkSwitch.
const byte ledPin = 13;
const byte buttonPin = 2;
// Boolean to represent toggle state
volatile bool toggleState = false;
void checkSwitch() {
// Check status of switch
// Toggle LED if button pressed
if (digitalRead(buttonPin) == LOW) {
// Switch was pressed
// Change state of toggle
toggleState = !toggleState;
// Indicate state on LED
digitalWrite(ledPin, toggleState);
}
}
void setup() {
// Set LED pin as output
pinMode(ledPin, OUTPUT);
// Set switch pin as INPUT with pullup
pinMode(buttonPin, INPUT_PULLUP);
// Attach Interrupt to Interrupt Service Routine
attachInterrupt(digitalPinToInterrupt(buttonPin),checkSwitch, FALLING);
}
void loop() {
// 5-second time delay
Serial.println("Delay Started");
delay(5000);
Serial.println("Delay Finished");
Serial.println("..............");
}