Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-A4 DIGITAL I/O
#3
(04-02-2024, 09:52 PM)admin Wrote: your code function is when digital input trigger, Toggle relay.
you can replace this code:
digitalWrite(Relay1, !digitalRead(Relay1));

use if .... else  ...    for ON/OFF relay.

Thank you Sir, 
SOLVED  in this way :
void ScanKey1() {
  KEY_NUM1 = 1;                               // Key1 unpressed
  if (digitalRead(Key1) == LOW) {             // Key1 Pressed
    delay(20);
     if (digitalRead(Key1) == LOW) {
      KEY_NUM1 = 0;                           // if digitalRead(Key1 == low)
         digitalWrite(Relay1, HIGH);          // Relay1 is Turned ON
        } else {                              // if Key1 is turned OFF (Key4 open)
      digitalWrite(Relay1, LOW);              // Rela1 is turned OFF
      }
    }
 }
Reply


Messages In This Thread
KC868-A4 DIGITAL I/O - by franco.demei@gmail.com - 04-02-2024, 09:37 PM
RE: KC868-A4 DIGITAL I/O - by admin - 04-02-2024, 09:52 PM
RE: KC868-A4 DIGITAL I/O - by franco.demei@gmail.com - 04-03-2024, 12:18 PM
RE: KC868-A4 DIGITAL I/O - by admin - 04-03-2024, 12:28 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)