• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

parking

Status
Not open for further replies.

milimod

New Member
hi

Please help me to building a parking - avr atmega8



I need an input key called A. With each click, the number 5 decreases accordingly to reach 0

and need an input key called B. with each click, The number 0 increases to 5, respectively



Requires 5 keys so that:

5 characters named z1 z2 z3 z4 z5

z1 z2 z3 z4 z5 will be displayed by default,

Each key belongs to the control of a character.

For example: By pressing key 5, the character Z5 will be deleted the in the lcd



Please help to write this code in the CodeVisionAVR program



TANX
 

DerStrom8

Super Moderator
We are not here to do your homework for you. You need to do it yourself. Why are you even going to school if you have no interest in learning?
 

milimod

New Member
This is a personal task

This is also a file written by me:

<< Proteus + HEX file >>

and cod :


C:
#include <mega8.h>
#include <alcd.h>
#include <delay.h>
#include <stdio.h>

#define ddr    DDRD
#define port   PORTD
#define pin    PIND

#define pin_a   0
#define pin_b   1


#define pin_1   3
#define pin_2   4
#define pin_3   5
#define pin_4   6
#define pin_5   7


unsigned char number = 5;
char str[17];

void main(void)
{



ddr = 0x00;
port = 0xff;


lcd_init(16);

while(1)
    {
       if(pin == 0xff)
        {
            sprintf(str, "number = %d", number);
            lcd_gotoxy(0,0);
            lcd_puts(str);
            lcd_gotoxy(0, 1);
            lcd_puts("makan:A B C D E");
        }
        else if(!(pin & (1<<pin_a)))
        {
            delay_ms(100);
            if((!(pin & (1<<pin_a))) && (pin_b>0))
            {
            delay_ms(100);
                number--;

            }

        }
        else if(!(pin & (1<<pin_b)))
        {
            delay_ms(100);
            if((!(pin & (1<<pin_b))) && (pin_a<5))
            {
                number++;
            }
        }

        else if(!(pin & (1<<pin_1)))
        {
            delay_ms(100);
            if(!(pin & (1<<pin_1)))
            {
                lcd_gotoxy(6, 1);
                lcd_puts("  ");
            }
        }
        else if(!(pin & (1<<pin_2)))
        {
            delay_ms(100);
            if(!(pin & (1<<pin_2)))
            {
                lcd_gotoxy(7, 1);
                lcd_puts("  ");
            }
        }
        else if(!(pin & (1<<pin_3)))
        {
            delay_ms(100);
            if(!(pin & (1<<pin_3)))
            {
                lcd_gotoxy(9, 1);
                lcd_puts("  ");
            }
        }
        else if(!(pin & (1<<pin_4)))
        {
            delay_ms(100);
            if(!(pin & (1<<pin_4)))
            {
                lcd_gotoxy(11, 1);
                lcd_puts("  ");
            }
        }
        else
        {
            delay_ms(100);
            if(!(pin & (1<<pin_5)))
            {
                lcd_gotoxy(13, 1);
                lcd_puts("  ");
            }
        }

    }
}
 

DerStrom8

Super Moderator
So be specific, what is your problem? What issues are you having with your existing code?
 

milimod

New Member
I expect to reach zero = show in the LCD <Full capacity>
Highest number increase = just {5}

If the pins are closed, the numbers can not be changed by the pin_a and pin_b keys
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top