I am running on a Win7 x64 system and using Arduino 022 IDE.
Here's what just happened using the following code:
#include "Tlc5940.h"
]#include "math.h"
void setup() {
Serial.begin(9600);
Serial.println ("setup start");
Serial.println (millis());
}
void loop(){
Serial.print("loop start");
Serial.println(millis());
delay (1000);
}
RESULT is fx`f~ actually the line is much longer but this is all I got with copy/paste. Gibberish and all on one line.
The includes are there because they are vital to the main program I'm working with. I also just tried same code without the includes and the results were same as above.
I also just tried with a different UNO board and the results were the same.
NOTE - all of the above was done on a WIN7 x64 platform which is my base system.
NOW - the following is from an XP system in Virtual PC on the same computer.
here's the code:
#include <math.h>
int ledpinyellow = 3;
int ledpingreen = 5;
int ledpinred = 9;
int currentmillis=0;
int previousmillis=0;
double startmillis=0;
int N=0;
double clockint=50;
double ledstep = -1;
double x=0;
double y1=0;
double y2=0;
double y3=0;
double z1=0;
double z2=0;
double z3=0;
void setup (){
Serial.begin(9600);
x=0;
y1=0;
Serial.println("millis");
Serial.println(millis());
previousmillis=millis();
currentmillis=millis();
}
void loop (){
currentmillis=millis();
while(currentmillis-previousmillis<clockint){
delay(10);
currentmillis=millis();
}
previousmillis=currentmillis;
ledstep +=1;
x=10* ledstep*(clockint/1000);
if (x >0 & x <9){
y1= 4*4*x;
analogWrite(ledpinyellow, y1);
analogWrite(ledpingreen,255);
}
if (x>=9 & x<=10 ){
analogWrite(ledpingreen,0);
analogWrite(ledpinyellow,y1);
}
if(x>10 & x<= 20.5){
y1=4.7*50*sin(.15*x+.1)+18;
analogWrite(ledpinyellow,y1);
}
Serial.println("x");
Serial.println(x);
Serial.println(y1);
Serial.println(y2);
Serial.println(y3);
if (ledstep >=50){
ledstep = -1;
Serial.println("time");
Serial.println(millis()-startmillis);
startmillis=millis();
}
}
and the result is:
millis
6
millis
6
x
0.00
0.00
0.00
0.00
x
0.50
and it goes on
so this result looks very good and is what is expected.
However, when I load my main program - here's the first several lines of setup -
note: I have attached the complete program in a file.
void setup() {
Serial.begin(9600);
Tlc.init();
Tlc.clear();
Tlc.update();
// delay(1000);
Serial.println ("setup start");
Serial.println (millis());
//************************** wakeup begins **********************
x=0;
y1=0;
prevmillis=millis();
curmillis=millis();
while(ledstepint<50){
curmillis=millis();
while(curmillis-prevmillis<clockintdbl){
delay(10);
curmillis=millis();
}
prevmillis=curmillis;
ledstepint +=1;
x=10* ledstepint*(clockintdbl/1000);
/////////////////////////////////////////////////////////////////////////
if (x >0 & x <9){
y1= 4*4*x;
}
if (x>=9 & x<=10 ){
y1=255;
}
if(x>10 & x<= 20.5){
y1=4.7*50*sin(.15*x+.1)+18;
}
/////////////////////////////////////////////////////////////////////////
brt[ledstepint]=y1;
// Serial.println(y1);
}
ledstepint=-1;
// delay (2000);
Serial.println ("setup ends");
Serial.println (millis());
//***********
THE RESULT is blank - nothing at all. This only thing that changed here is the program I loaded into the UNO.
This is driving me nuts and wasting a lot of time - would very much appreciate help.
I just saw a few posts that came in as I was preparing this reply. Before my current problems, I have used Serial.println (millis()) many times with no problems at all.