OUR PROJECT

Before connecting any devices you first have to download an updated driver, which can be found at http://www.bluesoleil.com/download/

To begin with you must first plug in the BAM module into the Create iRobot and the Bluesoleil Bluetooth receiver to the computer. Once both are connected you have to enter My Bluetooth places and find what outgoing port is connected to the iRobot. Take that information into the Basic code in order to make sure the program connects to the correct COM port and the two items will link. Run the VB code and click open com port. Finally, enjoy your experience.


Here is the code for our program. (be prepared to scroll for awhile)


Public Forward_speed, Backward_speed, Forward_more, Backward_more, Left_turn, Right_turn As Integer

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Private Sub Command1_Click()

Dim hb(28) As Byte 'Happy Birthday Notes [SONG #0]

Dim hbd(30) As Byte 'Happy Birthday Notes [Song #1]

Dim play(4) As Byte 'Plays song

Dim plays(4) As Byte 'Plays rest of song


' 1st part of happy birthday (limit is 16 notes)

hb(0) = 128

hb(1) = 140

hb(2) = 0

hb(3) = 12

hb(4) = 60

hb(5) = 16

hb(6) = 60

hb(7) = 16

hb(8) = 62

hb(9) = 32

hb(10) = 60

hb(11) = 32

hb(12) = 65

hb(13) = 32

hb(14) = 64

hb(15) = 50

hb(16) = 60

hb(17) = 16

hb(18) = 60

hb(19) = 16

hb(20) = 62

hb(21) = 32

hb(22) = 60

hb(23) = 32

hb(24) = 67

hb(25) = 32

hb(26) = 65

hb(27) = 50


buffer = hb


MSComm1.Output = buffer



play(0) = 128

play(1) = 132

play(2) = 141

play(3) = 0


buffer = play


MSComm1.Output = buffer


Sleep (5000)


'2nd part of happy birthday

hbd(0) = 128

hbd(1) = 140

hbd(2) = 1

hbd(3) = 13

hbd(4) = 60

hbd(5) = 16

hbd(6) = 60

hbd(7) = 16

hbd(8) = 72

hbd(9) = 32

hbd(10) = 69

hbd(11) = 32

hbd(12) = 65

hbd(13) = 32

hbd(14) = 64

hbd(15) = 32

hbd(16) = 62

hbd(17) = 60

hbd(18) = 71

hbd(19) = 16

hbd(20) = 71

hbd(21) = 16

hbd(22) = 69

hbd(23) = 32

hbd(24) = 65

hbd(25) = 32

hbd(26) = 67

hbd(27) = 32

hbd(28) = 65

hbd(29) = 50


buffer = hbd


MSComm1.Output = buffer



plays(0) = 128

plays(1) = 132

plays(2) = 141

plays(3) = 1


buffer = plays


MSComm1.Output = buffer



End Sub


Private Sub Done_Click()


End Sub



Private Sub Exit_Click()

    If MSComm1.PortOpen Then MSComm1.PortOpen = False

   

    Unload Me

End Sub






Private Sub Form_Load()

Forward_more = 0

Backward_more = 129

Right_turn = 5

Left_turn = 255


End Sub


'------------------------------------------------

'---------------Port Commands--------------------

'------------------------------------------------


Private Sub open_Click()

   MSComm1.CommPort = 1 'DO NOT FORGET

  

   ' 56000 baud, no parity, 8 data, and 1 stop bit.

   MSComm1.Settings = "56000,N,8,1"

   'define input buffer size when data incoming

      MSComm1.InputLen = 0

  

      MSComm1.RThreshold = 2

  

   ' Open the port.

   MSComm1.PortOpen = True

   If (MSComm1.PortOpen) Then

    Console.Text = "Port is Open for Business"

   Else

    Console.Text = "Port is Closed"

   End If


End Sub


Private Sub close_Click()


If MSComm1.PortOpen Then MSComm1.PortOpen = False

Console.Text = "This Port is Closed!"


End Sub



'------------------------------------------------

'--------------Move Commands---------------------

'------------------------------------------------


Private Sub Forward_Click()

Dim f(7) As Byte 'move forward array of 7 bytes

Backward_more = 129

Left_turn = 255

Right_turn = 5


f(0) = 128

f(1) = 130

f(2) = 137

f(3) = 0

f(4) = 55

f(5) = 128

f(6) = 0


buffer = f


MSComm1.Output = buffer


End Sub

Private Sub fastforward_Click()

Backward_more = 129

Left_turn = 255

Right_turn = 5


    If (Forward_more = 128) Then

    Forward_more = 128

    Else

        Forward_more = Forward_more + 1

    End If

   

    Dim f(7) As Byte 'move forward array of 7 bytes


f(0) = 128

f(1) = 130

f(2) = 137

f(3) = Forward_more

f(4) = 55

f(5) = 128

f(6) = 0


buffer = f


MSComm1.Output = buffer


End Sub

Private Sub Backward_Click()

Dim b(7) As Byte 'move backward array of 7 bytes

Forward_more = 0

Left_turn = 255

Right_turn = 5


b(0) = 128

b(1) = 130

b(2) = 137

b(3) = 255

b(4) = 64

b(5) = 128

b(6) = 0


buffer = b


MSComm1.Output = buffer


End Sub


Private Sub fastback_Click()

Dim b(7) As Byte 'move backward array of 7 bytes

Forward_more = 0

Left_turn = 255

Right_turn = 5


    If (Backward_more = 255) Then

    Backward_more = 255

    Else

    Backward_more = Backward_more + 1

    End If

   

b(0) = 128

b(1) = 130

b(2) = 137

b(3) = Backward_more

b(4) = 64

b(5) = 128

b(6) = 0


buffer = b


MSComm1.Output = buffer

   

End Sub


Private Sub Left_Click()

Dim L(7) As Byte 'move left array of 7 bytes


L(0) = 128

L(1) = 130

L(2) = 137

L(3) = 0

L(4) = 255

L(5) = 0

L(6) = 0


buffer = L


MSComm1.Output = buffer


End Sub


Private Sub veerleft_Click(Index As Integer)

Dim f(7) As Byte 'move forward array of 7 bytes

Right_turn = 5


If (Left_turn = 5) Then

Left_turn = 5

Else

Left_turn = Left_turn - 50

End If


f(0) = 128

f(1) = 130

f(2) = 137

f(3) = Forward_more

f(4) = 55

f(5) = 1

f(6) = Left_turn


buffer = f


MSComm1.Output = buffer


End Sub


Private Sub Right_Click()

Dim r(7) As Byte 'move right array of 7 bytes


r(0) = 128

r(1) = 130

r(2) = 137

r(3) = 0

r(4) = 255

r(5) = 255

r(6) = 255


buffer = r


MSComm1.Output = buffer


End Sub


Private Sub veerright_Click(Index As Integer)

Dim f(7) As Byte 'move forward array of 7 bytes

Left_turn = 255


If (Right_turn = 255) Then

Right_turn = 255

Else

Right_turn = Right_turn + 50

End If


f(0) = 128

f(1) = 130

f(2) = 137

f(3) = Forward_more

f(4) = 75

f(5) = 255

f(6) = Right_turn


buffer = f


MSComm1.Output = buffer

End Sub


Private Sub Stop_Click()

Dim stp(7) As Byte 'stop moving array of 7 bytes


stp(0) = 128

stp(1) = 130

stp(2) = 137

stp(3) = 0

stp(4) = 0

stp(5) = 0

stp(6) = 0


buffer = stp


MSComm1.Output = buffer


End Sub


'------------------------------------------------

'-------------Other Fancy Commands---------------

'------------------------------------------------


Private Sub LightOn_Click()

Dim ind(6) As Byte  'Indicator light array of 6 bytes

Dim ok As Boolean


ind(0) = 128

ind(1) = 132

ind(2) = 139

ind(3) = 2

ind(4) = 0

ind(5) = 0


buffer = ind


MSComm1.Output = buffer


End Sub


Here are some of the resources we used to work on our project.

-    www.irobot.com


-    http://compsci.snc.edu/cs460/cohejr/


-    http://www.sparkfun.com/commerce/product_info.php?products_id=684


-    http://www.robotics.utexas.edu/rrg/learn_more/low_ed/types/industrial.html


-    http://realterm.sourceforge.net/


-    www.wikipedia.com


-    http://irobotcreate.googlepages.com/


Below you can find our code and an explanation on how to start the project.