Hi Tim:
I tried to compile your sketch and IDE show this:
PCintPort has not been declared..in this line
" PCintPort::attachInterrupt(SERVO_IN_PIN, calcServo, CHANGE);"
I've change the line to only "attachInterrupt(SERVO_IN_PIN, calcServo, CHANGE);" and the compilation is finished.
Well I'm trying to simplify your sketch to only have the results of 9 signals, control signal + eight (multiswitch 12 ints +2 pots) because I use it to polarize TIP122 transistors and do things. Also move servos, but isn't usually.
What do you think.......:::::
#include <PinChangeInt.h>
#define SERVO_IN_PIN 10
volatile unsigned long ulServoInShared= 0;
volatile unsigned long ulServoStart = 0;
volatile int multi_servo[17];
volatile int current_servo = 0;
void setup()
{
Serial.begin(9600); // other values include 9600, 14400, 57600 etc.
// set up interrupt for receiver input
attachInterrupt(SERVO_IN_PIN, calcServo, CHANGE);
}
void loop()
{
int servonum = 0;
int servoval = 360;
float tempval = 360.0;
// array slot zero is sync - 1 thru 9 are valid servo pulses
for (servonum = 1; servonum < 9; servonum++)
{
Serial.print("Servo: ");
Serial.print(servonum);
Serial.print(", ");
Serial.println(multi_servo[servonum]);
}
// "if...multi_servo[servonum] = > < xxx" conditions to do things
}
void calcServo()
{
if (digitalRead(SERVO_IN_PIN) == HIGH)
{
ulServoStart = micros();
}
else
{
ulServoInShared = (uint16_t)(micros() - ulServoStart);
current_servo++;
if (ulServoInShared < 1000) {
current_servo = 0;
}
if (ulServoInShared > 2000) {
current_servo = 0;
}
if (current_servo < 10) {
multi_servo[current_servo] = ulServoInShared;
}
}
}
Another Question: in a Arduino UNO I must change "#define SERVO_IN_PIN 10" to #define SERVO_IN_PIN 2" or "#define SERVO_IN_PIN 3"??
I read interrups in UNO must use 2 or 3 pin.
Thanks
Best Regards
Pedro
I tried to compile your sketch and IDE show this:
PCintPort has not been declared..in this line
" PCintPort::attachInterrupt(SERVO_IN_PIN, calcServo, CHANGE);"
I've change the line to only "attachInterrupt(SERVO_IN_PIN, calcServo, CHANGE);" and the compilation is finished.
Well I'm trying to simplify your sketch to only have the results of 9 signals, control signal + eight (multiswitch 12 ints +2 pots) because I use it to polarize TIP122 transistors and do things. Also move servos, but isn't usually.
What do you think.......:::::
#include <PinChangeInt.h>
#define SERVO_IN_PIN 10
volatile unsigned long ulServoInShared= 0;
volatile unsigned long ulServoStart = 0;
volatile int multi_servo[17];
volatile int current_servo = 0;
void setup()
{
Serial.begin(9600); // other values include 9600, 14400, 57600 etc.
// set up interrupt for receiver input
attachInterrupt(SERVO_IN_PIN, calcServo, CHANGE);
}
void loop()
{
int servonum = 0;
int servoval = 360;
float tempval = 360.0;
// array slot zero is sync - 1 thru 9 are valid servo pulses
for (servonum = 1; servonum < 9; servonum++)
{
Serial.print("Servo: ");
Serial.print(servonum);
Serial.print(", ");
Serial.println(multi_servo[servonum]);
}
// "if...multi_servo[servonum] = > < xxx" conditions to do things
}
void calcServo()
{
if (digitalRead(SERVO_IN_PIN) == HIGH)
{
ulServoStart = micros();
}
else
{
ulServoInShared = (uint16_t)(micros() - ulServoStart);
current_servo++;
if (ulServoInShared < 1000) {
current_servo = 0;
}
if (ulServoInShared > 2000) {
current_servo = 0;
}
if (current_servo < 10) {
multi_servo[current_servo] = ulServoInShared;
}
}
}
Another Question: in a Arduino UNO I must change "#define SERVO_IN_PIN 10" to #define SERVO_IN_PIN 2" or "#define SERVO_IN_PIN 3"??
I read interrups in UNO must use 2 or 3 pin.
Thanks
Best Regards
Pedro
perisc, sonar, radar). 

Comment