Đ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 6', 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ả | CONTROLLING RC SERVOS WITH THE BX-24 511 twice in this example changes the state of a specified I O line. Note the use of the constants. The syntax for PutPin is as follows PutPin PinNumber Value where PinNumber is the number of the pin you want to use e.g. pin 25 for the red LED and Value is either 1 for on or logical HIGH or 0 for off or logical LOW . The Delay function causes the BX-24 to pause a brief while in this case 70 milliseconds. Delay is called twice so there is a period of time between the on off flashing of each LED Green pulse. Call PutPin GreenLED LEDon Call Delay 0.07 Call PutPin GreenLED LEDoff Call Delay 0.07 The process is repeated for the green LED. Controlling RC Servos with the BX-24 You can easily control RC servos with the BX-24 using a few simple statements. While there is no built-in servo command as there is with the OOPic microcontroller see Chapter 33 the procedure is nevertheless very easy to do in the BX-24. Here s a basic program that places a servo connected to pin 20 of the BX-24 at its approximate mid-point position. I say approximate because the mechanics of RC servos can differ between makes models and even individual units Sub Main Do Call PulseOut 20 1.5E-3 1 Call Delay 0.02 Loop End Sub The program continuously runs because it s within an infinite Do loop. The PulseOut statement sends a short 1.5-millisecond ms HIGH pulse to pin 20. The Delay statement causes the BX-24 to wait 20 milliseconds before the loop is repeated all over again. With a delay of 20 milliseconds the loop will repeat 50 times a second 50 20 milliseconds 1000 milliseconds or one second . Note the optional use of scientific notation for the second parameter of PulseOut. Using the value 0.0015 would yield the same result. You should be aware that the BX-24 supports two versions of the PulseOut statement a float version and an integer version The float version is used with floating-point numbers that is numbers that have a decimal point. The integer version