SlideShare a Scribd company logo
LAMPIRAN 1.PROGRAM ROBOT 
/********************************************* 
This program was produced by the 
CodeWizardAVR V1.24.0 Standard 
Automatic Program Generator 
© Copyright 1998-2003 HP InfoTech s.r.l. 
http://www.hpinfotech.ro 
e-mail:office@hpinfotech.ro 
Project : 
Version : 
Date : 17/11/2013 
Author : hendawan 
Company : 
Comments: 
Chip type : Atmega32 
Program type : Application 
Clock frequency : 12,000000 MHz 
Memory model : Small 
External SRAM size : 0 
Data Stack size : 128 
*********************************************/ 
#define SkiXX PIND.0 
#define SkiX PIND.1 
#define Ski PIND.2 
#define Ska PIND.3 
#define SkaX PIND.4 
#define SkaXX PIND.5
#define EnKi PORTC.4 
#define dirA_Ki PORTC.0 
#define dirB_Ki PORTC.1 
#define EnKa PORTC.5 
#define dirC_Ka PORTC.2 
#define dirD_Ka PORTC.3 
#include <mega8535.h> 
#include <delay.h> 
bit x; 
unsigned char xcount,lpwm,rpwm; 
// Timer 0 overflow interrupt service routine 
interrupt [TIM0_OVF] void timer0_ovf_isr(void) 
{ 
// Place your code here 
xcount++; 
if(xcount<=lpwm)EnKi=1; 
else EnKi=0; 
if(xcount<=rpwm)EnKa=1; 
else EnKa=0; 
TCNT0=0xFF; // Timer0 Value Menentukan periode pulsa PWM 
} 
void maju() 
{ 
dirA_Ki=1;dirB_Ki=0; 
dirC_Ka=1;dirD_Ka=0; 
} 
void belok_kiri() 
{
unsigned int i; 
lpwm=50; rpwm=50; 
delay_ms(60); // dimajukan sedikit 
dirA_Ki=0;dirB_Ki=1; 
dirC_Ka=1;dirD_Ka=0; 
for(i=0;i<=1000;i++) while (!SkiXX ||!SkiX) {}; 
for(i=0;i<=1000;i++) while ( SkiXX || SkiX) {}; 
lpwm=0; rpwm=0; 
} 
void belok_kanan() 
{ 
unsigned int i; 
lpwm=50; rpwm=50; 
delay_ms(60); // dimajukan sedikit 
dirA_Ki=1;dirB_Ki=0; 
dirC_Ka=0;dirD_Ka=1; 
for(i=0;i<=1000;i++) while (!SkaXX ||!SkaX) {}; 
for(i=0;i<=1000;i++) while ( SkaXX || SkaX) {}; 
lpwm=0; rpwm=0; 
} 
// Declare your global variables here 
unsigned char sensor; 
void scan_rule1() 
{ maju(); 
sensor=PIND; 
sensor&=0b00111111; 
switch(sensor) 
{ case 0b00111110: rpwm=0; lpwm=200; x=1; break;
case 0b00111100: rpwm=50; lpwm=200; x=1; break; 
case 0b00111101: rpwm=75; lpwm=200; x=1; break; 
case 0b00111001: rpwm=100; lpwm=200; x=1; break; 
case 0b00111011: rpwm=150; lpwm=200; x=1; break; 
case 0b00110011: rpwm=200; lpwm=200; break; 
case 0b00110111: rpwm=200; lpwm=150; x=0; break; 
case 0b00100111: rpwm=200; lpwm=100; x=0; break; 
case 0b00101111: rpwm=200; lpwm=75; x=0; break; 
case 0b00001111: rpwm=200; lpwm=50; x=0; break; 
case 0b00011111: rpwm=200; lpwm=0; x=0; break; 
case 0b00111111: break; 
if(x) {lpwm=50; rpwm=0; break;} 
else {lpwm=0; rpwm=50; break;} 
} 
} 
void scan_count(unsigned char count) 
{ 
unsigned int i; 
unsigned char xx=0; 
while(xx<count) 
{ for(i=0;i<1000;i++) while((sensor & 0b00011110)!=0b00000000) scan_rule1(); 
for(i=0;i<1000;i++) while((sensor & 0b00011110)==0b00000000) scan_rule1(); 
xx++; 
} 
} 
void main(void) 
{ 
// Declare your local variables here
// Input/Output Ports initialization 
// Port A initialization 
// Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In 
// State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T 
PORTA=0x00; 
DDRA=0x00; 
// Port B initialization 
// Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In 
// State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T 
PORTB=0x00; 
DDRB=0x00; 
// Port C initialization 
// Func0=Out Func1=Out Func2=Out Func3=Out Func4=Out Func5=Out Func6=Out Func7=Out 
// State0=0 State1=0 State2=0 State3=0 State4=0 State5=0 State6=0 State7=0 
PORTC=0x00; 
DDRC=0xFF; 
// Port D initialization 
// Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In 
// State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P 
PORTD=0xFF; 
DDRD=0x00; 
// Timer/Counter 0 initialization 
// Clock source: System Clock 
// Clock value: 10,800 kHz 
// Mode: Normal top=FFh 
// OC0 output: Disconnected 
TCCR0=0x05; 
TCNT0=0x00;
OCR0=0x00; 
// Timer/Counter 1 initialization 
// Clock source: System Clock 
// Clock value: Timer 1 Stopped 
// Mode: Normal top=FFFFh 
// OC1A output: Discon. 
// OC1B output: Discon. 
// Noise Canceler: Off 
// Input Capture on Falling Edge 
TCCR1A=0x00; 
TCCR1B=0x00; 
TCNT1H=0x00; 
TCNT1L=0x00; 
OCR1AH=0x00; 
OCR1AL=0x00; 
OCR1BH=0x00; 
OCR1BL=0x00; 
// Timer/Counter 2 initialization 
// Clock source: System Clock 
// Clock value: Timer 2 Stopped 
// Mode: Normal top=FFh 
// 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; 
// Analog Comparator initialization 
// Analog Comparator: Off 
// Analog Comparator Input Capture by Timer/Counter 1: Off 
// Analog Comparator Output: Off 
ACSR=0x80; 
SFIOR=0x00; 
// Global enable interrupts 
#asm("sei") 
while (1) 
{ 
// Place your code here 
scan_count(3); 
belok_kanan(); 
}; 
}

More Related Content

PPTX
Home automation system
PDF
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
TXT
Ir remote kit_blink.pde
PDF
PWM based motor speed control using LPC 1768
PDF
PDF
Código ASM para LCD Microcontrolador PIC
PPT
Uart VHDL RTL design tutorial
PDF
74ls74 d
Home automation system
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
Ir remote kit_blink.pde
PWM based motor speed control using LPC 1768
Código ASM para LCD Microcontrolador PIC
Uart VHDL RTL design tutorial
74ls74 d

What's hot (20)

DOCX
Uart
PPT
Solution on Portable Blood Pressure Monitor System
PDF
DDAA FPGA - Multiplexor De Numeros en Display 7 Segmentos En Tiempo
PDF
Timer 0 programming on LPC 1768
ODP
FPGA Tutorial - LCD Interface
PDF
UART MCU
PDF
Handling Interrupts in Microchip MCUs
PDF
Apple 1 manual & warranty 1976
PPTX
FAR/MARS Avionics CDR
PDF
Handling Asynchronous Events in MCUs
PDF
Sua chua may lanh cua daikin
PDF
The Emerald Datasheet
PDF
Guia de configuracao_ms9520
PDF
Exception handling on the x86
PDF
Exception handling on the x86
PDF
Things you should know for network programming
PDF
Mitsubachi Arduino code
PDF
Keyless Door Entry via Bluetooth Technology
PDF
Affinity quick start guide issue 3
Uart
Solution on Portable Blood Pressure Monitor System
DDAA FPGA - Multiplexor De Numeros en Display 7 Segmentos En Tiempo
Timer 0 programming on LPC 1768
FPGA Tutorial - LCD Interface
UART MCU
Handling Interrupts in Microchip MCUs
Apple 1 manual & warranty 1976
FAR/MARS Avionics CDR
Handling Asynchronous Events in MCUs
Sua chua may lanh cua daikin
The Emerald Datasheet
Guia de configuracao_ms9520
Exception handling on the x86
Exception handling on the x86
Things you should know for network programming
Mitsubachi Arduino code
Keyless Door Entry via Bluetooth Technology
Affinity quick start guide issue 3
Ad

Viewers also liked (6)

PDF
A3 planta baixa térreo
PPTX
Residencial Salinas
PDF
Projeto eletrico pdf
PDF
Hydros V4 - Incêndio
PDF
Planta baixa para projeto elétrico iluminação a4 layout1
PDF
Apostila CEFET - Instalações Elétricas
A3 planta baixa térreo
Residencial Salinas
Projeto eletrico pdf
Hydros V4 - Incêndio
Planta baixa para projeto elétrico iluminação a4 layout1
Apostila CEFET - Instalações Elétricas
Ad

Similar to Lampiran 1.programdocx (20)

PDF
What will be quantization step size in numbers and in voltage for th.pdf
DOCX
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
PPTX
LCD_Example.pptx
PDF
Combine the keypad and LCD codes in compliance to the following requ.pdf
PPT
W8_2: Inside the UoS Educational Processor
DOCX
Dam gate open close lpc prog
DOC
FINISHED_CODE
PPT
Data Acquisition
PDF
0.my book draft chap 1
TXT
PIC and LCD
ODP
Fpga creating counter with internal clock
PDF
selected input/output - sensors and actuators
PDF
CC2500 Wireless Trans-receiver Module
PDF
Product catlog
DOCX
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
PPTX
Embedded JavaScript
PDF
VHDL Practical Exam Guide
PDF
Vhdl practical exam guide
PPT
Em s7 plc
PDF
Assembly programming II
What will be quantization step size in numbers and in voltage for th.pdf
eece237lab2EECE237Lab2.uvproj 1.1 ### uVision .docx
LCD_Example.pptx
Combine the keypad and LCD codes in compliance to the following requ.pdf
W8_2: Inside the UoS Educational Processor
Dam gate open close lpc prog
FINISHED_CODE
Data Acquisition
0.my book draft chap 1
PIC and LCD
Fpga creating counter with internal clock
selected input/output - sensors and actuators
CC2500 Wireless Trans-receiver Module
Product catlog
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
Embedded JavaScript
VHDL Practical Exam Guide
Vhdl practical exam guide
Em s7 plc
Assembly programming II

More from Lugik kristiyanto (6)

DOCX
Lampiran 3 datasheet
DOCX
Lampiran 2 rangkaian
DOCX
Kata pengantar
DOCX
Daftar isi
DOCX
Komponen elektromekanik
Lampiran 3 datasheet
Lampiran 2 rangkaian
Kata pengantar
Daftar isi
Komponen elektromekanik

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
01-Introduction-to-Information-Management.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Computing-Curriculum for Schools in Ghana
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Pre independence Education in Inndia.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Institutional Correction lecture only . . .
PPTX
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Microbial diseases, their pathogenesis and prophylaxis
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Complications of Minimal Access Surgery at WLH
01-Introduction-to-Information-Management.pdf
O7-L3 Supply Chain Operations - ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Renaissance Architecture: A Journey from Faith to Humanism
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Computing-Curriculum for Schools in Ghana
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pre independence Education in Inndia.pdf
Cell Structure & Organelles in detailed.
Institutional Correction lecture only . . .
Final Presentation General Medicine 03-08-2024.pptx

Lampiran 1.programdocx

  • 1. LAMPIRAN 1.PROGRAM ROBOT /********************************************* This program was produced by the CodeWizardAVR V1.24.0 Standard Automatic Program Generator © Copyright 1998-2003 HP InfoTech s.r.l. http://www.hpinfotech.ro e-mail:office@hpinfotech.ro Project : Version : Date : 17/11/2013 Author : hendawan Company : Comments: Chip type : Atmega32 Program type : Application Clock frequency : 12,000000 MHz Memory model : Small External SRAM size : 0 Data Stack size : 128 *********************************************/ #define SkiXX PIND.0 #define SkiX PIND.1 #define Ski PIND.2 #define Ska PIND.3 #define SkaX PIND.4 #define SkaXX PIND.5
  • 2. #define EnKi PORTC.4 #define dirA_Ki PORTC.0 #define dirB_Ki PORTC.1 #define EnKa PORTC.5 #define dirC_Ka PORTC.2 #define dirD_Ka PORTC.3 #include <mega8535.h> #include <delay.h> bit x; unsigned char xcount,lpwm,rpwm; // Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isr(void) { // Place your code here xcount++; if(xcount<=lpwm)EnKi=1; else EnKi=0; if(xcount<=rpwm)EnKa=1; else EnKa=0; TCNT0=0xFF; // Timer0 Value Menentukan periode pulsa PWM } void maju() { dirA_Ki=1;dirB_Ki=0; dirC_Ka=1;dirD_Ka=0; } void belok_kiri() {
  • 3. unsigned int i; lpwm=50; rpwm=50; delay_ms(60); // dimajukan sedikit dirA_Ki=0;dirB_Ki=1; dirC_Ka=1;dirD_Ka=0; for(i=0;i<=1000;i++) while (!SkiXX ||!SkiX) {}; for(i=0;i<=1000;i++) while ( SkiXX || SkiX) {}; lpwm=0; rpwm=0; } void belok_kanan() { unsigned int i; lpwm=50; rpwm=50; delay_ms(60); // dimajukan sedikit dirA_Ki=1;dirB_Ki=0; dirC_Ka=0;dirD_Ka=1; for(i=0;i<=1000;i++) while (!SkaXX ||!SkaX) {}; for(i=0;i<=1000;i++) while ( SkaXX || SkaX) {}; lpwm=0; rpwm=0; } // Declare your global variables here unsigned char sensor; void scan_rule1() { maju(); sensor=PIND; sensor&=0b00111111; switch(sensor) { case 0b00111110: rpwm=0; lpwm=200; x=1; break;
  • 4. case 0b00111100: rpwm=50; lpwm=200; x=1; break; case 0b00111101: rpwm=75; lpwm=200; x=1; break; case 0b00111001: rpwm=100; lpwm=200; x=1; break; case 0b00111011: rpwm=150; lpwm=200; x=1; break; case 0b00110011: rpwm=200; lpwm=200; break; case 0b00110111: rpwm=200; lpwm=150; x=0; break; case 0b00100111: rpwm=200; lpwm=100; x=0; break; case 0b00101111: rpwm=200; lpwm=75; x=0; break; case 0b00001111: rpwm=200; lpwm=50; x=0; break; case 0b00011111: rpwm=200; lpwm=0; x=0; break; case 0b00111111: break; if(x) {lpwm=50; rpwm=0; break;} else {lpwm=0; rpwm=50; break;} } } void scan_count(unsigned char count) { unsigned int i; unsigned char xx=0; while(xx<count) { for(i=0;i<1000;i++) while((sensor & 0b00011110)!=0b00000000) scan_rule1(); for(i=0;i<1000;i++) while((sensor & 0b00011110)==0b00000000) scan_rule1(); xx++; } } void main(void) { // Declare your local variables here
  • 5. // Input/Output Ports initialization // Port A initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T PORTA=0x00; DDRA=0x00; // Port B initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func0=Out Func1=Out Func2=Out Func3=Out Func4=Out Func5=Out Func6=Out Func7=Out // State0=0 State1=0 State2=0 State3=0 State4=0 State5=0 State6=0 State7=0 PORTC=0x00; DDRC=0xFF; // Port D initialization // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P PORTD=0xFF; DDRD=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: 10,800 kHz // Mode: Normal top=FFh // OC0 output: Disconnected TCCR0=0x05; TCNT0=0x00;
  • 6. OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer 1 Stopped // Mode: Normal top=FFFFh // OC1A output: Discon. // OC1B output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer 2 Stopped // Mode: Normal top=FFh // OC2 output: Disconnected ASSR=0x00; TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization // INT0: Off
  • 7. // INT1: Off // INT2: Off MCUCR=0x00; MCUCSR=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x01; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off // Analog Comparator Output: Off ACSR=0x80; SFIOR=0x00; // Global enable interrupts #asm("sei") while (1) { // Place your code here scan_count(3); belok_kanan(); }; }