Translate

Mobil Parkir Otomatis (Self-Car Parking System) Menggunakan ANDROID dan Arduino

Mobil Parkir Otomatis (Self-Car Parking System) Menggunakan ANDROID dan Arduino


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah sistem mobil yang mana mobil tersebut bisa parkir otomatis, jadi mobil bisa menuju ke parkiran dan menempatkan mobil ke halaman parkir. handphone android digunakan untuk menentukan lokasi parkir yang diinginkan. mikrokontroller yang dipakai adalah Arduino UNO dan motor driver yang digunakan untuk kendali roda adalah L298. sebagai pengaman arus dan tegangan dipakai UBEC 3A agar arus tidak masuk ke Arduino secara berlebih saat motor dc berjalan. untuk deteksi jarak saat mundur digunakan sensor jarak SRF04. terdapat sensor photodioda yang akan mendeteksi lokasi parkir 1 dan 2, jika terdeteksi garis hitam pertama, artinya disitulah tempat parkir 1, jika terdeteksi garis hitam kedua, artinya disitulah parkiran ke 2. untuk lebih jelasnya berikut adalah program dam skema lengkapnya. 




1. Arduino UNO





2. LCD 16x2 dan I2C Modul





3. Driver Motor L298





4. Sensor Photodioda





5. UBEC 3A





6. Sensor Jarak SRF04





7. Bluetooth HC-05





8. Progam Android 






9. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal_I2C.h>

#define trigPin 3
#define echoPin 4

const int pwm = 2;
int accelero;
int f = 1;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
 
  Serial.begin(9600);
  Serial.setTimeout(5);
 
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
 
  pinMode(6, OUTPUT);
  pinMode(pwm, OUTPUT);

 
}

void loop() {

/* 
      int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
 
  lcd.setCursor(0, 0);
  lcd.print(dataadc0);
  lcd.print(" ");
  lcd.print(dataadc1);
 
  lcd.setCursor(0, 1);
  lcd.print(dataadc2);
  lcd.print(" ");
  lcd.print(dataadc3);
 
  delay(2000);
  lcd.clear();
*/ 

  if (Serial.available() > 0)
{
  accelero = Serial.parseInt();
  Serial.println(accelero);

 if (accelero == 100)
 {

  lcd.setCursor(0, 0);
  lcd.print("PARKIR SATU ");
  delay(3000);
  lcd.clear();
 
  analogWrite(pwm,128);
  analogWrite(6,150);

  for (int i=0; i <= 40; i++){
   
    int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
      
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  if((dataadc0 > 1000) && (dataadc1 > 1000) && (dataadc2 > 1000) && (dataadc3 > 1000)) {
  i = 39;
  }
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
    
  for (int i=0; i <= 80; i++){
 
 
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){
 

//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
 
 
  for (int i=0; i <= 30; i++){

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
while(1){
//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  lcd.setCursor(0, 0);
  lcd.print("jarak ");
  lcd.setCursor(0, 1);
  lcd.print(distance);

 if(distance < 7){

   while(1){
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);   
     loop();
   }
  
 }
 
}  

}



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



 if (accelero == 300)
{

   analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("PARKIR TIGA ");
  delay(3000);
  lcd.clear();
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);

  for (int i=0; i <= 100; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
    
  for (int i=0; i <= 80; i++){
 

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
 
 
while(1){
//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  lcd.setCursor(0, 0);
  lcd.print("jarak ");
  lcd.setCursor(0, 1);
  lcd.print(distance);

 if(distance < 7){

   while(1){
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);   
    loop();
   }
  
 }
 
}  

}


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

 if (accelero == 200)
 {

  
  lcd.setCursor(0, 0);
  lcd.print("PARKIR DUA ");
  delay(3000);
  lcd.clear();

  analogWrite(pwm,128);
  analogWrite(6,150);

  for (int i=0; i <= 100; i++){
   
    int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
      
  if((dataadc0 > 1000) && (dataadc1 > 1000) && (dataadc2 > 1000) && (dataadc3 > 1000)&&(f == 1)) {
  f = 2;
 
  for (int i=0; i <= 10; i++){
    //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
      int dataadc0 = analogRead(A0);
     int dataadc1 = analogRead(A1);
      int dataadc2 = analogRead(A2);
       int dataadc3 = analogRead(A3);
 
  }
 
  
  }
 
      dataadc0 = analogRead(A0);
      dataadc1 = analogRead(A1);
      dataadc2 = analogRead(A2);
      dataadc3 = analogRead(A3);
 
 
  if((dataadc0 > 1000) && (dataadc1 > 1000) && (dataadc2 > 1000) && (dataadc3 > 1000)&&(f == 2)) {
  i = 99;
  f = 1;
  }
      
      
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
    
  for (int i=0; i <= 50; i++){
 

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 50; i++){
 

//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
 
 
  for (int i=0; i <= 30; i++){

  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
    digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
while(1){
//mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
  long duration, distance;
  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

  lcd.setCursor(0, 0);
  lcd.print("jarak ");
  lcd.setCursor(0, 1);
  lcd.print(distance);

 if(distance < 7){

   while(1){
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);   
     loop();
   }
  
 }
 
}  
 

 
}





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


 if (accelero == 400)
 {


  analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("KELUAR 1 ");
  delay(3000);
  lcd.clear();
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);

  for (int i=0; i <= 80; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
    
  for (int i=0; i <= 50; i++){
 

  //MUNDUR
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kanan
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 30; i++){

  //mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){

  //maju
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  

 }


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


  if (accelero == 500)
 {

  

  analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("KELUAR 2 ");
  delay(3000);
  lcd.clear();
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);

  for (int i=0; i <= 80; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //KANAN
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
 
    
  for (int i=0; i <= 50; i++){
 

  //MUNDUR
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kiri 
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
 
    loop();
    
 }

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

  if (accelero == 600)
 {


  analogWrite(pwm,128);
  analogWrite(6,150);
 
  lcd.setCursor(0, 0);
  lcd.print("KELUAR 3 ");
  delay(3000);
  lcd.clear();
 
   //kanan 
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  delay(1000);

  for (int i=0; i <= 80; i++){
   
  //maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
 
    
  for (int i=0; i <= 50; i++){
 

  //MUNDUR
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
   //kanan 
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  delay(1000);
  
 
  for (int i=0; i <= 80; i++){
 

//maju 
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);   
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }

  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
  //kiri
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
 
 
  for (int i=0; i <= 30; i++){

  //mundur 
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
  
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(3000);
 
    //lurus
  digitalWrite(10, HIGH);
  digitalWrite(11, LOW);
  delay(1000);
 
  //lurus
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
 
 
  for (int i=0; i <= 80; i++){

  //maju
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH); 
  delay(5);


  digitalWrite(12, LOW);
  digitalWrite(13, LOW);   
  delay(50);
 
   }
  
 
  
 }



}

 
}




10. VIDEO HASILNYA














Membuat Charger Dengan PIEZOELECTRIC dan Monitor Tegangan Dengan ARDUINO

Membuat Charger Dengan PIEZOELECTRIC dan Monitor Tegangan Dengan ARDUINO


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat dengan menggunakan PIEZOELECTRIC sebagai device penghasil tegangan, alat ini menggunakan Arduino sebagai monitoring tegangan masuk dan keluar dari battery. tujuan utama dari alat ini yaitu memanfaatkan media getar atau gerak sebagai penghasil sumber tegangan. jadi saat piezo terkena getaran, dia akan menghasilkan tegangan yang cukup tinggi berkisar 1 volt sampai 10 volt. untuk lebih jelasnya berikut adalah skema dan programnya.



a. Arduino UNO





b. Rangkaian Rectifier 





c. Piezoelectric






d. LCD 16x2






e. Program Arduino IDE

#include "Wire.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  lcd.noCursor();
}

void loop() {

  int voltage = analogRead(A0);
  float vol = voltage * (5.0 / 1023.0);

  int voltage1 = analogRead(A1);
  float vol1 = voltage1 * (5.0 / 1023.0);
 
  lcd.setCursor(0, 0);
  lcd.print("Vin= ");
  lcd.print(vol);
   
  lcd.setCursor(0, 1);
  lcd.print("Vout");
  lcd.print(vol1);
  
}





f. VIDEO HASILNYA









MEMBUAT ALAT UKUR KADAR GULA DARAH SECARA NON-INVASIVE



MEMBUAT ALAT UKUR KADAR GULA DARAH SECARA NON-INVASIVE


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat dengan menggunakan mikrokontroller untuk mengukur kadar gula darah didalam tubuh, jika biasanya untuk mengukur kadar gula darah harus menggunakan sample darah, maka alat ini didesain dengan cara non-invasive agar tidak perlu menggunakan darah lagi. alat ini berbasis pantulan atau bias cahaya sehingga yang sebenarnya dideteksi adalah intensitas cahaya yang didapat dari sumber cahaya yang melewati kulit dan pembulu darah pada jari tangan. untuk lebih jelasnya berikut adalah skema dan programnya.




a. Minimum System ATMega






b. Sensor Photodioda - Led Merah





R3 = 100K
R2 = 220 
D1 = Photodioda
LED1 = Led Super Bright Merah





c. Program Bascom AVR

$regfile = "m8def.dat"
$crystal = 4000000

Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.1 , Db4 = Portb.0
Config Lcdpin = Pin , Db5 = Portd.7 , Db6 = Portd.6 , Db7 = Portd.5
Config Lcd = 16 * 2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Dim Dataadc(20) As Word

Dim A As Integer
A = 0
Dim X As Integer
X = 0

Dim Datafix As Integer
Datafix = 0
Dim Hasil As Integer
Hasil = 0


Cls
Cursor Off

Start Adc

Do

Do

Dataadc(x) = Getadc(5)

Datafix = Datafix + Dataadc(x)

Cls

Incr X

Waitms 10

Loop Until X > 20

Hasil = Datafix / 20

Upperline
Lcd "ADC = " ; Hasil

Waitms 200
X = 0
Datafix = 0
Hasil = 0

Loop

'------------------------ end






d. Data Hasil Pengujian









e. VIDEO HASILNYA









 

Mengakses Motor Servo dan Sensor Suhu LM35 Dengan Code Vision AVR ( CV AVR )

Mengakses Motor Servo dan Sensor Suhu LM35 Dengan Code Vision AVR ( CV AVR )


       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara mengakses motor servo dan sensor suhu LM35 menggunakan bahasa c (CV AVR). alat ini sebenarnya digunakan untuk mengendalikan valve, jika suhu telah melebihi batas yang ditentukan maka servo akan berputar menutup valve, jika kurang dari batas yang ditentukan maka servo akan berputar membuka valve. begitu seterusnya. untuk mengetahui program dan skemanya bisa simak ulasan berikut.



 a. Minimum System





b. Motor Servo





c. Sensor Suhu LM35





d. UBEC 3A Voltage Regulator






e. Program Code Vision AVR (CV AVR)

 /*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
Date    : 8/6/2016
Author  : NeVaDa
Company :
Comments: cah lebay mencari puing2 asmara


Chip type               : ATmega16
Program type            : Application
AVR Core Clock frequency: 11.059200 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 256
*****************************************************/

#include <mega16.h>
#include <stdlib.h>
#include <delay.h>
#include <math.h>

// Standard Input/Output functions
#include <stdio.h>

// Alphanumeric LCD Module functions
#include <alcd.h>

#define ADC_VREF_TYPE 0x40
#define servo1 PORTC.0

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}

// Declare your global variables here
unsigned int dataadc1, y, data1;
float suhu, vin;
 
char temp[10];

// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Place your code here
y++;
if (y==900){y=0;}

if (y <=data1){ servo1=1;}
else{ servo1=0;}


}

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;

// Port C initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTC=0x00;
DDRC=0xFF;

// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTD=0x00;
DDRD=0xFF;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0x01;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x01;

// USART initialization
// USART disabled
UCSRB=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC Clock frequency: 691.200 kHz
// ADC Voltage Reference: AVCC pin
// ADC Auto Trigger Source: Free Running
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0xA4;
SFIOR&=0x1F;

// SPI initialization
// SPI disabled
SPCR=0x00;

// TWI initialization
// TWI disabled
TWCR=0x00;

// Alphanumeric LCD initialization
// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTB Bit 0
// RD - PORTB Bit 1
// EN - PORTB Bit 2
// D4 - PORTB Bit 4
// D5 - PORTB Bit 5
// D6 - PORTB Bit 6
// D7 - PORTB Bit 7
// Characters/line: 16
lcd_init(16);
lcd_clear();
// Global enable interrupts
#asm("sei")

while (1)
      {
      // Place your code here
      dataadc1=read_adc(0);
      vin = (dataadc1 * 5.0)/1023.0; 
      suhu = vin * 100;       

   
      ftoa(suhu,2,temp);    
      lcd_gotoxy (0,0);
      lcd_putsf("Suhu=");
      lcd_puts(temp);
      lcd_putsf(" c");

if(suhu > 40){

PORTD.2 = 1;
PORTD.3 = 0;

PORTC.0=0;
data1=50;
delay_ms(1000);

}
else {

PORTD.2 = 0;
PORTD.3 = 1;

PORTC.0=0;
data1=150;
delay_ms(1000);

}

            
      }
}




f. Cara Menggunakan Alat

       Pertama hubungkan servo dengan mikrokontroller, kemudian pastikan UBEC 3A terpasang untuk penurun tegangan ke 5v dari 12v DC. setelah itu pastikan sumber tegangan lebih dari 1A. setelah semua siap. hubungkan servo dengan UBEC 3A untu Vcc dan GND. port signal dihubungkan ke PortC.0. untuk sensor suhu LM35 dihubungkan ke PortA.0. lcd dihubungkan ke PORTB. jika berhasil maka servo akan berputar sesuai suhu yang terukur.