Go Down

Topic: Please Compile These codes (Read 304 times) previous topic - next topic

nikhilkaushik

Please add these two Urgent

First

const int VAL_PROBE = 0; //Analog pin 0 
 const int MOISTURE_LEVEL = 450; // the value after the LED goes on 
 void setup() 
 { 
  Serial.begin(9600); 
  pinMode(13, OUTPUT); 
  pinMode(7, OUTPUT); 
 } 
 void LedState(int state) 
 { 
  digitalWrite(7,state); 
 } 
 void loop() 
 { 
  int moisture = analogRead(VAL_PROBE); 
  Serial.print("Moisture = "); 
  Serial.println(moisture); 
  if(moisture > MOISTURE_LEVEL) 
  { 
   LedState(HIGH); 
   digitalWrite(13,LOW); 
  } 
  else   
  { 
   LedState(LOW); 
   digitalWrite(13,HIGH); 
  } 
  delay(500); 
 } 

Second

#include <LiquidCrystal.h>
LiquidCrystal LCD(10, 9, 5, 4, 3, 2);
void setup()
{
  Serial.begin(9600);
  pinMode(A0, INPUT);
  LCD.begin(16,2);   
}
void loop()
{
  int SensorValue= analogRead(A0);
  Serial.print(SensorValue);   
  Serial.print(" - ");
  if(SensorValue >= 1000)
{
   Serial.println("not in Soil or DISCONNECTED");
   LCD.setCursor(0,0);
   LCD.print("NOT IN SOIL");
   LCD.print("             ");
  }
  if(SensorValue < 1000 && SensorValue >= 600)
{
   Serial.println("DRY");
   LCD.setCursor(0,0);
   LCD.print("DRY");
   LCD.print("             ");
  }
  if(SensorValue < 600 && SensorValue >= 370)
{
   Serial.println("HUMID");
   LCD.setCursor(0,0);
   LCD.print("HUMID");
   LCD.print("             ");
  }
  if(SensorValue < 370)
{
   Serial.println("WATER");
   LCD.setCursor(0,0);
   LCD.print("WATER");
   LCD.print("             ");
  }
  LCD.setCursor(0,1);
  LCD.print("                 ");
  LCD.setCursor(0,1);
  LCD.print(SensorValue);
  delay(1000);
}



Robin2

Please add these two Urgent
When someone says "Urgent" my first reaction is to put it at the bottom of my IN tray.

When someone expects a quick response it is a good idea to first read How to use the Forum  so that you can make it as easy as possible for people to help you.

It is also useful to get the Title right. I think you mean "combine" rather than "compile". If so this Simple Merge Demo may help.

Before trying to merge the programs go through each of them carefully to make sure they are not trying to use the same resource - for example an I/O pin. If you find conflicts change something in one of the separate programs and make sure it still works with the change.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Grumpy_Mike

#2
Feb 08, 2019, 02:37 am Last Edit: Feb 08, 2019, 02:40 am by Grumpy_Mike
Or you can read this:-
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

Note on using delay at the end of a function the delay you will see is the total delay of both code sections, so you might want to change them.

Why have you posted this in this section can you not read what this section is about? it says:-
Quote
Interfacing w/ Software on the Computer

Firmata, Processing, Max/MSP, PureData, VVVV, etc.
Which is about interfacing OTHER languages running on a COMPUTER with the Arduino.

Go Up