سلام دوستان
من این ربات رو دارم هنوز برنامه حرفه ای براش ننوشتم میخواستم ببینم کسی برای این ربات برنامه نوشته یا نه؟!
اگر کسی برنامه حرفه ای براش نوشته منون میشم اپلود کنه
یا با همکاری هم یه برنامه حرفه ای براش بنویسیم
این برنامه نمونه برای این ربات هست که داخل سی دیش بود
از روی این برنامه میتونید تمام پورت هارو متوجه بشید که برای چی استفاده میشند
من این ربات رو دارم هنوز برنامه حرفه ای براش ننوشتم میخواستم ببینم کسی برای این ربات برنامه نوشته یا نه؟!
اگر کسی برنامه حرفه ای براش نوشته منون میشم اپلود کنه
یا با همکاری هم یه برنامه حرفه ای براش بنویسیم
این برنامه نمونه برای این ربات هست که داخل سی دیش بود
از روی این برنامه میتونید تمام پورت هارو متوجه بشید که برای چی استفاده میشند
/************************************************** ***
This program was produced by the
CodeWizardAVR V2.05.0 Advanced
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 5/16/2011
Author : www.Eca.ir *** www.Webkade.ir
Company :
Comments:
Chip type : ATmega16
Program type : Application
AVR Core Clock frequency: 16.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
************************************************** ***/
#include <mega16.h>
#include <delay.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
// Alphanumeric LCD Module functions
#include <lcd.h>
// Standard Input/Output functions
#include <stdio.h>
#define FIRST_ADC_INPUT 0
#define LAST_ADC_INPUT 7
unsigned char adc_data[LAST_ADC_INPUT-FIRST_ADC_INPUT+1];
#define ADC_VREF_TYPE 0x60
// ADC interrupt service routine
// with auto input scanning
interrupt [ADC_INT] void adc_isr(void)
{
static unsigned char input_index=0;
// Read the 8 most significant bits
// of the AD conversion result
adc_data[input_index]=ADCH;
// Select next ADC input
if (++input_index > (LAST_ADC_INPUT-FIRST_ADC_INPUT))
input_index=0;
ADMUX=(FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff))+input_index;
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
}
// Declare your global variables here
char buffer[20];
void main(void)
{
// Port D initialization
// Func7=In Func6=In Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=In
// State7=T State6=T State5=1 State4=1 State3=1 State2=1 State1=1 State0=T
PORTD=0x32;
DDRD=0xfE;
DDRB = 0xff;
// ADC initialization
// ADC Clock frequency: 500.000 kHz
// ADC Voltage Reference: AVCC pin
// ADC Auto Trigger Source: Free Running
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff);
ADCSRA=0xED;
SFIOR&=0x1F;
lcd_init(16);
lcd_puts("Robotic Trainer"
;
PORTB = 0x55;
delay_ms(500);
PORTB = 0xAA;
delay_ms(500);
PORTB = 0x55;
delay_ms(500);
PORTB = 0xAA;
delay_ms(500);
PORTB = 0;
#asm("sei"
while (1) {
if (adc_data[1]>100) PORTB.0 = 0;
else PORTB.0 = 1;
if (adc_data[2]>100) PORTB.1 = 0;
else PORTB.1 = 1;
if (adc_data[3]>100) PORTB.2 = 0;
else PORTB.2 = 1;
if (adc_data[4]>100) PORTB.3 = 0;
else PORTB.3 = 1;
if (adc_data[5]>100) PORTB.4 = 0;
else PORTB.4 = 1;
if (adc_data[6]>100) PORTB.5 = 0;
else PORTB.5 = 1;
if (adc_data[7]>100) PORTB.6 = 0;
else PORTB.6 = 1;
if (adc_data[0]>100) PORTB.7 = 0;
else PORTB.7 = 1;
if (adc_data[4]<100 && adc_data[5]<100) // 1 1 forward
{
PORTD &= 0x03;
PORTD |= 0xB8; // 10 11 10
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Forward"
;
}
else if (adc_data[0]<100 && adc_data[1]>100) // 1 0 Right
{
PORTD &= 0x03;
PORTD |= 0xB0; // 10 11 00
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Right "
;
}
else if (adc_data[0]>100 && adc_data[1]<100) // 0 1 Left
{
PORTD &= 0x03;
PORTD |= 0x38; // 00 11 10
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Left "
;
}
else // 0 0 Stop
{
PORTD &= 0x03;
PORTD |= 0x00; // 00 00 00
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Stop "
;
}
delay_ms(100);
}
}
This program was produced by the
CodeWizardAVR V2.05.0 Advanced
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 5/16/2011
Author : www.Eca.ir *** www.Webkade.ir
Company :
Comments:
Chip type : ATmega16
Program type : Application
AVR Core Clock frequency: 16.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
************************************************** ***/
#include <mega16.h>
#include <delay.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
// Alphanumeric LCD Module functions
#include <lcd.h>
// Standard Input/Output functions
#include <stdio.h>
#define FIRST_ADC_INPUT 0
#define LAST_ADC_INPUT 7
unsigned char adc_data[LAST_ADC_INPUT-FIRST_ADC_INPUT+1];
#define ADC_VREF_TYPE 0x60
// ADC interrupt service routine
// with auto input scanning
interrupt [ADC_INT] void adc_isr(void)
{
static unsigned char input_index=0;
// Read the 8 most significant bits
// of the AD conversion result
adc_data[input_index]=ADCH;
// Select next ADC input
if (++input_index > (LAST_ADC_INPUT-FIRST_ADC_INPUT))
input_index=0;
ADMUX=(FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff))+input_index;
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
}
// Declare your global variables here
char buffer[20];
void main(void)
{
// Port D initialization
// Func7=In Func6=In Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=In
// State7=T State6=T State5=1 State4=1 State3=1 State2=1 State1=1 State0=T
PORTD=0x32;
DDRD=0xfE;
DDRB = 0xff;
// ADC initialization
// ADC Clock frequency: 500.000 kHz
// ADC Voltage Reference: AVCC pin
// ADC Auto Trigger Source: Free Running
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=FIRST_ADC_INPUT | (ADC_VREF_TYPE & 0xff);
ADCSRA=0xED;
SFIOR&=0x1F;
lcd_init(16);
lcd_puts("Robotic Trainer"

PORTB = 0x55;
delay_ms(500);
PORTB = 0xAA;
delay_ms(500);
PORTB = 0x55;
delay_ms(500);
PORTB = 0xAA;
delay_ms(500);
PORTB = 0;
#asm("sei"

while (1) {
if (adc_data[1]>100) PORTB.0 = 0;
else PORTB.0 = 1;
if (adc_data[2]>100) PORTB.1 = 0;
else PORTB.1 = 1;
if (adc_data[3]>100) PORTB.2 = 0;
else PORTB.2 = 1;
if (adc_data[4]>100) PORTB.3 = 0;
else PORTB.3 = 1;
if (adc_data[5]>100) PORTB.4 = 0;
else PORTB.4 = 1;
if (adc_data[6]>100) PORTB.5 = 0;
else PORTB.5 = 1;
if (adc_data[7]>100) PORTB.6 = 0;
else PORTB.6 = 1;
if (adc_data[0]>100) PORTB.7 = 0;
else PORTB.7 = 1;
if (adc_data[4]<100 && adc_data[5]<100) // 1 1 forward
{
PORTD &= 0x03;
PORTD |= 0xB8; // 10 11 10
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Forward"

}
else if (adc_data[0]<100 && adc_data[1]>100) // 1 0 Right
{
PORTD &= 0x03;
PORTD |= 0xB0; // 10 11 00
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Right "

}
else if (adc_data[0]>100 && adc_data[1]<100) // 0 1 Left
{
PORTD &= 0x03;
PORTD |= 0x38; // 00 11 10
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Left "

}
else // 0 0 Stop
{
PORTD &= 0x03;
PORTD |= 0x00; // 00 00 00
_lcd_ready();
lcd_gotoxy(0,1);
lcd_putsf("Stop "

}
delay_ms(100);
}
}
دیدگاه