Processing + Arduino Shield translation
in
Integration and Hardware
•
1 year ago
Hi all¡
I´m in the middle of a project where I should run a bunch of servos, the best idea was using this board :
http://www.robot-r-us.com/vmchk/servo-controllers/red-back-spider-robot-48-servos-controller.html
It provides a simple Arduino code to run up to 48 servos at once, it looks like this:
- #include <Servo.h>
- // define global variables
- int sp=1500;
- int dr=5;
- // define servos
- Servo s00;
- Servo s01;
- Servo s02;
- Servo s03;
- Servo s04;
- Servo s05;
- Servo s06;
- Servo s07;
- Servo s08;
- Servo s09;
- Servo s10;
- Servo s11;
- Servo s12;
- Servo s13;
- Servo s14;
- Servo s15;
- Servo s16;
- Servo s17;
- Servo s18;
- Servo s19;
- Servo s20;
- Servo s21;
- Servo s22;
- Servo s23;
- Servo s24;
- Servo s25;
- Servo s26;
- Servo s27;
- Servo s28;
- Servo s29;
- Servo s30;
- Servo s31;
- Servo s32;
- Servo s33;
- Servo s34;
- Servo s35;
- Servo s36;
- Servo s37;
- Servo s38;
- Servo s39;
- Servo s40;
- Servo s41;
- Servo s42;
- Servo s43;
- Servo s44;
- Servo s45;
- Servo s46;
- Servo s47;
- void setup()
- {
- s00.attach(2);
- s01.attach(3);
- s02.attach(4);
- s03.attach(5);
- s04.attach(6);
- s05.attach(7);
- s06.attach(8);
- s07.attach(9);
- s08.attach(10);
- s09.attach(11);
- s10.attach(12);
- s11.attach(13);
- s12.attach(14);
- s13.attach(15);
- s14.attach(16);
- s15.attach(17);
- s16.attach(18);
- s17.attach(19);
- s18.attach(20);
- s19.attach(21);
- s20.attach(22);
- s21.attach(23);
- s22.attach(24);
- s23.attach(25);
- s24.attach(26);
- s25.attach(27);
- s26.attach(28);
- s27.attach(29);
- s28.attach(30);
- s29.attach(31);
- s30.attach(32);
- s31.attach(33);
- s32.attach(34);
- s33.attach(35);
- s34.attach(36);
- s35.attach(37);
- s36.attach(38);
- s37.attach(39);
- s38.attach(40);
- s39.attach(41);
- s40.attach(42);
- s41.attach(43);
- s42.attach(44);
- s43.attach(45);
- s44.attach(46);
- s45.attach(47);
- s46.attach(48);
- s47.attach(49);
- }
- void loop()
- {
- s00.writeMicroseconds(sp);
- s01.writeMicroseconds(sp);
- s02.writeMicroseconds(sp);
- s03.writeMicroseconds(sp);
- s04.writeMicroseconds(sp);
- s05.writeMicroseconds(sp);
- s06.writeMicroseconds(sp);
- s07.writeMicroseconds(sp);
- s08.writeMicroseconds(sp);
- s09.writeMicroseconds(sp);
- s10.writeMicroseconds(sp);
- s11.writeMicroseconds(sp);
- s12.writeMicroseconds(sp);
- s13.writeMicroseconds(sp);
- s14.writeMicroseconds(sp);
- s15.writeMicroseconds(sp);
- s16.writeMicroseconds(sp);
- s17.writeMicroseconds(sp);
- s18.writeMicroseconds(sp);
- s19.writeMicroseconds(sp);
- s20.writeMicroseconds(sp);
- s21.writeMicroseconds(sp);
- s22.writeMicroseconds(sp);
- s23.writeMicroseconds(sp);
- s24.writeMicroseconds(sp);
- s25.writeMicroseconds(sp);
- s26.writeMicroseconds(sp);
- s27.writeMicroseconds(sp);
- s28.writeMicroseconds(sp);
- s29.writeMicroseconds(sp);
- s30.writeMicroseconds(sp);
- s31.writeMicroseconds(sp);
- s32.writeMicroseconds(sp);
- s33.writeMicroseconds(sp);
- s34.writeMicroseconds(sp);
- s35.writeMicroseconds(sp);
- s36.writeMicroseconds(sp);
- s37.writeMicroseconds(sp);
- s38.writeMicroseconds(sp);
- s39.writeMicroseconds(sp);
- s40.writeMicroseconds(sp);
- s41.writeMicroseconds(sp);
- s42.writeMicroseconds(sp);
- s43.writeMicroseconds(sp);
- s44.writeMicroseconds(sp);
- s45.writeMicroseconds(sp);
- s46.writeMicroseconds(sp);
- s47.writeMicroseconds(sp);
- sp+=dr;
- if (sp>2000 || sp<1000) dr=-dr;
- delay(1);
- }
The shield´s creators says that the board is coded like an Arduino Mega anyway, I was wondering how to code in Processing to use it. I only have to declare the 48 pins and parse the data?
I was hoping to clear this matter before buying the board.
Any help will be appreciated¡
I hope I´m explaining properly, sorry about my bad english¡
1