TOMIXのポイント!2


昨日のスローポイントアクション。

サンプルスケッチ



#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // twelve servo objects can be created on most boards
 
int pos = 0;    // variable to store the servo position
 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
 
 
void loop()
{
  int start_pos;
  int end_pos;
  int d;

  start_pos=90-6;
  end_pos=90+22;
  d=100;

  //片側に寄せる
  for(pos = start_pos; pos <= end_pos; pos += 1)
  {
    myservo.write(pos);
    delay(d);
  }
  delay(1000);  // 1秒待ち


  //反対側に寄せる
  for(pos = end_pos; pos>=start_pos; pos-=1)
  {                               
    myservo.write(pos);
    delay(d);
  }
  delay(1000);  // 1秒待ち

}



イメージ 1

地下層から地上層に上がるのに、233mm 上げないといけないのだけれど、
以外に坂がキツイ。Nゲージで 3.97% はかなりヤバイ。全長 約6m。

イメージ 2

二重螺旋にしてなんとか、2.21% に。
というか二重螺旋にすると全長10mになるんだけど、いいのかな?(^^;