Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

7Botに自力でコードを書き込んでみた

shuzo-kino.hateblo.jp
以前の記事のように7botを導入してはみたものの、待てども待てどもサンプルが上がってくる気配がありません。

このままでは月が変わりそうなので……試しに有志が作ったサンプルコードを動かしてみました。
発送時点で公開はされてたのに、公式を見る限りは動かしてる人自体が少ないようです。
……受け身が主流とは、Maker界隈も変わりましたねぇ(遠い目

実際のところ

環境構築

Arudino IDEの最新版を用意します。
内蔵されているArduino DueはARM系なので、デフォでは未採用です。
専用UIで自前で書込情報を導入しないといけません。
Due | Arduino Documentation

とりあえず、以下の記事を見るか、ググれば対処できるかと。
近いうちに記事にします=>書きました
shuzo-kino.hateblo.jp

ソースコード

コードはこちらから拝借
Loading...

/*
Basic Arduino code to sweep robot from 
left to right and back again in a loop, while displaying analog output: 


Pin configs for 7bot.

Axis 1; Readout = A0 ; ServoControl D2 
Axis 2; Readout = A1 ; ServoControl D3 
Axis 3; Readout = A2 ; ServoControl D4 
Axis 4; Readout = A3 ; ServoControl D5 
Axis 5; Readout = A4 ; ServoControl D6 
Axis 6; Readout = A5 ; ServoControl D7 
Axis 7; Readout = A6 ; ServoControl D8 

Pomp Valve; Control D10 ; Low means open (suction); High closed (no suction) 
Pomp motor; Control D11 ; High is on; Low is off 
Beep; Control D12 ; High is very irritating noise, Low is peace 

Left Button; Readout D71 
Right Button; Readout D70 
*/




#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 
int s1 = 0; // variale to store the servo read out 

int ServoReadPort = 0; // analog port 0 
int ServoWritePort = 2; // digital port 2 

void setup() { 
Serial.begin(9600); 
myservo.attach(ServoWritePort); // attaches the servo on pin 9 to the servo object 

} 

void loop() { 


for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees 
// in steps of 1 degree 
myservo.write(pos); // tell servo to go to position in variable 'pos' 
s1 = analogRead(ServoReadPort); 
Serial.println(s1); // tell servo to go to position in variable 'pos' 

delay(15); // waits 15ms for the servo to reach the position 
} 
delay(5000); 
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees 
myservo.write(pos); // tell servo to go to position in variable 'pos' 
s1 = analogRead(ServoReadPort); 
Serial.println(s1); // tell servo to go to position in variable 'pos' 

delay(15); // waits 15ms for the servo to reach the position 
} 
delay(5000); 

}

通常のArduinoとは書込時に出てくるフレーズが異なるので要注意です。

最大524,288バイトのフラッシュメモリのうち、スケッチが24,040バイト(4%)を使っています。
Atmel SMART device 0x285e0a60 found
Erase flash
done in 0.037 seconds

Write 26316 bytes to flash (103 pages)

[                              ] 0% (0/103 pages)
[==                            ] 9% (10/103 pages)
[=====                         ] 19% (20/103 pages)
[========                      ] 29% (30/103 pages)
[===========                   ] 38% (40/103 pages)
[==============                ] 48% (50/103 pages)
[=================             ] 58% (60/103 pages)
[====================          ] 67% (70/103 pages)
[=======================       ] 77% (80/103 pages)
[==========================    ] 87% (90/103 pages)
[============================= ] 97% (100/103 pages)
[==============================] 100% (103/103 pages)
done in 5.206 seconds

Verify 26316 bytes of flash

[                              ] 0% (0/103 pages)
[==                            ] 9% (10/103 pages)
[=====                         ] 19% (20/103 pages)
[========                      ] 29% (30/103 pages)
[===========                   ] 38% (40/103 pages)
[==============                ] 48% (50/103 pages)
[=================             ] 58% (60/103 pages)
[====================          ] 67% (70/103 pages)
[=======================       ] 77% (80/103 pages)
[==========================    ] 87% (90/103 pages)
[============================= ] 97% (100/103 pages)
[==============================] 100% (103/103 pages)
Verify successful
done in 4.855 seconds
Set boot flash true
CPU reset.

動作すると、こんな感じ*1

7Bot Robot arm - program test

*1:なにげに人生初の動画アップロードだったり