Go Down

Topic: 64 yr old newby would like some help (Read 985 times) previous topic - next topic

RayJorgensen

My parts haven't come yet but I've been working with Fritzing and learning quite a bit.  I've attached the file if someone can take a look.  I think I have most everything hooked up right.  The clock has one post I don't know where to connect. Don't worry about criticism this is my first venture into anything like this.

Second question:  Next I'll start on on coding. Where can I find a list of functions that are available.  My searches haven't yielded much. (wrong wording I'm sure)

Thanks

RayJorgensen

Hopefully this is the file.

terryking228

#32
Dec 08, 2017, 02:52 am Last Edit: Dec 08, 2017, 02:54 am by terryking228
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

RayJorgensen

Part are to be here Friday.  I'm like a kid a Christmas - can't wait.

I'm going to end up with 15 sensors at least.  8 of them will just be straight temp  sensors. So I've got test code for all diff sensors as separate sketches. I'll test one at a time.  How am I doing so far?

After all test out I'll hook all of them up and test.  If I pass then on to controlling with all of the "if statements". 

I see no reason to sample the senors more that every minute.  Can I put a delay ahead of the block that will control all of them?

The exception will be the soil moisture sensor, I'm thinking every 30 minutes is more than enough.  (Save the sensor).  How do I handle that?  Won't a delay statement cause the program to just sit at that spot?

All this data will be collected by an excel macro.  I hope to see "cause and effect" which will help tweek the values in the sensors or the control statements.

Thanks in advance!!!!!   I can't wait to get going!!

DrAzzy

I see no reason to sample the senors more that every minute.  Can I put a delay ahead of the block that will control all of them?

The exception will be the soil moisture sensor, I'm thinking every 30 minutes is more than enough.  (Save the sensor).  How do I handle that?  Won't a delay statement cause the program to just sit at that spot?

Yes, that's exactly what delay would do; that's why you shouldn't use delay for that sort of thing.

See this thread - this is one of the most common questions people have once they get over the basics with Arduino (really, it's one that basically everyone doing anything with Arduino soon runs into). The solution is to do the timing with millis() and check those times, rather than using blocking delays.  http://forum.arduino.cc/index.php?topic=223286.0

If you're ever making a delay longer than a few hundred milliseconds, you should stop and ask yourself if you should be using millis()
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

larryd

I like the enthusiasm you youngsters have!

If you want to schedule things to happen, this example shows some ways of doing so.

Code: [Select]

//Simple BWD BlinkWithoutDelay examples
//
//Timer variables used
unsigned long currentMillis;
unsigned long pin13Millis;
unsigned long pin12Millis;
unsigned long SwitchMillis;
 
//if these are not changed in the sketch, they can be const
unsigned long debounceMillis = 50UL;  //50ms
unsigned long ledOnTime      = 500UL; //500ms seconds
 
byte lastSwitchState = HIGH;
byte buttonState     = HIGH;
 
//enable/disable flags
boolean flag13 = true;
boolean flag12 = false;
 
const byte Switch = 2; //pushed = LOW
 
//**********************************************************************
 
void setup()
{
  Serial.begin(9600);
 
  digitalWrite(13,LOW);
  pinMode(13, OUTPUT);
 
  digitalWrite(12,LOW);
  pinMode(12, OUTPUT);
 
  pinMode(Switch, INPUT_PULLUP); //pushed = LOW
 
} //  >>>>>>>>>>>>>> E N D  O F  s e t u p ( ) <<<<<<<<<<<<<<<<<
 
void loop()
{
  //save the current time
  currentMillis = millis();
 
  //*************************************
  //Heartbeat LED
  //Toggle LED on and off. Helps show if there is blocking code
  if (flag13 == true && currentMillis - pin13Millis >= ledOnTime)
  {
    pin13Millis = millis();            //re-initialize Timer
    digitalWrite(13,!digitalRead(13)); //toggle LED condition
  }
 
  //*************************************
  if (flag12 == true && currentMillis - pin12Millis >= 5*1000UL)
  {
    //Turn off pin 12
    digitalWrite(12,LOW); //Turn off LED
    flag12 = false;       //disable timing
  }
 
//*************************************
//is it time to check the switches?
if (currentMillis - SwitchMillis >= debounceMillis)
{
//code here runs every debounceMillis ms
SwitchMillis = millis(); //re-initilize Timer
//go and check the switches
checkSwitches();   
}
 
  //*********************************
  //put other non-blocking stuff here
  //*********************************
 
} //  >>>>>>>>>>>>>> E N D  O F  l o o p ( ) <<<<<<<<<<<<<<<<<
 
 
//======================================================================
//                      F U N C T I O N S
//======================================================================
 
 
//****************** c h e c k S w i t c h e s ( ) *********************
//switches are checked every debounceValue milli seconds
//no minimum switch press time is validated with this code (i.e. No glitch filter)
void checkSwitches()
{
  //re-usable for all the switches
  boolean thisState;   
 
  //check if this switch has changed state
  thisState = digitalRead(Switch);
  if (thisState != lastSwitchState)
  {
    //update the switch state
    lastSwitchState = thisState;
 
    //this switch position has changed so do some stuff
    //"LOW condition code"
    //has switch gone from HIGH to LOW?
    if(thisState == LOW)                         
    {
      //Do some LOW switch stuff here
      flag12 = true;          //allow timing
      digitalWrite(12, HIGH); //turn on LED
      pin12Millis = millis(); //initialize Timer
    }
 
  } //END of Switch code
 
  //*****************************************
  // similar code for other switches goes here
  //*****************************************
 
} //END of checkSwitches()
 
//**********************************************************************
 
//======================================================================
//                      E N D  O F  C O D E
//======================================================================
     
No technical PMs.
The last thing you did is where you should start looking.

RayJorgensen

Thanks for the link and the sample code.  I'll take a while for me to understand, I'm sure!!

Parts just came - Chistmas early!!!!!!!!

justjohn

Thanks for the link and the sample code.  I'll take a while for me to understand, I'm sure!!

Parts just came - Chistmas early!!!!!!!!
Great to see this kind of enthusiasm and excitement over this kind of thing. :-)

Go Up