64 yr old newby would like some help

Hi Ray,

  // This line sets the RTC with an explicit date & time, for example to set
  // May 21, 2015 at 6pm you would call: (use 24 hour time)
  //    rtc.adjust(DateTime(2015, 5, 21, 18, 0, 0));

Oh, my bad; I must have copied some of that from "The Internet".. :frowning:

Invoking / executing / (Yes you're right we used to say "call" a subroutine (Now usually called a function).

So:

rtc.adjust(DateTime(<4-digit year>, , , <24-hour hour>, , );

.. is how this works.

(This example is from this page):

http://arduino-info.wikispaces.com/DS1307_RealTime_Clock_Brick

I will update that example to be clearer.

Also it may not be clear: You would UPLOAD/RUN this sketch to SET the time. THEN you would write your own code, or comment OUT those lines to come back and run this sketch later to check how the RTC is doing...

Glad to see you are exhibiting the primary Engineering skill: Persistence!

By the way, get into the habit of commenting your lines of code.
Reason, when you are 65, it will remind you what is happening.

Example:

  //To set the RTC time:
  //uncomment the third line down, as needed make changes to: SS,MM,HH,DD,DT,MM,YY  
  //upload this sketch, comment the line again, upload this sketch again!!!
  //DS3231         SS,MM,HH,DD,DT,MM,YY
  //setDS3231time (45,14,18, 1, 8, 5,16); //uncomment to set the RTC time

"persistence"

Amazin' how some of Larry's lines creep into my code...

Just happened again...

I got it running at the right time. It'd be nice on normal time, but that can come later.

I LOVE the mouse!!!

Can I set all my sensors as "calls" or "subs"? It would really reduce the lines to sort thru to adjust my ifs based on those static values.

Thanks for the laughs and the info.

Some people suggest putting blocks of code into there own separate functions.
In the loop() function you add 'calls' to these functions, loop() runs over and over.
This may help keep your code easier to follow and debug.

I'm one of those Some People... See this page for example:

http://arduino-info.wikispaces.com/YourDuinoStarter_AutomationExample

The loop has just 3 functions it calls:

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  ReadSensors();  // Each of these is a function defined below
  MakeDecisions();
  TakeActions();

  delay(1000);     // Wait 1 second
}//--(end main loop )---

I have used that basic framework in pretty complex sketches, such as controlling a multi-zone high temperature kiln.

RayJorgensen:
I got it running at the right time. It'd be nice on normal time, but that can come later.

Can I set all my sensors as "calls" or "subs"? It would really reduce the lines to sort thru to adjust my ifs based on those static values.

Thanks for the laughs and the info.

Good to hear you are having fun Ray.
One of the keys to programing is getting the code structured, so grouping into functions helps in code layout, execution and the all important debug or "what the ???" part of the "fun"
So for a simple Temperature and Humdity weather station it could be like this;
Its just some pseudo code and C++ just to illustrate the principle.

include libraries

// assign global variables
int TempRead;
int HumdityRead;
int TempDegC;
int HumPercent;
// etc

int TempPin = A0;
int HumPin = A1;
// etc

void setup() {
  Serial.begin(9600); // if you are going to display to monitor
  // setup I/O
  pinMode(TempPin, INPUT);
  pinMode(HumPin, INPUT);
  etc

}
//== == = Main Loop == == ==
void loop() {
  ReadInputs();
  ConvertValues();
  Display();
  SendToMonitor();
}
//== == Functions == == =
void ReadInputs()
{
  TempRead = analogRead(TempPin);
  HumidityRead = analogRead(HumPin);
}
void ConvertValues()
{
  TempDegC = TempRead * some scale factor;
  HumPercent = HumidityRead * some scale factor;
}
void Display()
{
  // some code that uses TempDeC and HumPercent and puts it on a dislay
}
void SendToMonitor()
{
  // some code that sends TempDeC and HumPercent to serial monitor
}

I hope it helps, forum members feel free to comment.

Tom.. :slight_smile:

Terry our minds think alike... bloody scary.. :o :o :o :o :o

Tom, we've both done A Lot Of This:

Design and Repair of industrial control systems.

And we have preserved our selves and our sanity.

Apparently.

I think that explains it.

Tom.. :o

You guys are cracking me up - old fogies teaching/learning, in "old fogy" ways. Being one myself (though rarely admitting it), I'm kinda getting a kick out of it all.

I'm certainly enjoying and learning from all THANKS.

I'm hooking up my waterproof temp sensors.I'll end up having at least 8 of these. Can I use 1 - 4.7 ohm resistor for multiple sensors or do I need 1 for each?

Just cause I'm curious - why the resistor between 5v and signal?

This should work:

or

BTW
4.7 Ω IS NOT 4.7K

Read Terry's discussion here:
http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20

Thanks Larry. How do you make the ohm sign?

RayJorgensen:
How do you make the ohm sign?

Ω

I made a macro on the iPad called:
ohm...

When the browsers editor sees the character sequence, ohm... is replaced with the Ω symbol that I copied from the web.

I did the same with:
mic... μ
and
div... ÷
and
pi... π

Well, I don't know how to do that nor do I have a desire to!!! How should I notate a "omh" with the keyboard on my computer? Just so we all know what we are talking about. I tested the resistor with the meter to make sure a had the right one.

We sometimes use R or K or M

4.7ohm >>>- - - > 4R7

220Ω >>>- - - > 220R

2,200 ohm >>>- - - > 2.2K

2,200,000 ohm >>>- - - > 2.2M

ray - if you google u will extract lot of relevant info. that's how i did my robot
it involved a lot of reading and getting the right stuff from ebay.

regd age - i began last year arduino with no electronic exp. only i could cut code. i am 70.

in two months i had a proto-type robot going with sensors and and now its
a bit complex with stepper motors and laser beams and OLED display.

trying to chat with the entity now - the next step.

i began with zx81 micro comp - the home computer connected to tv!

all the very best!

sunil