سلام دوستان،یه برنامه واسه کنترل سطح اب نوشتم که وقتی اب مخزن کم شد پمپ روشن شه ،حالا این مدارو در شبیه ساز میبندم کار میکنه،ولی وقتی در عمل میبندم،فقط وصلشو میفهمه،مشکل از کجای کاره؟
این از کدی که نوشتم:
اینم عکس شبیه ساز:
ممنون میشم کمکم کنید
این از کدی که نوشتم:
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=ifndef"]#ifndef[/URL] F_CPU
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=define"]#define[/URL] F_CPU 1000000UL /* CPU CLOCK FREQUENCY */
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=endif"]#endif[/URL]
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL] <avr/io.h>
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL] <stdlib.h>
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL] <stdio.h>
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL] <util/delay.h>
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL] <avr/interrupt.h>
[URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL] "LCD16x2_4bit.h"
volatile int readLevel=0;
ISR(TIMER2_COMP_vect){
readLevel = PINB & 0x03;
switch(readLevel)
{
case 0x00:
PORTD &= ~(1<<6);
break;
case 0x02:
PORTD |= (1<<6);
break;
case 0x03:
PORTD |= (1<<6);
break;
default:
PORTD &= ~(1<<6);
}
}
int main(void)
{
lcdinit();
DDRD = 0b01010011;
PORTD = 0b00000000;
DDRB = 0b00000000;
PORTB = 0b00000000;
TCCR2 |= (1 << WGM01) | (1 << CS00) | (1 << CS02);
OCR2 = 0x60;
TIFR |= (1 << OCF2);
TIMSK |= (1 << OCIE2);
TCNT2 = 0;
while(1)
{
[FONT=Yekan] [/FONT]
}
}
اینم عکس شبیه ساز:
ممنون میشم کمکم کنید
دیدگاه