Jump to content

Another Arduino thread..


davidb

Featured Posts

I have put what I think are my problem areas in red bold, near the bottom. I still don't get any arduino IDE colours in the forum's file attachment area, but of course I could do a screenshot of the problem area if required, thanks for looking, D

__________________________

 

//millis25Mar

int stoke = 2;              // INPUT Stoking Temp Sensor (Bottom of store)
int houseUFH = 3;           // OUTPUT UFH Relay ( not involved with millis problem)
int runPin = 4;             // INPUT Heat Available for distribution stat (Top of accumulator tank 56deg)

int alarm = 7;              // OUTPUT Alarm Light Relay

int veryHot = 9;            // INPUT  Boiler too hot 85deg
int logStoreUFH = 10;       // OUTPUT Log Store UFH Relay (heat sink for excess heat)
int butt = 12;              // INPUT from alarm cancel Button
int buttonPressed = 0;
int ledPin = 13;            // OUTPUT Indicator (built in LED)


unsigned long previousMillis = 0;      // will store last time LED was updated

const long interval = 40000;           // interval at which to blink (milliseconds)

int dt = 100; // Delay of 100 milisecs

void setup() {
 
  Serial.begin(9600);

  pinMode(stoke, INPUT);          // stat acts 70deg     pin 2
  pinMode(houseUFH, OUTPUT);      // Yellow Relay Wire   pin 3
  pinMode(runPin, INPUT);         // stat acts at 56deg  pin 4
  pinMode(alarm, OUTPUT);         // Blue Relay Wire     pin 7
  pinMode(veryHot, INPUT);        // stat acts at 85deg  pin 9
  pinMode(logStoreUFH, OUTPUT);   // Green Relay Wire    pin 10
  pinMode(butt, INPUT_PULLUP);    // cancel button       pin 12 (with external pull up resistor)
  pinMode(ledPin, OUTPUT);        // Indicator LED       pin 13

}

void loop() {

  delay (dt * 5);

unsigned long currentMillis = millis();

  int analog = analogRead(myPin);     // Reads data from myPin (A2) pin and puts in analog Int
  int readRun = digitalRead(runPin);  // Reads data from runPin (4) and puts it in readRun Int
  int readStoke = digitalRead(stoke); // Reads data from stoke (2) and puts in readStoke Int
  int readAlarm = digitalRead(alarm); // Reads data from alarm (7) and puts in readAlarm Int
  int readHot = digitalRead(veryHot); // Reads data from veryHot (9) and puts it in readHot Int
  int readButt = digitalRead(butt);   // Reads data from butt (12) and puts it in readButt Int

  Serial.print("   Stoke  =   ");     // next 6 lines for printing to serial monitor
  Serial.println(readStoke);
  Serial.print("   button pressed  =   ");
  Serial.println(readButt);
  Serial.print("   Millis  =   ");
  Serial.println(millis());

  if ((readStoke == 0) && (readButt == 1)) {   // boiler is too cold and button is untouched

    Serial.println("Boiler Requires Stoking");
   
    digitalWrite(ledPin, HIGH);                // starts indicator LED flashing
    delay (dt);
    digitalWrite(ledPin, LOW);
    delay (dt);                                // ends indicator LED flashing
    digitalWrite(alarm, HIGH);                 // lights alarm light pin 7
  }                                          

  if (readButt == LOW) {      // when the button is pressed set buttonPressed to 1
    buttonPressed = 1;        // if the temperature is too low have the criteria that the cancel button has also not been pressed.
                              //  this is Jen's addition, not sure of the logic here!

    digitalWrite(alarm, LOW);              //   illuminates alarm lED

    if (currentMillis - previousMillis >= interval) { // saves the last time alarm was triggered

      digitalWrite(alarm, HIGH);   //   not sure of this either!    to reset buttonPressed to zero when the temperature
    }                              //   recovers, so it will alarm again the next time it drops too low.
    else {
      digitalWrite(ledPin, LOW);
      digitalWrite(alarm, LOW);
    }
  }
}
 

 

Link to comment
Share on other sites

On 24/03/2021 at 20:46, davidb said:

yes, you were correct, I just fiddled about adding and removing curlys till it worked. Its very odd at times, but incredibally clever overall. Thanks

Use Textwrangler or other free editors, they have really good features to help you identify your bracket pairings. (and other syntax errors). It is easy to tell the Arduino IDE that you are using an alternative editor.

Edited by system 4-50
Link to comment
Share on other sites

Textwrangler has been superceded by BBedit which won't work on my old Imac or Macbook, I shall see if it works on a Win7 laptop later. Otherwise, do you have any other suggestions please? I have got   http://www.sublimetext.com  running but it looks like another steep learning curve for me at first glance.

 

thank you, David

Link to comment
Share on other sites

Trying to troubleshoot this code again and running various things though the serial monitor (on right of screenshot) - the millis are inceasing normally, but it isn't returning anything for currentMillis or previousMillis, but the interval is printing correct at 4000.

 

While running the sketch, everything is fine but holding the button pressed extiguished the alarm, but it comes back within a second when released.

 

I'll try and find a tutorial on millis now

 

 

1048113185_ScreenShot2021-03-26at19_34_43.png.7a196ab54f48383bc1a1aa50f13a8de2.png

Link to comment
Share on other sites

  • 1 month later...

We did the link a fortnight ago and ascended the Wigan flight on Thursday with great help from the Wigan Flight Crew, thanks again for a great service!

 

There are not enough Ribble Link videos available on YouTube yet, so here is my contribution, mainly experimenting with an old GoPro:

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.