Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'mcgraw-hill - the robot builder's bonanza episode 2 part 7', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 546 REMOTE CONTROL SYSTEMS End If I I 2 Do even number elements only spaces are in odd number elements Digit Digit 1 Loop While I MaxPulses - 1 Determine item selected Tx is for debug window display MotorVal is the value to use on PortA Select Case Value Case 16706 Tx 0 MotorVal 0 Case 16898 Tx 1 MotorVal 1 Case 16642 Tx 2 MotorVal 2 Case 17154 Tx 3 MotorVal 3 Case 16514 Tx 4 MotorVal 4 Case 17026 Tx 5 MotorVal 5 Case 16770 Tx 6 MotorVal 6 Case 17282 Tx 7 MotorVal 7 Case 16450 Tx 8 MotorVal 8 Case 16962 Tx 9 MotorVal 9 Case 16802 Tx Power MotorVal 0 Case 16930 Tx Channel Up MotorVal 0 Case 16674 Tx Channel Down MotorVal 0 Case 16546 Tx Volume Up MotorVal 0 Case 17058 Tx Volume Down MotorVal 0 Case Else Tx other End Select Set PortA output to motor value lower four bits only Register.PORTA Register.PORTA AND bx11110000 OR _ Motors CInt MotorVal Call PutStr Tx display on debug window COMMANDING A ROBOT WITH INFRARED REMOTE CONTROL 547 Call NewLine Call Delay 0.25 wait quarter of a second Continue Loop End Sub Lifted from NetMedia BasicX code examples Sub TranslateSpace ByVal Space As UnsignedInteger _ ByRef BitValue As Integer ByRef Success As Boolean Translates the specified space into a binary digit. Each space must be within this range. Const MaxValue As Single 1700.0E-6 Const MinValue As Single 300.0E-6 This is the crossover point between binary 0 and 1. Const TripPoint As Single 1000.0E-6 Const UnitConversion As Single 135.63368E-9 1.0 7372800.0 Dim SpaceWidth As Single Convert to seconds. SpaceWidth CSng Space UnitConversion If SpaceWidth MinValue Or SpaceWidth MaxValue Then Success False Exit Sub Else Success True End If If SpaceWidth TripPoint Then BitValue 1 Else BitValue 0 End If End Sub Sub Initialize Wait for power to stabilize Call Delay 0.25 Used for serial port communications Call OpenSerialPort 1 19200 End Sub Of critical importance is the Select Case structure which compares the values that are returned from the remote. These were the actual numeric