Jump to content
array

parque de estacionamento

Recommended Posts

array

#include<avr/io.h>
#include<avr/interrupt.h>
unsigned char carro , temporiz;

#include <avr/bit_tools.h>
ISR(INT0_vect)
{
bit_set(PORTD,0);
TCCR0=0x05; //ck/1024 ----> 32ms entre int.
carro++;
}


ISR(INT1_vect)
{
 carro--;
}


ISR(TIMER0_ovf_vect) //32 ms
{
--temporiz;
if (temporiz == 0)
{
  temporiz = 156;
  bit_clear(PORTC,0);
  TCCR0=0;
}
}

int main(void)
{
temporiz = 156;
PORTC=0x00;//cancela
PORTB=0xFF;// entra carro
PORTD=0xFF;//sai carro
DDRA=0xFF;
GIMSK=0xC0;
MCUCR=0x0A;
sei();
while(1)
{
if (PINB>PIND)
{	

carro++;//entra carro
  if(carro==10)
 carro=0;
}
if (PINB<PIND)
{

carro--;// sai carro
if(carro==0)
 carro=9;
}
}
}

alguem me poderia ajudar.

quando corro o programa e fica aepanas a correr quando entra carro e sai carro.

Share this post


Link to post
Share on other sites
HappyHippyHippo

é assim ... isso tem aspecto de código de comunicação com algum tipo de electrónica que nem faço ideia a de que seja, mas ...

#include<avr/io.h>
int main(void)
{
 // ..
 while(1) // <--------- ciclo infinito ?? como esperas sair desta ?
 {
   // ..
 }
}

fica aepanas a correr quando entra carro e sai carro.


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.