1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
-
-
-
-
- var HBridge_lib = require('jsupm_l298');
-
-
-
-
- var myHBridge_obj = new HBridge_lib.L298(3, 4, 7);
-
-
- myHBridge_obj.goForward = function()
- {
- console.log("Starting motor at 50% for 3 seconds...");
- myHBridge_obj.setSpeed(50);
- myHBridge_obj.setDirection(HBridge_lib.L298.DIR_CW);
- myHBridge_obj.enable(true);
- };
-
- myHBridge_obj.reverseDirection = function()
- {
- console.log("Reversing direction...");
- myHBridge_obj.setDirection(HBridge_lib.L298.DIR_NONE);
- myHBridge_obj.setDirection(HBridge_lib.L298.DIR_CCW);
- };
-
- myHBridge_obj.stop = function()
- {
- myHBridge_obj.setSpeed(0);
- myHBridge_obj.enable(false);
- };
-
- myHBridge_obj.quit = function()
- {
- myHBridge_obj = null;
- HBridge_lib.cleanUp();
- HBridge_lib = null;
- console.log("Exiting");
- process.exit(0);
- };
-
-
-
- myHBridge_obj.goForward();
- setTimeout(myHBridge_obj.reverseDirection, 3000);
- setTimeout(function()
- {
- myHBridge_obj.stop();
- myHBridge_obj.quit();
- }, 6000);
|