logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

[BASCOM][ATMEGA-8] problem z programikiem

Lukaszinfer 26 Cze 2009 18:28 1727 9
REKLAMA
  • #1 6706989
    Lukaszinfer
    Poziom 12  
    Witam,

    mam problem z napisaniem programiku w jezyku bascom dla nastepujacej komendy:

    Jeżeli switch (np. PB1) jest ON (do atmegi idzie minus) przez 5 sekund
    to
    np.dioda (np.PB0) jest ON

    Za pomoc bede bardzo wdzieczny i odwdziecze sie w postaci paru PKT
  • REKLAMA
  • REKLAMA
  • #3 6707318
    Lukaszinfer
    Poziom 12  
    ok dzieki + 10 pkt
  • REKLAMA
  • #5 6707399
    Lukaszinfer
    Poziom 12  
    ale ten pinb.5 to pomyłka czy tak ma byc
  • REKLAMA
  • #7 6707561
    Lukaszinfer
    Poziom 12  
    a moze znacie jeszcze jakies inne pomysly
    moze podam moj programik

    
    $regfile = "m8def.dat"
    $crystal = 1000000
    Config Portb = &B11111101
           Portb = &B11111111
    Config Portc = &B1111111
            Portc = &B1111111
    Config Portd = &B11111111
          Portd = &B11111111
    
    Do
    If Pinb.1 = 0 Then                                          'jesli switch press
    Portd.1 = 0                                                 'dioda zielona ON
    Portc.0 = 1                                                 'przekaznik ON
    Portc.5 = 1                                                 'buzzer ON
    Portd.0 = 1                                                 'dioda czerwona OFF
    Waitms 200
    
    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 30
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 10
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100
    
    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100
    
    Portc.0 = 0                                                 'przekaznik OFF
    Portc.5 = 0                                                 'buzzer OFF
    Portd.1 = 1                                                 'dioda zielona OFF
    Portd.0 = 0                                                 'dioda czerwona ON
    End If
    
    If Pinb.1 = 1 Then                                          'jesli switch OFF
    Portc.0 = 0                                                 'przekażnik OFF
    Portc.5 = 0                                                 'buzzer OFF
    Portd.1 = 1                                                 'dioda zielona OFF
    Portd.0 = 0                                                 'dioda czerwona ON
    End If
    
    Loop
    
    '***** c.0 przekaznik   *****
    '***** c.5 buzzer       *****
    '***** d.0 dioda czerwona        *****
    '***** d.1 dioda zielona *****
    '***** b.1 switch       *****
    '***** 0 OFF 1 ON       *****
    



    i teraz chce aby:
    jeśli switch jest ON przez 5 sekund to
    przekaznik OFF
    buzzer OFF
    dioda zielona OFF
    dioda czerwona ON


    a jesli chodzi o moj programik to jestem poczatkujacym elektronikiemi narazie w bascomie umiem podstawowe komendy
  • #8 6708090
    wicy
    Poziom 22  
    
    If pinb.1=0 then
       wait 5
       if pinb.1=0 then 
          Portc.0 = 0
          Portc.5 = 0
          Portd.1 = 0                               
          Portd.0 = 1
       end if
    end if 
  • #9 6708630
    Lukaszinfer
    Poziom 12  
    $regfile = "m8def.dat"
    $crystal = 1000000
    Config Portb = &B11111101
    Portb = &B11111111
    Config Portc = &B1111111
    Portc = &B1111111
    Config Portd = &B11111111
    Portd = &B11111111

    Do
    If Pinb.1 = 0 Then 'jesli switch press
    Portd.1 = 0 'dioda zielona ON
    Portc.0 = 1 'przekaznik ON
    Portc.5 = 1 'buzzer ON
    Portd.0 = 1 'dioda czerwona OFF
    Waitms 200

    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 60
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 30
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 10
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100

    Portc.5 = 0
    Wait 5
    Portc.5 = 1
    Waitms 100

    Portc.0 = 0 'przekaznik OFF
    Portc.5 = 0 'buzzer OFF
    Portd.1 = 1 'dioda zielona OFF
    Portd.0 = 0 'dioda czerwona ON
    End If

    If Pinb.1 = 1 Then 'jesli switch OFF
    Portc.0 = 0 'przekażnik OFF
    Portc.5 = 0 'buzzer OFF
    Portd.1 = 1 'dioda zielona OFF
    Portd.0 = 0 'dioda czerwona ON
    End If

    If Pinb.1 = 0 Then 'jesli switch ON
    Wait 2 'przez 2 sekundy
    If Pinb.1 = 0 Then 'jesli switch nadal ON
    Portc.0 = 0 'przekaznik OFF
    Portc.5 = 0 'buzzer OFF
    Portd.1 = 1 'dioda zielona OFF
    Portd.0 = 0 'dioda czerwona ON
    end if
    End If

    Loop

    '***** c.0 przekaznik *****
    '***** c.5 buzzer *****
    '***** d.0 dioda czerwona *****
    '***** d.1 dioda zielona *****
    '***** b.1 switch *****
    '***** 0 OFF 1 ON



    cos takiego nie dziala
REKLAMA