Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
【Sensor series program】-#01-Arduino code of KC868-A6 and Hall Sensor
#1
Wink 
【Sensor series program】-#01-Arduino code of KC868-A6 and Hall Sensor

Code:
/*【Sensor series program】Arduino code of KC868-A6 and Hall Sensor*/
/*When the Hall sensor is triggered, Turn on relay 1; Otherwise turn off relay1*/
#include "Wire.h"
#include"PCF8574.h"

PCF8574 pcf8574_RE(0x24,4,15);
int rawValue;

void setup(){

  pinMode(32,INPUT);
  Serial.begin(115200);
  pcf8574_RE.pinMode(P0,OUTPUT);
  pcf8574_RE.pinMode(P1,OUTPUT);
  pcf8574_RE.pinMode(P2,OUTPUT);
  pcf8574_RE.pinMode(P3,OUTPUT);
  pcf8574_RE.pinMode(P4,OUTPUT);
  pcf8574_RE.pinMode(P5,OUTPUT);
  pcf8574_RE.begin();
  for(int i=0;i<6;i++)
  {
   pcf8574_RE.digitalWrite(i,HIGH);
  }
}

void loop(){
  rawValue=analogRead(32);
  Serial.println(rawValue);
  if(rawValue==0)
  {
     
      pcf8574_RE.digitalWrite(P0,LOW);
  }
  else {
      pcf8574_RE.digitalWrite(P0,HIGH);
  }
}
 
   
Reply


Messages In This Thread
【Sensor series program】-#01-Arduino code of KC868-A6 and Hall Sensor - by KinCony Support - 05-20-2022, 03:11 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)