46
Електроника / Питане за схема на H-мост
« -: Април 12, 2009, 09:48:30 pm »
Мерси за доброто обяснение !
От тук може да видиш всички публикации на този потребител.
#include <avr/io.h>
#include <avr/delay.h>
#define F_CPU 4000000UL
int main(void)
{
DDRD = 0xff;
DDRC = 0x00;
PORTD|=_BV(PD1);
while(1)
{
while (!(PINC&(1<<PC5)))
{
if(PINC&(1<<PC5))
{
PORTD&=~_BV(PD1);
PORTD|=_BV(PD2);
}
}
while(!(PINC&(1<<PC5)))
{
if(PINC&(1<<PC5))
{
PORTD&=~_BV(PD2);
PORTD|=_BV(PD1);
}
}
}
}
#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 4000000UL
int main(void)
{
DDRD = 0xff;
DDRC = 0x00;
PORTD |= _BV(PD1);
PORTD &= ~_BV(PD2);
while(1)
{
if (PINC&_BV(PC5))
{
if (PORTD&_BV(PD1))
{
PORTD |= _BV(PD2);
PORTD &= ~_BV(PD1);
}
else
{
PORTD |= _BV(PD1);
PORTD &= ~_BV(PD2);
}
while (PINC&_BV(PC5));
}
}
}
#include <avr/io.h>
#include <avr/delay.h>
#define F_CPU 4000000UL
int main(void)
{
DDRD=0xff;
DDRC=0x00;
while (1) {
if (PINC&(1<<PC5))
{
PORTD|=_BV(PD1);
}
}
}