Hello,
I am working a project where I have a light source which orientation is controlled by 2 servos. I will name it an "unit": 3 inputs named x,y and light.
The project uses many units. (not enough for pins even on Mega)
I would like to hear suggestions on best approaches to implement it. This might be a little abstract.
At this moment I am thinking of using one ATTiny to control each unit separately, as slaves, communicating via i2c with a master arduino uno, currently loaded with standard firmata and getting instructions from Processing.
The idea is that arduino uno will be constantly informing each slave address what to do.
I am still not sure how to concat this to work with Wire library but something like:
on loop()
for each slave:
Wire.beginTransmission(0x...);
Wire.write( "0x180y180" ); where I imagine : 0 or 1 (light on/off) | angle at motor x | angle at motor y)
Wire.endTransmission();
delay(500); <- I am convicted I can't use it
Any suggestions would be great!
Thank you
This 16 servo board may help. Using those boards is much less complicated than using a Tiny for each servo. The Tiny85 does not use the Wire library for I2C as it lacks hardware I2C. The TinyWires library is one to implement I2C on tiny85.
Are you aware of the wire length restrictions when using I2C? I think the servo output and power can run much farther than I2C wires.
3 inputs named x,y and light.
Are these analog?
Can you describe your system better? Are the tiny85's reading the x, y, light analog levels and transmitting the data to a central "server" that is connected to the PC? And the tiny85 are controlling servos?
Thank you very much for your reply!
I believe these boards might be a very good solution. I was just checking and they can be also chained!
Btw, i was not aware of the wires length restrictions and i2C. I think wires will be no longer than 30 cm.
I will try to answer some of your questions below:
System:
An arduino uno (master) loaded with firmata is directly connected to a pc receiving commands from a processing application, like how to move the servos and turn lights on/off.
Each slave equipped with an ATtiny reads it's correspondent servos X and Y positions( analog from 0 to 180) and the light (digital, but analog would be better since I can control intensity) sent by master. After reading these information, each ATtiny slave executes the movements accordingly.
the board you recommended seems to be a better solution for the servos. I just have to think about how to output the signals for the lights.
Originally, I intended to have multi ATtiny to control 2 servos, X and Y, using it's analog ports, plus one light, using a digital port. But one of these analog ports are being used for the i2c communication with the master. I was about to test if it works, but I am still struggling with the code on sending data correctly.
Previously, in another project, I could drive one single servo using ATtiny and software servo library.
Initially, I am not using slave-to-master communication, just master-to-slaves.
30 cm is probably OK for length. If there is trouble, a stronger pullup (no less than 1K) should fix it.
Hi,
Just to check, you are aware that "analog outputs" in the case of arduino usually means PWM with 0 to 255 duty cycle.
If you are looking for pure DC variable level, you can put a filter on the PWM to get a DC level, or look for a controller with DtoA output, or use an external DtoA controlled by the Arduino.
Tom.... 
Thanks for the instructions. I guess the cable will not be the problem in terms of length, but I still need to mount the boards over the structure frame to make sure about the distance.
So far I am testing with only one of the 16 servo board. Originally, before acquiring this board, I was testing only 4 servos directly connected to Arduino outputs. This Arduino was loaded with StandardFirmata, receiving serial commands from a Processing application (Basically, the servos orientation and light intensity).
Is there best practice to loop through all the servos and update their angles in a certain way?
Considering 60 servos, say every servo orientation is mapped to a mouse movement on a screen.
I am not familiar with the timers in Arduino board, so I am wonder a case where I have the first servo 0 to be set at an angle... and while servo 0 is moving to that angle, the function continues to set the angles for the rest of servos in the chain up to servo 60.
But how can I update servo 0 as soon as it reaches its angle, even thought the function is not finished yet updating all chained servos?
In the same way, if the last chained servo is set to an angle, I should add some delay so it can reach its position. But in this case, the delay() designed for the last servo will prevent all the chain to start being updated.