Several of you Gurus have been good enough to give me pointers, recently, which have enabled me to fix problems I have had.
Now I have another one for you. ("Groan", did I hear??).
I am writing a sketch that enables "surplus energy" from a solar system, ie after the battery reaches full charge, to be used to drive particular devices.
Up till now, the testing and debugging has gone well, but I have hit, for me, a solid wall.
In the sketch, I jump to a function readPulseButton(), which is where things go wrong.
Using Serial.println, I step my way through it. Knowing I need to check if the pulse button is pressed, I read the digital pin and I can see it toggling at the #1 block of Serial.print, but at #2, it is solidly latched at 0.
I would be very grateful if one of you would be so kind as to tell me how and where I have stuffed up.
Note: later functions, have not been tested yet, and are bound to contain bugs.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Thanks.. Tom...
With 12 kB size? I doubt it, last time I encountered it, the post limit was 9 kB.
while (count < 3)
{
store = ((float)analogRead(A2) / 1023) * 5 * 4.8; // acquire and process ADC value to give result in volts
batteryVoltage = batteryVoltage + store; // add the values together
count++; // increment counter
delay (50);
}
count = 0;
May or may not be a problem, but shouldn't you reset batteryVoltage before you start adding data to it?
#4 - Well spotted. It didn't seem to cause issues, when I debugged that bit, but it sure as hell should. Looked back at the earlier iterations, and lo and behold, there is battery = 0. Did I accidently delete it? or Whoops!
#5 - Yes. You read it correctly, and yes it did, still does, scramble my brains when debugging. I thought about using ! but decided to try it at the next iteration, once it is working.
Pert
#6 - I like your idea. Being new to this game I had missed the fact that int is a 2 byte variable, while byte is, well a byte. Less memory usage. Nice one.
PaulS
See comment on #4, above.
I don't know why it didn't go feral on me. That part of the sketch is read every circuit of the loop and there will always be a voltage of between roughly 2v and 4v. Luck, or maybe even a bug, must have been on my side that day. :-))