Now the last post on that thread was me asking if someone could tell me what this :-
((total+)/10)
was.
Now it has just become more confusing, when Paul posted his code
double R1[4] = {
8000.00, 4000.00, 2000.00, 1000.00};
double R2 = 90.00;
int total;
//int V = 5;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
int s1, s2, s3, s4;
double effective;
for (int n = 0; n < 16; n++) {
effective = 0.00;
s4 = (n & 0x08 ? 1 : 0);
Serial.print(s4);
Serial.print(" ");
s3 = (n & 0x04 ? 1 : 0);
Serial.print(s3);
Serial.print(" ");
s2 = (n & 0x02 ? 1 : 0);
Serial.print(s2);
Serial.print(" ");
s1 = (n & 0x01 ? 1 : 0);
Serial.print(s1);
Serial.print(" ");
if (s1) effective = effective + (1 / R1[0]);
if (s2) effective = effective + (1 / R1[1]);
if (s3) effective = effective + (1 / R1[2]);
if (s4) effective = effective + (1 / R1[3]);
effective = (1 / effective);
// Serial.print(effective);
// Serial.print(" ");
total = (1023-((effective / (R2 + effective)) * 1024));
Serial.print(total);
Serial.print(" ");
Serial.print((total+)/10); // Note "linearising" tweak
Serial.println(" ");
}
}
void loop() {
// put your main code here, to run repeatedly:
}
It compiled and ran without error, now I am trying to compile again, and I get an error. I have tried this on IDE 1.5.7 IDE 1.6.0 and IDE 1.0.6 all give
sketch_jan02a.ino: In function ‘void setup()’:
sketch_jan02a.ino:36:26: error: expected primary-expression before ‘)’ token
I even tried a restart of my computer, no different.
Can ANYBODY tell me what that function is… and why it is not now working for me.
I appreciate what you are saying, and I am very well aware of the error I am receiving, but did you read all of my original post? That code compiled and ran when I tried it 2 days ago!!!
So can I reiterate.... What does that function do, and why is not working for me now?
ghlawrence2000:
I appreciate what you are saying, and I am very well aware of the error I am receiving, but did you read all of my original post? That code compiled and ran when I tried it 2 days ago!!!
So can I reiterate.... What does that function do, and why is not working for me now?
Thanks,
Graham
I can't explain what I can't see. What I can tell you for certain is that the code, as it is here, absolutely did NOT compile. That line is not valid c syntax.
When code is bad, don't ask yourself why it did work before. Bad is bad. Fix it.
I don't know what that code does. Is it code for the Arduino Due, or the normal Uno/Nano/Micro boards ?
This was the result of ((total+)/10). I really cannot explain why it did work… So assume, I imagined it… how do we linearise the list shown… (using code that works)?
Thanks,
Graham
Edit: Ok so I must have dreamed it worked… I see if we use ((total+5)/10) That works and is actually syntax I understand