Smart Home Automation Forum
【Sensor series program】-#02-Arduino code of KC868-A6 and Laser Sensor - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A6 (https://www.kincony.com/forum/forumdisplay.php?fid=22)
+--- Thread: 【Sensor series program】-#02-Arduino code of KC868-A6 and Laser Sensor (/showthread.php?tid=1936)



【Sensor series program】-#02-Arduino code of KC868-A6 and Laser Sensor - KinCony Support - 05-20-2022

【Sensor series program】-#02-Arduino code of KC868-A6 and Laser Sensor

Code:
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,  15, 4, U8X8_PIN_NONE);//SCL IO15  SDA  IO4


void page1() {
  u8g2.setFont(u8g2_font_timR14_tf);// Font 18
  u8g2.setFontPosTop();
  u8g2.setCursor(5,20);
  u8g2.print("Sending Lasers ");
}
void page2() {
  u8g2.setFont(u8g2_font_timR14_tf);// Font 18
  u8g2.setFontPosTop();
  u8g2.setCursor(5,20);
  u8g2.print("Not Sending");
}

void setup() {
  pinMode(0,INPUT);
  pinMode(32,OUTPUT);
  u8g2.setI2CAddress(0x3C*2);
  u8g2.begin();
  u8g2.enableUTF8Print();
 
}
void loop() {
  if(digitalRead(0)==LOW)
  {
   digitalWrite(32,HIGH);
   u8g2.firstPage();
    do
     {
    page1();
     }while(u8g2.nextPage());
  }
  else
     {
      digitalWrite(32,LOW);
         u8g2.firstPage();
    do
     {
       page2();
     }while(u8g2.nextPage());
     }
 
}