atmel:relaycontrollersource

'********************************************************************
'* Port flipper
'*
'* Each port in the PORT array will be toggled HIGH/LOW and held for
'* a second - Useful for debugging.
'*
'* uP:          AT89S8313
'* Language:    BASCOM-AVR 1.11.7.4
'* Date:        2005.Feb.27
'* Version:     V1.00
'* Author:      Brett England
'********************************************************************
$regfile = "2313def.dat"
$crystal = 8000000
 
Dim Port(4) As Byte
Dim Currentport As Byte
Dim I As Byte
Dim J As Byte
 
Declare Sub Lcdlocation(byval Row As Byte , Byval Col As Byte)
 
' Set all Relays OFF
Port(1) = 2 : Port(2) = 3 : Port(3) = 4 : Port(4) = 7
For I = 1 To 4
  Set Portb.port(i)
Next I
 
'Serial connection to LCD is via Port B.6
'LCD runs at 9600 baud
Config Portb = Output
Open "comb.6:9600,8,n,1" For Output As #2
 
'LCD Reset pin is driven from PortB.5
Reset Portb.5                                               'Drive pin low
Waitms 400
Set Portb.5                                                 'Then high
Waitms 400
 
Currentport = 0
Do
  For J = 1 To 4                                            ' For each PORT
 
     If Currentport <> 0 Then                               ' Previous relay?
          Set Portb.currentport                             ' Turn Off
     End If
 
     Currentport = Port(j)                                  ' Next relay port
     Reset Portb.currentport                                ' Turn relay On
 
     Call Lcdlocation(0 , 0)
     Print #2 , "Timer: " ; J ;
 
     For I = 1 To 4                                         ' Print all status
       Call Lcdlocation(i , 0)
       Print #2 , "Port: " ; Port(i) ; " = " ; Portb.port(i) ;
     Next I
     Waitms 2500                                            ' Wait 2.5secs
  Next J
Loop
 
Sub Lcdlocation(byval Row As Byte , Byval Col As Byte)
  Col = Col + 32
  Row = Row + 32
  Print #2 , "\B" ; Chr(col) ; Chr(row);
End Sub
  • atmel/relaycontrollersource.txt
  • Last modified: 2009/11/27 17:53
  • by 127.0.0.1