Andrianto.Heri,2008, Pemrograman Mikrokontroler AVR ATMega16, Penerbit Informatika. Bandung.
Budiharto, Widodo, 2008, Panduan Praktikum Mikrokontroler AVR ATMega 16.
Penerbit Elex media Komputindo. Jakarta.
Setiawan, afri, 2011, 20 Aplikasi Mikrokontroler ATMega8535 dan ATMega 16
Menggunakan Bascom-AVR,Penerbit Andi. Yogyakarta.
Pitowarno, Endra, 2006, Robotika: Desain,Kontrol,Kecerdasan Buatan.
Penerbit Andi .Yogyakarta.
http://www.atmel.com/pt/br/Images/doc2466.pdf http://www.LM35sensor.com/products/2201pdf.
https://www.sparkfun.com/datasheets/LCD/ADM1602K-NSA-FBS3.3v.pdf www.es.co.th/schemetic/pdf/YS1020.pdf
LAMPIRAN A
Program CODEVISIONAVR
Untuk program mikrokontroler pada Robot
/*****************************************************
Date : 8/24/2014
Chip type : ATmega16 Program type : Application AVR Core Clock frequency: 11.059200 MHz Memory model : Small
// Alphanumeric LCD functions
#include <alcd.h>
// Standard Input/Output functions
#include <stdio.h>
#define ADC_VREF_TYPE 0x40
// 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
//=========================================================
//Program FUNGSI Pergerakan / MANUVER ROBOT
//=========================================================
// 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=0x10;
// 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=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=P State2=T State1=T State0=T
PORTC=0x08;
DDRC=0x00;
// Port D 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
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xFF
// OC0 output: Disconnected TCCR0=0x00;
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=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On
// USART Transmitter: On // USART Mode: Asynchronous // USART Baud Rate: 9600
// 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: ADC Stopped
// Alphanumeric LCD initialization // Connections are specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
lcd_putsf(" -SUHU&GAS LPG- ");
delay_ms(2000);
//Program untuk menampilkan data GAS dan SUHU
//=========================================================
if(suhu>45) {buzzer=1; delay_ms(50); lcd_gotoxy(0,0);
lcd_putsf("Situasi BAHAYA ");}
else {lcd_gotoxy(0,0); lcd_putsf("Situasi AMAN ");}
buzzer=0; delay_ms(50);
//=========================================================
//Program untuk PERGERAKAN ROBOT
//=========================================================
if((UCSRA&0x80)==0x80) { data=getchar();
if (data=='a') {maju(); lcd_gotoxy(0,0); lcd_putsf(" --ROBOT MAJU-- ");}
else if(data=='b') {mundur(); lcd_gotoxy(0,0); lcd_putsf(" -ROBOT MUNDUR- ");}
else if(data=='c') {kanan(); lcd_gotoxy(0,0); lcd_putsf(" -ROBOT NGANAN- ");}
else if(data=='d') {kiri(); lcd_gotoxy(0,0); lcd_putsf(" --ROBOT KIRI-- ");}
else {stop(); } }
} }
Program VISUAL BASIC 2010
Untuk Tampilan Interface pada Komputer Imports System.Runtime.InteropServices Const WM_CAP_START = &H400S
Const WS_CHILD = &H40000000 Const WS_VISIBLE = &H10000000
Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10 Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11 Const WM_CAP_EDIT_COPY = WM_CAP_START + 30
Const WM_CAP_SEQUENCE = WM_CAP_START + 62 Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
Const WM_CAP_SET_SCALE = WM_CAP_START + 53
Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52 Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
Const SWP_NOMOVE = &H2S Const SWP_NOSIZE = 1 Const SWP_NOZORDER = &H4S Const HWND_BOTTOM = 1
DeclareFunction capGetDriverDescriptionA Lib"avicap32.dll" _ (ByVal wDriverIndex AsShort, _
ByVal lpszName AsString, ByVal cbName AsInteger, ByVal lpszVer AsString, _
ByVal cbVer AsInteger) AsBoolean
DeclareFunction capCreateCaptureWindowA Lib"avicap32.dll" _ (ByVal lpszWindowName AsString, ByVal dwStyle
AsInteger, _
ByVal x AsInteger, ByVal y AsInteger, ByVal nWidth AsInteger, _
ByVal nHeight AsShort, ByVal hWnd AsInteger, _ ByVal nID AsInteger) AsInteger
DeclareFunction SendMessage Lib"user32"Alias"SendMessageA" _ (ByVal hwnd AsInteger, ByVal Msg AsInteger, ByVal
ByVal hWndInsertAfter AsInteger, ByVal x AsInteger, ByVal y AsInteger, _
ByVal cx AsInteger, ByValcyAsInteger, ByVal wFlags AsInteger) AsInteger
DeclareFunction DestroyWindow Lib"user32" (ByVal hndw AsInteger) AsBoolean
Dim VideoSource AsInteger Dim hWnd AsInteger
PrivateSub Button_CONNECT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_CONNECT.Click
PrivateSub Form1_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load
myport = IO.Ports.SerialPort.GetPortNames() ComboBox1.Items.AddRange(myport)
Timer1.Enabled = True ListBox1.Items.Clear()
Dim DriverName AsString = Space(80) Dim DriverVersion AsString = Space(80) For i AsInteger = 0 To 9
IfcapGetDriverDescriptionA(i, DriverName, 80, DriverVersion, 80) Then
ListBox1.Items.Add(DriverName.Trim) EndIf
Next
b_maju.BackColor = Color.LightGray
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click VideoSource = ListBox1.SelectedIndex
SendMessage(hWnd, WM_CAP_DRIVER_DISCONNECT, VideoSource, 0) DestroyWindow(hWnd)
EndSub
PrivateSub start_cam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles start_cam.Click
SendMessage(hWnd, WM_CAP_DRIVER_DISCONNECT, VideoSource, 0) DestroyWindow(hWnd)
VideoSource = ListBox1.SelectedIndex
hWnd = capCreateCaptureWindowA(VideoSource, WS_VISIBLE Or WS_CHILD, 0, 0, 0, _
0, PictureBox1.Handle.ToInt32, 0)
IfSendMessage(hWnd, WM_CAP_DRIVER_CONNECT, VideoSource, 0) Then
SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0) SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0) SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0) SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _
PictureBox1.Width, PictureBox1.Height, _
PrivateSub Button_EXIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_EXIT.Click Close()
End
IfSerialPort1.IsOpen() = TrueThen SerialPort1.Close()
EndIf
EndSub
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
jam.Text = Format(Now, "hh:mm:ss") &" WIB"
Else : SerialPort1.Write(" ") EndIf
EndIf EndSub
PrivateSub SerialPort1_DataReceived(ByVal sender AsObject, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting()) EndSub
PrivateSubReceivedText(ByVal [text] AsString) 'input from ReadExisting
IfMe.lbl_serial.InvokeRequired Then
Dim x AsNewSetTextCallback(AddressOf ReceivedText) Me.Invoke(x, NewObject() {(text)})
Else
Me.serial_input = [text]
lbl_serial.Text = serial_input cek = Mid(serial_input, 1, 1)
If cek = "#"Then
Label2.Text = Mid(serial_input, 4, 2) &"
Celcius "
Label3.Text = Mid(serial_input, 11, 3) &"
ppm "
If Label2.Text > 45 Then
Label4.Text = "SITUASI BAHAYA"
Else
Label4.Text = "SITUASI AMAN"
EndIf
[text] = ""
serial_input = ""
PrivateSub b_kanan_MouseDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
b_kanan.MouseDown
b_kanan.BackColor = Color.Green c = 1
EndSub
PrivateSub b_kiri_MouseDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
b_kiri.MouseDown
b_kiri.BackColor = Color.Green d = 1
EndSub
PrivateSub b_maju_MouseDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
b_maju.MouseDown
b_maju.BackColor = Color.Green a = 1
EndSub
PrivateSub b_mundur_MouseDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
b_mundur.MouseDown
b_mundur.BackColor = Color.Green b = 1
EndSub
PrivateSub b_kanan_MouseUp(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles b_kanan.MouseUp b_kanan.BackColor = Color.LightGray
c = 0 EndSub
PrivateSub b_kiri_MouseUp(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles b_kiri.MouseUp b_kiri.BackColor = Color.LightGray
d = 0 EndSub
PrivateSub b_maju_MouseUp(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles b_maju.MouseUp b_maju.BackColor = Color.LightGray
a = 0 EndSub
PrivateSub b_mundur_MouseUp(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
b_mundur.MouseUp
b_mundur.BackColor = Color.LightGray b = 0
EndSub EndClass