Erii Visual Basic1
Erii Visual Basic1
Erii Visual Basic1
• Administration:
o Prayer
• Sending Byte Data to a Microcontroller:
o In this lesson we are going use Visual Basic.NET to send data in the form of
a byte array to a PIC microcontroller and have the microcontroller control
output devices. The PIC microcontroller is programmed in PicBasic Pro.
• PicBasic Pro and Visual Basic Programs Used in This Lesson:
o General PicBasic Pro Program Listing:
http://www.cornerstonerobotics.org/picbasic.php
o Lab 1 PicBasic Pro program, pbp_vb_led1 as .pdf file:
http://cornerstonerobotics.org/code/pbp_vb_led1.pdf
o Lab 1 Visual Basic.NET program, vb_led1 as .pdf file:
http://cornerstonerobotics.org/code/vb_led1.pdf
o Lab 2 PicBasic Pro program, pbp_vb_servo1 as .pdf file:
http://cornerstonerobotics.org/code/pbp_vb_servo1.pdf
o Lab 2 Visual Basic.NET program, vb_servo1 as .pdf file:
http://cornerstonerobotics.org/code/vb_servo1.pdf
• Software:
o Visual Basic 2008 Express Edition:
Visual Basic 2008 Express Edition is available free online at:
http://www.microsoft.com/express/download/ (Requires XP or
greater.)
Free Visual Basic.NET tutorials:
• http://www.homeandlearn.co.uk/NET/vbNET.html
• http://www.functionx.com/vbnet/index.htm
• http://msdn.microsoft.com/en-us/vbasic/bb466159.aspx
o PicBasic Pro:
PicBasic Pro is available from micro-Engineering Labs, Inc.,
melabs.com. We prefer the melabs U2 Programmer over the EPIC
Programmer. Both programmers are displayed at:
http://melabs.com/products/bundles.htm. The cost for both the
PicBasic Pro Compiler and the U2 Programmer with Accessories is
$359.90 USD
• Hardware:
o For a lesson on serial connections between the PC and the PIC
microcontroller, see:
http://cornerstonerobotics.org/curriculum/lessons_year2/erii_rs232_1.pdf
1
Cornerstone Electronics Technology and Robotics II
VB.NET and PicBasic Pro Lab 1 – LED On/Off
o Click on the form and resize to the general shape below. The form should
look like this:
3
o Click on the View Code button:
o Visual Basic displays the LED Control form in the Visual Studio IDE.
o Choose the HIGH RadioButton and press the Send button. The LED should
light up. Choose the LOW RadioButton and press the Send button. The
LED should turn off.
4
Cornerstone Electronics Technology and Robotics II
VB.NET and PicBasic Pro Lab 2 – Servo Position Control
• Purpose: The purpose of this lab is to send data in the form of a byte from Visual
Basic.NET to a PIC microcontroller.
• Apparatus and Materials:
o 1 – Breadboard with +5V Power Supply
o 1 – MAX232 RS-232 Driver/Receiver
o 1 – PIC16F88
o 5 – 1 uF Capacitors
o 1 – 150 Ohm Resistor
o 1 – 4.7K Resistor
o 1 – Hobby Servo
o 1 – Modified DB9 Connector - Connector,D-SUB,.318"RT,9P-F, Short Metal
Housing, Jameco Part # 104952
• Procedure:
o Wire the vb_servo1 circuit below. Read the schematic note.
5
o Set the properties to the following:
o Click on the form and resize to the general shape below. Now click on each
button and expand so that “Enter Position” displays. The form should look
like this:
6
o Click the Start Debugging button on the Standard toolbar.
o Visual Basic displays the Servo Control form in the Visual Studio IDE.
o Click on the Enter Position button; the Servo Position Input window appears.
Enter a number between 80 and 220 and press OK. Now press the Send
button in the Servo Control window. If the servo does not respond, it may
already be in that position so enter 220 and the servo should rotate.