Hi all,
Servo again.....(180 degrees, 5V and the Arduino)
In a project I have a chanAo which is the only chanAo.
In the Arduino sketch I want to read this analog value and map this to a pulse by using the standard servo libray from the Arduino (the USB communication between Proview and the Arduino is too slow to control a servo directly)
In the sketch from (/usr/pwr48/os_linux/hw_x86/exp/inc/pwr_arduino_uno.ino) I have the next code:
<<
// Write analog outputs
if ( msgSize == aoCnt) {
for ( i = 0; i < aoCnt; i++)
//Read the first Analog output from Proview and map this value to a servo on Do4
if ( i == 0)
{
degrees1 = map(msgData, 0, 255, 0, 179);
servo1.write(degrees1);
}
else
analogWrite( aoList, msgData);
>>
This is not working.
When I do exactly the same in the sketch by using a Do (debug flag has been set), Proview sends a value 64.
<<
// Write digital outputs
if ( msgSize == doSize + aoCnt) {
for ( i = 0; i < doSize; i++) {
for ( j = 0; j < 8; j++) {
if ( ((1 << j) & doMask) != 0) {
if ( ((1 << j) & msgData) != 0)
digitalWrite( i * 8 + j, HIGH);
else
digitalWrite( i * 8 + j, LOW);
}
}
}
for ( i = 0; i < aoCnt; i++)
//
//Test for the first digital output sent by Proview. If the button is pressed, Proview sends a messages with the value 64 --> the servo works in this case
if ( i == 0)
{
degrees1 = map(msgData, 0, 255, 0, 179);
servo1.write(degrees1);
}
else
analogWrite( aoList, msgData[doSize + i]);
>>
This works.
I can't find out why the "same" code works successfully when I map the Do part and is not working when I try to use the Ao,
Marc