Hier einmal die Bedienoberfläche zu dem Programm :

Bild hier  

Und hier der VB Code :
Code:
Public Class Form1

    Dim Anzeigewert As String

    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        SerialPort1.Open()
    End Sub

    Private Sub cmdEingabe1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEingabe1.Click
        SerialPort1.Write(1)
    End Sub

    Private Sub cmdEingabe2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEingabe2.Click
        SerialPort1.Write(2)
    End Sub

    Private Sub cmdEingabe3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEingabe3.Click
        SerialPort1.Write(3)
    End Sub

    Private Sub cmdReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdReset.Click
        SerialPort1.Write("r")
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If SerialPort1.BytesToRead > 0 Then
            Do
                Anzeigewert = Chr(SerialPort1.ReadByte)
                txtAnzeige.AppendText(Anzeigewert)
                txtAnzeige.ScrollToCaret()
                If SerialPort1.BytesToRead = 0 Then
                    Exit Do
                End If
            Loop
        End If
    End Sub

End Class
Und der Basecom-AVR:
Code:
$prog , 255 , &B11011001 ,                                  'Quarz an / Teiler aus / Jtag aus

$regfile = "m2560def.dat"
$hwstack = 82                                               '80
$framesize = 68                                             ' 64
$swstack = 68                                               '44

$crystal = 16000000                                         'Quarzfrequenz

Config Pind.5 = Output
Led Alias Portd.5


Config Com4 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com4:" For Binary As #4                               'USB Buchse



Dim A As Byte
Led = 1

Do
   Inputbin #4 , A
   If A > 0 Then
       Select Case A
         Case 49                                            'Das ist der ASCII Code für Taste "1"
            Led = 0
            Print #4 , "LED = Ein"
         Case 50                                            'Das ist der ASCII Code für Taste "2"
            Led = 1
            Print #4 , "LED = Aus"
         Case 51                                            'Das ist der ASCII Code für Taste "3"
            Print #4 , "Taste 3 wurde gedrückt!"
         Case 114                                           'Das ist der ASCII Code für Taste "r"
            Print #4 , "Reset..."
            Goto 0
         Case Else
            Print #4 , "Error"
      End Select
   End If
Loop

End