Jump to content
ELFORUM - Forumul electronistilor

o sugestie daca stie cineva.....


Guest sandigol
 Share

Recommended Posts

Guest sandigol

Am programat in Bascom un atmega8 care sa imi afiseze pe un lcd diferite mesaje,insa vreu sa mai adaug inca un semafor cu doua culori verde si rosu care sa imi functioneze in acelasi timp cu afisarea mesajului de pe display.Nu imi dau seama ce instructiune sa folosesc sau daca se foloseste o intrerupere pentru ca sa imi poata rula ambele in acelasi timp.Mai am o intrebare ,am setat pinul c2 ca intrare iar atunci cand aplic 5V pe el(1 logic) in mod normal ar trebui sa imi afiseze mesajul pus in program dupa "else",insa nu se schimba nimic. Va rog daca ma puteti ajuta pentru ca am nevoie de program la licenta.Programul atasat:M$regfile = "m8def.dat" ' specify the used micro$crystal = 10000000 ' used crystal frequencyConfig Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.6 , Rs = Portd.7Dim A As ByteConfig Lcd = 16 * 2 'configure lcd screenCls 'clear the LCD displayconfig portc.2=inputConfig Portb = OutputPortb.1 = 1 ' make portB.0 highWait 3 ' wait 500msPortb.1 = 0 ' make Portb.0 LowWaitms 50 'wait 500msPortb.2 = 1Wait 3 'aici imi functioneaza semaforulPortb.2 = 0Waitms 50 Do 'de aici incepe afisarea pe display If Portc.2 = 0 ThenCls Wait 1 'wait a momentDisplay Off 'turn display offWait 1 'wait a momentDisplay OnLcd "Rampa deschisa." 'display this at the top lineWait 2Lowerline 'select the lower lineWait 1Lcd "Atentie la stop" 'display this at the lower lineWait 1 Cls Else Cls Lcd "rampa blocata" Wait 1 Lowerline Wait 1 Lcd "rute ocolitoare" Wait 1 End If Loop_temp1 = 1 'value into ACC!rCall _write_lcd 'put it on LCD end

Link to comment
Share on other sites

Ca sa aprinzi un led ar trebui pur si simplu sa scrii pinul respectiv si iesirea se mentine, nu cred ca trebuie sa faci o intrerupere.Cat priveste intrarea care nu functioneaza, eu observ ca se intampla ceva daca devine zero (sper ca am fost atent). Cred ca ai pull-ul, deci pinul este intotdeauna 1. Daca ii dai zero se intampla ceva? Vreau sa spun sa pui pinul la masa, nu sa il lasi in aer.

Link to comment
Share on other sites

Guest sandigol

Ideea este ca partea cu ledurile imi functioneaza dar eu vreau sa imi mearga in timp ce pe lcd imi afiseaza acele mesaje setate de mine.In ceea ce am atasat eu imi se aprind si sting o singura data ledurile dupa care trece la partea cu afisarea textului in timp ce ledurile raman stinse...

Link to comment
Share on other sites

$regfile = "m8def.dat" ' specify the used micro

$crystal = 10000000 ' used crystal frequency

Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.6 , Rs = Portd.7

Dim A As Byte

Config Lcd = 16 * 2 'configure lcd screen

Cls 'clear the LCD display

 

config portc.2=input

 

Config Portb = Output

Portb.1 = 1 ' make portB.0 high

Wait 3 ' wait 500ms

Portb.1 = 0 ' make Portb.0 Low

Waitms 50 'wait 500ms

Portb.2 = 1

Wait 3 'aici imi functioneaza semaforul

Portb.2 = 0

Waitms 50

 

Do 'de aici incepe afisarea pe display

If Portc.2 = 0 Then

Cls

Portb.1 = 1

Wait 1 'wait a moment

Display Off 'turn display off

Wait 1 'wait a moment

Display On

Lcd "Rampa deschisa." 'display this at the top line

Wait 2

Lowerline 'select the lower line

Wait 1

Lcd "Atentie la stop" 'display this at the lower line

Wait 1

Cls

Else

Cls

Lcd "rampa blocata"

Portb.1 = 0

Wait 1

Lowerline

Wait 1

Lcd "rute ocolitoare"

Wait 1

End If

Loop

_temp1 = 1 'value into ACC

!rCall _write_lcd 'put it on LCD

end

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...

Important Information

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.Terms of Use si Guidelines