Nisam sad koristio interrupt.
Prijem.
EDIT
Kada sam dodao interrupt sa onim dodacima stopiranja interrupt-a onda opet dobijam ono kašnjenje, tako da nisam dobro interrupt odradio.
Code:
int LED = 12;
int taster1 = 8;
int taster2 = 9;
void setup() {
pinMode(LED, OUTPUT);
pinMode(taster1, INPUT);
pinMode(taster2, INPUT);
Serial.begin(9600);
}
void loop() {
if(digitalRead(8) == HIGH){
digitalWrite(LED, HIGH);
Serial.println(1111);
}
else{
Serial.println(0000);
digitalWrite(LED, LOW);
}
if(digitalRead(9) == HIGH){
Serial.println(2222);
}
else{
taster2test = 0;
Serial.println(3333);
}
delay(20);
}
Prijem.
Code:
int ledPin = 13;
int ledPin2 = A1;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
if(Serial.available() > 0){
int input = Serial.parseInt();//read serial input and convert to integer (-32,768 to 32,767)
if(input == 1111){//if on code is received
digitalWrite(ledPin, HIGH);//turn LED on
}
if(input == 0000){//if off code is received
digitalWrite(ledPin, LOW);//turn LED off
}
if(input == 2222){
digitalWrite(ledPin2, HIGH);
}
if(input == 3333){
digitalWrite(ledPin2, LOW);
}
}
}
EDIT
Kada sam dodao interrupt sa onim dodacima stopiranja interrupt-a onda opet dobijam ono kašnjenje, tako da nisam dobro interrupt odradio.