Translate

Membuat Light Cure Berbasis Arduino LCD OLED dan Kendali Intensitas LED Untuk Alat Bantu Penambalan Gigi Berlubang / Mematikan Bakteri Mulut

Membuat Light Cure Berbasis Arduino LCD OLED dan Kendali Intensitas LED Untuk Alat Bantu Pengeringan Saat Penambalan Gigi Berlubang / Mematikan Bakteri Mulut


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat untuk membantu dalam pengeringan gigi saat melakukan penambalan, alat ini menggunakan kontroller arduino sebagai kendali intensitas cahayanya dan juga menggunakan interface OLED LCD. terdapat berbagai macam variasi led yang bisa diberikan oleh alat ini. untuk kualitas dari alat ini tergantung pada jenis led yang digunakan. untuk lebih jelasnya berikut adalah komponen dan programnya.     




a. Arduino Nano




b. LCD OLED




c. LED / Laser  + Rangkaian Driver







d. Program Arduino IDE

#include "U8glib.h"
#include <PWM.h>
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); 

unsigned long waktu,waktusekarang;
int x;
char tmp_string1[8];
char tmp_string2[8];
int dataadc;
int z;

int btstart = 8;
int btnext = 7;
int btup = 4;
int btdown = 2;

int btstartx = 0;
int btnextx = 0;
int btupx = 0;
int btdownx = 0;

int ledx = 9;
int tema;
int counter;
int cacah;
int count;

int zx;
int hitung;

void setup(void) {

 pinMode(ledx,OUTPUT);
 digitalWrite(ledx,LOW);

 pinMode(btstart,INPUT);
 pinMode(btnext,INPUT);
 pinMode(btup,INPUT);
 pinMode(btdown,INPUT);
  
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}


void draw(void) {


  btupx = digitalRead(btup);
  btdownx = digitalRead(btdown);
  btnextx = digitalRead(btnext);

 if(btnextx == 1){
 count++;
 }

 if(count > 2){
 count = 0;
 }

 if(count < 0){
 count = 2;
 }

 if (tema == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(25, 13, "LIGHT CURE");
 }


 if(count == 0){
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 28, "-");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 43, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 58, "x");

 
 }

 if(count == 1){
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 28, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 43, "-");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 58, "x");

 }


 if(count == 2){
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 28, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 43, "x");
 
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(80, 58, "-");

 }


 if((btupx == 1)&&(count == 0)){
   delay(50);
   counter++;  
 }

 if((btdownx == 1)&&(count == 0)){
   delay(50);
   counter--;
 }


 if((btupx == 1)&&(count == 1)){
   delay(50);
   cacah++;  
 }

 if((btdownx == 1)&&(count == 1)){
   delay(50);
   cacah--;
 }


 if((btupx == 1)&&(count == 2)){
   delay(50);
   hitung++;  
 }

 if((btdownx == 1)&&(count == 2)){
   delay(50);
   hitung--;
 }



if(cacah > 2){
cacah = 0;
}
if(cacah < 0){
cacah = 2;
}


if(hitung > 3){
hitung = 0;
}
if(hitung < 0){
hitung = 3;
}


 if(counter > 2){
 counter = 0;
 }

 if(counter < 0){
 counter = 2;
 }
 
 if(counter == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 28, "Waktu= 20");
 }

 if(counter == 1){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 28, "Waktu= 40");
 }

 if(counter == 2){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 28, "Waktu= 60");
 }


if(cacah == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 43, "Mode = 1");
 }

 if(cacah == 1){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 43, "Mode = 2");
 }

 if(cacah == 2){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 43, "Mode = 3");
 }


if(hitung == 0){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= 0");
 }

 if(hitung == 1){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= T");
 }

 if(hitung == 2){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= R");
 }


 if(hitung == 3){
  // graphic commands to redraw the complete screen should be placed here
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr(0, 58, "Inten= S");
 }
 
}

void loop(void) {

 
  btstartx = digitalRead(btstart);
 
 if(btstartx == 1){
 mulai();
 }
 
  // picture loop
  u8g.firstPage();
  do {
    draw();
  } while( u8g.nextPage() );

  // rebuild the picture after some delay
  delay(500);
}

void mulai(){

if(hitung == 0){
 
if((counter == 0)&&(cacah == 0)&&(hitung == 0)){
analogWrite(ledx,64);
delay(10000);
analogWrite(ledx,255);
delay(10000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 1)&&(cacah == 0)&&(hitung == 0)){
analogWrite(ledx,64);
delay(10000);
analogWrite(ledx,255);
delay(20000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 2)&&(cacah == 0)&&(hitung == 0)){
analogWrite(ledx,64);
delay(10000);
analogWrite(ledx,255);
delay(30000);
analogWrite(ledx,0);
berhenti();
}

//===========================================

if((counter == 0)&&(cacah == 1)&&(hitung == 0)){
analogWrite(ledx,64);
delay(5000);
analogWrite(ledx,127);
delay(2500);
analogWrite(ledx,191);
delay(2500);
analogWrite(ledx,255);
delay(10000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 1)&&(cacah == 1)&&(hitung == 0)){
analogWrite(ledx,64);
delay(5000);
analogWrite(ledx,127);
delay(5000);
analogWrite(ledx,191);
delay(5000);
analogWrite(ledx,255);
delay(20000);
analogWrite(ledx,0);
berhenti();
}

if((counter == 2)&&(cacah == 1)&&(hitung == 0)){
analogWrite(ledx,64);
delay(5000);
analogWrite(ledx,127);
delay(7500);
analogWrite(ledx,191);
delay(7500);
analogWrite(ledx,255);
delay(20000);
analogWrite(ledx,0);
berhenti();
}

//==================================

if((counter == 0)&&(cacah == 2)&&(hitung == 0)){
zx = 20;
  kedip();
  berhenti();
}

if((counter == 1)&&(cacah == 2)&&(hitung == 0)){
zx = 40;
  kedip();
  berhenti();
}

if((counter == 2)&&(cacah == 2)&&(hitung == 0)){
zx = 60;
  kedip();
  berhenti();
}

}



if((hitung == 1)&&(counter == 0)){
  analogWrite(ledx,255);
  delay(20000);   
  berhenti();
}

if((hitung == 1)&&(counter == 1)){
  analogWrite(ledx,255);
  delay(40000);   
  berhenti();
}

if((hitung == 1)&&(counter == 2)){
  analogWrite(ledx,255);
  delay(60000);   
  berhenti();
}


//=======================================

if((hitung == 2)&&(counter == 0)){
  analogWrite(ledx,64);
  delay(20000);   
  berhenti();
}

if((hitung == 2)&&(counter == 1)){
  analogWrite(ledx,64);
  delay(40000);   
  berhenti();
}

if((hitung == 2)&&(counter == 2)){
  analogWrite(ledx,64);
  delay(60000);   
  berhenti();
}


//=======================================

if((hitung == 3)&&(counter == 0)){
  analogWrite(ledx,128);
  delay(20000);   
  berhenti();
}

if((hitung == 3)&&(counter == 1)){
  analogWrite(ledx,128);
  delay(40000);   
  berhenti();
}

if((hitung == 3)&&(counter == 2)){
  analogWrite(ledx,128);
  delay(60000);   
  berhenti();
}


mulai();
}

void kedip(){
zx--;
digitalWrite(ledx,LOW);
delay(500);
digitalWrite(ledx,HIGH);
delay(500);

if(zx < 0){
  zx = 0;
digitalWrite(ledx,LOW);
berhenti();
}
 
kedip();
}

void berhenti(){
digitalWrite(ledx,LOW);
berhenti();
}




e. VIDEO HASILNYA










No comments:

Post a Comment