Cookbook / Connect a DC Motor

Code

Flash

  1. import gainer.*;
  2.  
  3. var ioModule:Gainer = new Gainer("localhost", 2000, Gainer.MODE1, true);
  4.  
  5. ioModule.onReady = function() {
  6.     ...
  7.     // forward rotation
  8.     // 正回転
  9.     ioModule.analogOutput(255, 0);
  10.  
  11.     // reverse rotation
  12.     // 逆回転
  13.     ioModule.analogOutput(0, 255);
  14.  
  15.     // stop
  16.     // 停止
  17.     ioModule.analogOutput(0, 0);
  18.  
  19.     // BIG NO-NO!!!
  20.     // If you turn on both side, you'll burn your h-bridge up
  21.     // これは絶対にしてはダメ
  22.     // 両側をオンにするとHブリッジを焼いてしまう
  23.     ioModule.analogOutput(255, 255);
  24.     ...
  25. }

Max/MSP

Processing

  1. import gainer.*;
  2.  
  3. void setup {
  4.     gainer = new Gainer(this);
  5. }
  6.  
  7. void draw {
  8.     // forward rotation
  9.     // 正回転
  10.     gainer.analogOutput(255, 0);
  11.  
  12.     // reverse rotation
  13.     // 逆回転
  14.     gainer.analogOutput(0, 255);
  15.  
  16.     // stop
  17.     // 停止
  18.     gainer.analogOutput(0, 0);
  19.  
  20.     // BIG NO-NO!!!
  21.     // If you turn on both side, you'll burn your h-bridge up
  22.     // これは絶対にしてはダメ
  23.     // 両側をオンにするとHブリッジを焼いてしまう
  24.     gainer.analogOutput(255, 255);
  25. }
prev 1 - 2 - 3 - 4 - 5 next
Print