Wel,l isn't tht the way with everything. My sister lives on Nantucket and she went in to have new rear brakes installed. They gave her a quote of $4100 on a 6 year old vehicle. I remember when I got my pickup truck. Brake pads were going to be $32, I was livid. Hadn't paid more than $18 before that. Beyond availability, there is becoming this technical divide. When I am at home I have a lot of access to new electronics. At camp I scavange things from the town dump. Can't beat an old UPS for parts. I am trying to show that you don't have to spend a lot of money to have cutting edge technology. I would never have a micro system without a couple spare processor boards. $15 is cheap for a spare. When all else fails, substitution is good diagnostic and 5 years from now tht great board won't be available.
Nack to programming. Math requires a little attention. 2 + 2 = 4, but 20,000 + 20,000 won't necessarily be 40,000. In most cases it will be a negative number. There are ways to do larger numbers. Just do some quick math and avoid situations where numbers go beyond 32K. Interger division can be another problem. The remainder is truncated so 100 divided by 51 = 1. Using larger sample sizes will give acceptable results. I love copy and paste but it can often waste more time than it saves. It is easy to forget to change a variable name in a line of code. Then when the code fails to work it takes forever to find the problem. That variable looks so familiar you look at it a hundred times and it swtill looks right. I had a section of tested code I knew worked. some time later it didn't. I had coppied a section of code and instead of copy and paste I must have clicked cut. The compiler is pretty good about finding code errors and it will highlight a line. If you don't see the problem in that line, look at the one just before. When doing logic statements...... if ( X = 30) is not the same as ... if (X==30). The first will always be considered TRUE. Only the second with == is a logical statement. The first code will compile and you will look at that line a long time before you figure it out.
I have told you how nice it is to have a debug screen when writing a program and it would sure be nice to just plug in the laptop and get run data at the end of the day. In the troubleshooting anouncments there was a mention that Mac and UNIX users would find that connecting the USB cable would reset the UNO and all data would be lost. It appears this is the same for Windows 7. I wanted to get the daily running total so I used one of the six available PWM outputs. Connecting the output through a 22K ohm resistor to a 1uF capacitor will allow an intergrated voltage to be read corresponding to run time. Cooltime was used as the variable for the PWM. Since I never expected cooltime to be over 255 no conversion was necessary.
The following is an example of how to output temperature. It is desired for the nominal temperature of 0 to 47 degrees to be read by a digital voltmeter. The maximum output of the PWM is about 4.7 volts which woule correspond to 47 degrees. MAP is used to convert the numbers. 47 is converted to 255, the maximum number the PWM can take. The IF statement limits the maximum number the PWM will see. It is prefered you use the constrain statement instead.
// Convert cooltime to an analog PWM signal at pin 5 so it can be reas by an external meter
meter = map (TEMP, 0, 47, 0, 255); // convert 0-47 to 0-255 Values can extend beyond those limits
if (meter > 255) meter = 255; // limit the upper end of meter to 255 max PWM can take
// OR a better way is to use constrain to limit upper and lower
meter = constrain(meter, 0, 255); // limits range of sensor values to between 0 and 250
analogWrite(11, meter); // analogWrite values from 0 to 255
An analog meter can be used instead. Just use a meter of 1ma or less and select an appropriate resistor that would cause a full scale reading if connected to 5V.