newbies first attempt

ok so firstly let me make it clear that i am aware that the code is missing a lot before it will work… this is the first attempt at writing anything from scratch so forgive me… i guess what I’m looking for from you guys is more direction? … iv spent the last 2 weeks reading and re-reading websites etc. to try and get a handle on things but its very difficult as I’m sure you’re all aware… i believe the sketch is at very least legible, enough so that it should be clear what I’m trying to accomplish… just looking for help completing the parts i cant figure out such as button pushes, how to play a melody over a speaker and temp readings using 2 types of sensors… :slight_smile: keep in mind we all have to start somewhere! lol

// hardware I’m using
// arduino mega
// 3x ds18b20
// 1 x SainSmart MAX31855 Module + K Type Thermocouple Thermocouple Sensor For Arduino
// Frentaly® IIC/I2C/TWI 2004 Serial Blue Backlight LCD Module for Arduino UNO R3 MEGA2560 20 X 4, 2004
// all momentary push buttons
//motorized ball valve open when power applied, closed when power removed

#include <OneWire.h>

#include <DallasTemperature.h>

int Ds = 3;
int GValve = 4;
int Pump = 5;
int Spark = 6;
int Pwr = 7;
int Safe = 8; //thermocoupler
int AlmRly = 9;
int Spkr = 10;
int TempUp = 11;
int TempDn = 12;

float InTemp = //1st ds18b20 temp
float OutTemp = // 2nd ds18b20 temp
float TubTemp = // 3rd ds18b20 temp
float Avr = (InTemp + TubTemp) / 2
float TempHi = 105 // pin 11 and 12 should influence this number up or down by 1 number at a time.
unsigned float TempLo = 100
int LowSense = 100 //ferinheight
int Heater = //thermocouple temp

void setup()
{
pinMode(Ds, INPUT);
pinMode(GValve, OUTPUT);
pinMode(Pump, OUTPUT);
pinMode(Spark, OUTPUT);
pinMode(Pwr, INPUT);
pinMode(Safe, INPUT);
pinMode(AlmRly, OUTPUT);
pinMode(Spkr, OUTPUT);
pinMode(TempUp, INPUT);
pinMode(TempDn, INPUT);
}

short press Pwr
digitalWrite (Pump, HIGH);
short press again
digitalWrite (Pump, LOW);

long press Pwr,
digitalWrite (Pump, HIGH);
delay(30000);
digitalWrite (Spark, HIGH);
delay(1000);
digitalWrite (GValve, HIGH);
delay(10000);
digitalWrite (Spark, LOW);
delay (10000);

if (Safe > Heater)
{
digitalWrite (GValve && Pump, HIGH);
}
else
{
digitalWrite (Gvalve, LOW);
digitalWrite (AlmRly, HUGH);
Spkr plays tone for (10000) //any generic beeps or simple melody

long press Pwr again,
digitalWrite (GValve, LOW);
delay (6000);
digitalWrite (Pump, LOW);

check and display temps, InTemp, OutTemp, TubTemp and eta till hot.base eta on speed of rise over last 5 minutes and known desired temp //in ferinheight on 20x4 serial enabled lcd

if (Avr => Temp && Safe > LowSense)
{
digitalWrite (GValve && Pump, HIGH);
}
else
{
digitalWrite (GValve, LOW);
delay(60000);
digitalWrite (Pump, LOW);
delay (10000);

if (Safe > LowSense)
{
//continue with previous statement
}
else
{
digitalWrite (Gvalve, LOW);
digitalWrite (AlmRly, HIGH);
Spkr plays tone for 10 seconds //any generic beeps or simple melody

continue monitering temps……

if (Avr <= TempLo)
{
digitalWrite (Pump, HIGH);
}
delay (30000);
digitalWrite (Spark, HIGH);
delay(1000);
digitalWrite (GValve, HIGH);
delay(10000);
digitalWrite (Spark, LOW);
delay (10000);

if (Safe > LowSense)
{
//continue with previous statement
}
else
{
digitalWrite (Gvalve, LOW);
digitalWrite (AlmRly, HIGH);
Spkr plays tone for 10 seconds //any generic beeps or simple melody

17 posts and still didn't read the How to use this forum?

When you post in code tags like you are supposed to, please auto format your code with ctrl-T before you do. The indentation is very bad.

Having said that, you will get nowhere with all those loooonnngggg delay() functions in it. You need to learn how to do more than one thing at a time, with millis().

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Can you explain what you are trying to accomplish, the application.

Have you started your sketch in stages.
Getting each stage to work separately then combine them when you have all your stages successfully complete.

Trying to get everything working at once is fraught with problems.

Thanks… Tom… :slight_smile: