VERSION 5.00 Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UserForm1 Caption = "UserForm1" ClientHeight = 4452 ClientLeft = 36 ClientTop = 264 ClientWidth = 3804 OleObjectBlob = "UserForm1.frx":0000 StartUpPosition = 1 'CenterOwner End Attribute VB_Name = "UserForm1" Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Spirit1_InputChange(ByVal Number As Integer, ByVal Value As Integer) End Sub Private Sub UserForm_Click() End Sub Private Sub AliveCheck_Click() ' ' LegoTest Macro ' Macro recorded 12/12/98 by Amnon Silverstein ' Dim step_delay As Integer PBrickCtrl.InitComm step_delay = 5 If PBrickCtrl.PBAliveOrNot Then PBrickCtrl.SelectPrgm 0 PBrickCtrl.BeginOfTask 0 PBrickCtrl.On "motor0" PBrickCtrl.Wait CON, step_delay PBrickCtrl.Off "motor0" PBrickCtrl.EndOfTask PBrickCtrl.SelectPrgm 1 PBrickCtrl.BeginOfTask 1 PBrickCtrl.On "motor1" PBrickCtrl.Wait CON, 2 'step_delay PBrickCtrl.Off "motor1" PBrickCtrl.EndOfTask PBrickCtrl.SelectPrgm 2 PBrickCtrl.BeginOfTask 2 PBrickCtrl.On "motor1" PBrickCtrl.While 9, 1, 0, 2, 0 PBrickCtrl.EndWhile PBrickCtrl.Off "motor1" PBrickCtrl.EndOfTask PBrickCtrl.SelectPrgm 3 PBrickCtrl.BeginOfTask 3 PBrickCtrl.On "motor0" PBrickCtrl.While 9, 2, 3, 2, 1 PBrickCtrl.EndWhile PBrickCtrl.Off "motor0" PBrickCtrl.EndOfTask PBrickCtrl.SetSensorType 0, LIGHT_TYPE PBrickCtrl.SetSensorType 1, ANGLE_TYPE PBrickCtrl.PlaySystemSound SWEEP_FAST_SOUND Alive.Caption = "Ready to roll!" Else Alive.Caption = "No RCX connection." End If End Sub Private Sub Go_Click() Dim sensor_val As Integer Dim put_cell As String Dim camera_res As Integer Dim old_timer As Integer Dim new_timer As Integer Dim angle_step As Integer Dim current_angle As Integer Dim needed_angle As Integer angle_step = 4 camera_res = 55 PBrickCtrl.SetSensorType 0, 3 PBrickCtrl.SetPower "motor0motor1", CON, 7 PBrickCtrl.SetFwd "motor0motor1" For y = 0 To (camera_res - 1) PBrickCtrl.StartTask 0 sensor_val = PBrickCtrl.Poll(9, 0) PBrickCtrl.SetFwd "motor1" For x = 0 To (camera_res - 1) current_angle = PBrickCtrl.Poll(9, 1) needed_angle = (angle_step * x) keep_going = 0 While (((current_angle - needed_angle) < 0) And (keep_going < 30)) PBrickCtrl.StartTask 1 keep_going = keep_going + 1 current_angle = PBrickCtrl.Poll(9, 1) Wend sensor_val = 0 For i = 1 To 1 sensor_val = sensor_val + PBrickCtrl.Poll(9, 0) Next Range("A1").Select ActiveCell.Offset(x, y).Select ActiveCell.FormulaR1C1 = Str(sensor_val) Next PBrickCtrl.SetRwd "motor1" PBrickCtrl.StartTask 2 current_angle = PBrickCtrl.Poll(9, 1) While (current_angle > 0) current_angle = PBrickCtrl.Poll(9, 1) Wend Next ' Home PBrickCtrl.StartTask 2 PBrickCtrl.SetRwd "motor0" PBrickCtrl.StartTask 3 End Sub