Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Gestione input PIC 16f

Raccolta di codici sorgenti

Moderatore: Foto UtentePaolino

0
voti

[21] Re: Gestione input PIC 16f

Messaggioda Foto Utentemaxtronic » 13 feb 2013, 19:22

Provo a fare come hai scritto e ti farò sapere al + presto
grazie
Avatar utente
Foto Utentemaxtronic
0 4
 
Messaggi: 22
Iscritto il: 30 gen 2013, 0:43

0
voti

[22] Re: Gestione input PIC 16f

Messaggioda Foto Utentemaxtronic » 16 feb 2013, 0:38

fatto tutto , solo un problema .... se pigio un pulsante è ok ma se lo lascio non si spegne il led corrispondente . Poi se premo un pulsante e lo tengo premuto , l'altro gioco di luci parte e non si ferma . ti posto il listato . se puoi prova sia il primo che ho fatto così magari riesci a capire cosa devo fare .

program lightcontrol
dim controllo as byte[6]
dim k as byte
sub procedure gioco0
portb.2=1
delay_ms(100)
portb.3=1
delay_ms(100)
portb.4=1
delay_ms(100)
portb.5=1
delay_ms(100)
portb.6=1
delay_ms(100)
portb.7=1
delay_ms(100)
portb=0
portb.2=1
end sub
sub procedure gioco1
portb.3=1
delay_ms(100)
portb.2=1
portb.4=1
delay_ms(100)
portb.5=1
delay_ms(100)
portb.6=1
delay_ms(100)
portb.7=1
delay_ms(100)
portb=0
portb.3=1
end sub
sub procedure gioco2
portb.4=1
delay_ms(100)
portb.3=1
portb.5=1
delay_ms(100)
portb.2=1
portb.6=1
delay_ms(100)
portb.7=1
delay_ms(100)
portb=0
portb.4=1
end sub
sub procedure gioco3
portb.5=1
delay_ms(100)
portb.4=1
portb.6=1
delay_ms(100)
portb.3=1
portb.7=1
delay_ms(100)
portb.2=1
delay_ms(100)
portb=0
portb.5=1
end sub
sub procedure gioco4
portb.6=1
delay_ms(100)
portb.5=1
portb.7=1
delay_ms(100)
portb.4=1
delay_ms(100)
portb.3=1
delay_ms(100)
portb.2=1
delay_ms(100)
portb=0
portb.6=1
end sub
sub procedure gioco5
portb.7=1
delay_ms(100)
portb.6=1
delay_ms(100)
portb.5=1
delay_ms(100)
portb.4=1
delay_ms(100)
portb.3=1
delay_ms(100)
portb.2=1
delay_ms(100)
portb=0
portb.7=1
end sub



main:
trisa=%11111
trisb=%00000011
porta=0
portb=0

for k = 0 to 5
controllo[k] = 0
next k

while true

if (porta.0 = 1) then
if controllo[0] = 0 then
gioco0
controllo[0] = 1
controllo[1] = 0 '
controllo[2] = 0
controllo[3] = 0
controllo[4] = 0
controllo[5] = 0
end if
end if


if (porta.1 = 1) then
if controllo[1] = 0 then
gioco1
controllo[0] = 0
controllo[1] = 1
controllo[2] = 0
controllo[3] = 0
controllo[4] = 0
controllo[5] = 0
end if
end if
if (porta.2 = 1) then
if controllo[2] = 0 then
gioco2
controllo[0] = 0
controllo[1] = 0
controllo[2] = 1
controllo[3] = 0
controllo[4] = 0
controllo[5] = 0
end if
end if
if (porta.3 = 1) then
if controllo[3] = 0 then
gioco3
controllo[0] = 0
controllo[1] = 0
controllo[2] = 0
controllo[3] = 1
controllo[4] = 0
controllo[5] = 0
end if
end if
if (porta.4 = 1) then
if controllo[4] = 0 then
gioco4
controllo[0] = 0
controllo[1] = 0
controllo[2] = 0
controllo[3] = 0
controllo[4] = 1
controllo[5] = 0
end if
end if
if (portb.0 = 1) then
if controllo[5] = 0 then
gioco5
controllo[0] = 0
controllo[1] = 0
controllo[2] = 0
controllo[3] = 0
controllo[4] = 0
controllo[5] = 1
end if
end if

wend

end.
Avatar utente
Foto Utentemaxtronic
0 4
 
Messaggi: 22
Iscritto il: 30 gen 2013, 0:43

0
voti

[23] Re: Gestione input PIC 16f

Messaggioda Foto Utentemaxtronic » 24 feb 2013, 23:34

HELP
Avatar utente
Foto Utentemaxtronic
0 4
 
Messaggi: 22
Iscritto il: 30 gen 2013, 0:43

0
voti

[24] Re: Gestione input PIC 16f

Messaggioda Foto UtenteDryden » 25 feb 2013, 13:57

Scusa ma non riesco bene a capire quale è il problema...

Comunque, hai aggiornato la versione di mikrobasic?? te lo chiedo perché potrebbe essere un bug del programma....
Avatar utente
Foto UtenteDryden
20 4
New entry
New entry
 
Messaggi: 97
Iscritto il: 1 gen 2011, 14:37
Località: Bolzano

0
voti

[25] Re: Gestione input PIC 16f

Messaggioda Foto Utentemaxtronic » 25 feb 2013, 18:10

non posso aggiornarlo per adesso . :(
Avatar utente
Foto Utentemaxtronic
0 4
 
Messaggi: 22
Iscritto il: 30 gen 2013, 0:43

Precedente

Torna a Firmware e programmazione

Chi c’è in linea

Visitano il forum: Nessuno e 5 ospiti