Mater
Code: Select all
Device = 18F4550
Clock = 20
Include "USART.bas"
Dim boton1 As PORTD.0
Dim boton2 As PORTD.1
Dim boton3 As PORTD.2
Dim boton4 As PORTD.3
SetBaudrate(br19200)
TRISD=%11111111
While true
If boton1=1 Then
USART.Write("A", 13, 10)
EndIf
If boton2=1 Then
USART.Write("B", 13, 10)
EndIf
If boton3=1 Then
USART.Write("C", 13, 10)
EndIf
If boton4=1 Then
USART.Write("D", 13, 10)
EndIf
Wend
Code: Select all
Device = 18F4550
Clock = 20
Include "USART.bas"
Dim dato As String
Dim LED1 As PORTD.0
Dim LED2 As PORTD.1
Dim LED3 As PORTD.2
Dim LED4 As PORTD.3
SetBaudrate(br19200)
ReadTerminator = 13
While true
If DataAvailable = true Then
USART.Read(dato)
If dato = "A" Then
High (LED1)
DelayMS (1000)
Low (LED1)
EndIf
If dato = "B" Then
High (LED2)
DelayMS (1000)
Low (LED2)
EndIf
If dato = "C" Then
High (LED3)
DelayMS (1000)
Low (LED3)
EndIf
If dato = "D" Then
High (LED4)
DelayMS (1000)
Low (LED4)
EndIf
EndIf
Wend