jonidohc16v
Member
Hey everyone!
So, I'm working on a project where I use 4 muxs, one for voltage, one for temperature, one for amps and another for PWM. I have 30 Servos turning and a sensor in each one to record their PWM, the AMS AS5048B. The voltage, temperature and amps, I got them easily. But the PWM I'm not finding the way to get it properly.
I leave here my code of what I have tried so far.
I'm only triyng with two servos to see if it works. I was hoping if any of you could helpm, tell me what I'm doing wrong and guidem, please
Thank you,
Jonathan
So, I'm working on a project where I use 4 muxs, one for voltage, one for temperature, one for amps and another for PWM. I have 30 Servos turning and a sensor in each one to record their PWM, the AMS AS5048B. The voltage, temperature and amps, I got them easily. But the PWM I'm not finding the way to get it properly.
I leave here my code of what I have tried so far.
Code:
#include "PWM.hpp"
#define CONTROL0 17
#define CONTROL1 16
#define CONTROL2 15
#define CONTROL3 14
PWM ch1(A9);
int mux0array[16] = {0};
int mux0array1[14] = {0};
void setup()
{
pinMode(CONTROL0, OUTPUT);
pinMode(CONTROL1, OUTPUT);
pinMode(CONTROL2, OUTPUT);
pinMode(CONTROL3, OUTPUT);
pinMode(A9, INPUT);
ch1.begin(true);
Serial.begin(9600);
}
void loop()
{
pwm_read();
}
void pwm_read()
{
for (int i = 0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux0array[i] = analogRead(A9);
//mux0array1[i] = analogRead(A8);
}
for (int i = 0; i<2; i++)
{
mux0array[0] = ch1.getValue();
Serial.print(mux0array[0]);
Serial.print("\t");
mux0array[1] = ch1.getValue();
Serial.print(mux0array[1]);
Serial.println("\t");
delay(250);
}
}
I'm only triyng with two servos to see if it works. I was hoping if any of you could helpm, tell me what I'm doing wrong and guidem, please
Thank you,
Jonathan