User manual
PICkit™ Serial Analyzer DLL
© 2007 Microchip Technology Inc. DS51647A-page 99
10.4 PROGRAMMING EXAMPLE
The following is an example of creating a Visual Basic
®
.NET program using the dll to
read an I
2
C device.
1. In Solution Explorer, if References is not shown, press the Show All Files button.
2. Right click on references in solution explorer, browse to the PICkitS.dll and add it.
3. Double click the form to create Sub Form1_Load.
4. Add following to form1_load:
PICkitS.Basic.Initialize_PICkitSerial()
PICkitS.Basic.Configure_PICkitSerial_For_I2C()
5. On the Form1.vb [Design] view, click on the Events button in the Properties
Window.
6. Double click the FormClosed Event to create Sub Form1_FormClosed
7. Add the following line in Form1_FormClosed:
PICkitS.Basic.Cleanup()
8. On the form, add three text boxes and three labels as shown in the Figure 10-1
below.
FIGURE 10-1: TEXT BOXES AND LABELS
9. Name the text boxes as follows:
TextBox_Slave_Addr
TextBox_Word_Addr
TextBox_Result
10. Add a button, change the text to “Read One Byte” and double click it creating the
sub Button1_Click.
11. Add the following code to Button1_Click:
Dim Return_String AsString = vbNullString
Dim Return_Data(1) AsByte
Dim Slave_Addr AsByte = Convert.ToByte(TextBox_Slave_Addr.Text)
Dim Word_addr AsByte = Convert.ToByte(TextBox_Word_Addr.Text)