Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
【Sensor series program】-#02-Arduino code of KC868-A6 and Laser Sensor
#1
Wink 
【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());
     }
 
}
       
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)