I'm trying to build a robot arm based on Arduino UNO and PCA9685 controlled by few potentiometers. The easiest way that I figure out and find on internet is using two Arduino's, one as master and second as slave. This is where my question comes from, there is a way to use single Arduino UNO instead of two by using at the same time SDA and SCL with analog inputs? Maybe there is another way to do that?
That's my actual code:
#include <Arduino.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwmDriver = Adafruit_PWMServoDriver(0x40);
void setup()
{
pwmDriver.begin();
pwmDriver.setPWMFreq(51);
}
int tempPotVal = 0;
int adcPin[4] = {A0, A1, A2, A3};
int pwmRisingTime = 0;
int pwmFallingTime = 0;
void loop()
{
for (int id = 0; id < 4; id++)
{
tempPotVal = analogRead(adcPin[id]);
pwmFallingTime = map(tempPotVal, 113, 842, 102, 512);
pwmDriver.setPWM(id, pwmRisingTime, pwmFallingTime);
}
}