thanks paul, what you think now?
//This is my first ever sketch i am writing for my 2650. i might need help.
//This sketch will eventually control my camper with my droid or voice.
//I will worry less about things going wrong with my off grid trailer.
//Worrying can lead to high anxiety. Stress affects you emotionally and physically.
//Start of my pins
int Water = 22; //Voltage sensor for my SeeLevel II water tank sensor strip
int Tank1 = 24; //load sensor pin for propane tank 1
int Tank2 = 26; //load sensor pin for propane tank 2
int Humid1 = 28; //pin for humidity sensor inside
int Humid2 = 30; //humidity sensor inside
int Temp1 = 42; //DS18B20 temperature sensor under camper
int Temp2 = 34; //DS18B20 temperature inside camper
int Volts = 36; //battery bank voltage
int Amps = 38; //amps being used
int Relay1 = 40; //turns on a relay switch when Temp1 goes below 32degrees
int LED1 = A2; //white led lights up when i talk
int RB1 = A9; //red and blue warning led for Temp1
int RB2 = A10; //red and blue warning led for Tank1
int RB3 = A11; //red and blue warning led for Tank2
int RB4 = A12; //red and blue warning led for low Water
int Light1 = A12; //Will control 1156 bulbs inside. or maybe i need digital pin.
int Light2 = A13; //Will control 1156 bulbs inside. and might need some relays.
int Light3 = A14; //Will control 1156 bulbs inside. what did i get myself into?
int Light4 = A15; //Will control 1156 bulb outside.
int val = 0; //not sure what this pin does but its needed
//end of my pins
//Start Code for one Electret mini condenser microphone pins
// these constants won't change:
int ElectretLED1 = A2; // led connected to analog pin 2 will light up when i talk
int Electret1 = A1;//amplifier output connected to analog pin 1
// these variables will change:
int sensorReading = 0;// variable to store the value read from the sensor pin
int sensorMax = 2000;
int sensorMin = 0;
int threshold = 600;
//End Code for the electret microphone
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // initialize serial communications
pinMode(Temp1, INPUT);
pinMode(Temp2, INPUT);
pinMode(Tank1, INPUT);
pinMode(Tank2, INPUT);
pinMode(Humid1, INPUT);
pinMode(Humid2, INPUT);
pinMode(Electret1, INPUT);
pinMode(Water, INPUT);
pinMode(Volts, INPUT);
pinMode(Amps, INPUT);
pinMode(LED1, OUTPUT);
pinMode(RB1, OUTPUT);
pinMode(RB2, OUTPUT);
pinMode(RB3, OUTPUT);
pinMode(Relay1, OUTPUT);
pinMode(Light1, OUTPUT);
pinMode(Light2, OUTPUT);
pinMode(Light3, OUTPUT);
pinMode(Light4, OUTPUT);
pinMode(ElectretLED1, OUTPUT);
//end my pinmode code
//Start Code for Electret1 microphone
analogWrite(A2, HIGH);
while (millis() < 3000) {
threshold = analogRead(Electret1);
// record the maximum sensor value
if (threshold > sensorMax) {
sensorMax = threshold;
}
}
// signal the end of the calibration period
analogWrite(A2, LOW);
threshold = sensorMax;
//End Code for Electret1 microphone
}//end setup
void loop() {
//two load sensors outside to measure how much propane i have in each 20lb tank
if (digitalRead(Tank1) <= 17)
{
digitalWrite(RB2, HIGH);
}//led alerts me when 20lb propane tank 1 is low
if (digitalRead(Tank2) <= 17)
{
digitalWrite(RB3, HIGH);
}//led alerts me when 20lb propane tank 2 is low
if (digitalRead(Tank1) >= 18)
{
digitalWrite(RB2, LOW);
}//led is off for propane tank 1
if (digitalRead(Tank2) >= 18)
{
digitalWrite(RB3, LOW);
}//led is off for propane tank 2
//end two load sensors outside to measure weight of propane tanks
//start DS18B20 temperature sensor under camper.
if (digitalRead(Temp1) <= 0)
{
digitalWrite(Relay1, HIGH);
}//turns on heat tape or something to
//warm up a outside pipe with using the least amount of power at night.
if (digitalRead(Temp1) >= 1)
{
digitalWrite(Relay1, LOW);
}//and then shuts it off
if (analogRead(Temp1) <= 0)
{
analogWrite(RB1, HIGH);
}//turns on warning LED inside
if (analogRead(Temp1) >= 1)
{
analogWrite(RB1, LOW);
}//and shuts LED off
//end flashing warning led for DS18B20 temperature sensor
//Start reading the water voltage sensor that i will need help with!
int sensorValue = digitalRead(22);
// Convert the digital voltage reading from (11V - 15V) to a percent (0% - 100%)
float voltage = sensorValue * (11.0 / 15.0);
Serial.print("Voltage: ");
Serial.println(voltage); // print out the value you read:
// end reading the water voltage sensor
//start electret code
//read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(Electret1);
// if the sensor reading is greater than the threshold:
if (threshold>600) {
(LED1, HIGH);
}
if (threshold<600) {
(LED1, LOW);
} //end electret code
//now i will display all sensors onto my laptop somehow. Help?
//in the future these will be displayed on my droid app.
Serial.print("Water: ");
Serial.print(Water);
Serial.println("");
Serial.print("Tank1: ");
Serial.print(Tank1);
Serial.println("");
Serial.print("Tank2: ");
Serial.print(Tank2);
Serial.println("");
Serial.print("Temp1: ");
Serial.print(Temp1);
Serial.println("");
Serial.print("Temp2: ");
Serial.print(Temp2);
Serial.println("");
Serial.print("Humidity: ");
Serial.print(Humid1);
Serial.println("");
Serial.print("Volts: ");
Serial.print(Volts);
Serial.println("");
Serial.print("Amps: ");
Serial.print(Amps);
Serial.println("");
//end of this stuff. lol
delay(1000); //this rechecks every 1 second?
}
