Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« on: February 12, 2013, 10:18:57 pm » |
my white led dont light when i speak and my blue and red led does not go off after sticking the DS18B20 sensor in snow. for more info about this project, click my sig. //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 and/or voice. //I will worry less about things going wrong with my off grid trailer when away. //Worrying can lead to high anxiety. Stress affects you emotionally and physically.
int Water = 22; //Voltage sensor for my SeeLevel II water tank sensor strip int Tank1 = 24; //load sensor for propane tank 1 int Tank2 = 26; //load sensor for propane tank 2 int Humid1 = 28; //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 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 Temp2 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 does but its needed //end of my int pins
//Start Code for one Electret mini condenser microphone pins // these constants won't change: const int ElectretLED1 = A2; // white led connected to analog pin 2 will light up when i talk const 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 = 1023; int threshold = 1200; //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(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 electret microphone
}//end setup
//these will read inputs and write them somewhere that can be seen in a droid app. //and also to be seen on my laptop online when im home or away. i will need help. void loop() { val = digitalRead(Temp1); digitalWrite(Temp1, 0); val = digitalRead(Temp2); digitalWrite(Temp2, 0); val = digitalRead(Humid1); digitalWrite(Humid1, 0); val = digitalRead(Water); digitalWrite(Water, 0); val = digitalRead(Tank1); digitalWrite(Tank1, 0); val = digitalRead(Tank2); digitalWrite(Tank2, 0);
//two load sensors outside to measure how much propane i have in each 20lb tank if (Tank1 <= 17) {digitalWrite(RB2, HIGH); }//led alerts me when 20lb propane tank 1 is low if (Tank2 <= 17) {digitalWrite(RB3, HIGH); }//led alerts me when 20lb propane tank 2 is low if (Tank1 >= 18) {digitalWrite(RB2, LOW); }//led is off for propane tank 1 if (Tank2 >= 18) {digitalWrite(RB3, LOW); }//led is off for propane tank 2 //end load sensors
//start DS18B20 temperature sensor under camper. if (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 (Temp1 >= 1) {digitalWrite(Relay1, LOW); }//and then shuts it off if (Temp1 <= 0) {analogWrite(RB1, HIGH); }//turns on warning LED inside if (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 ((sensorReading >= threshold)) { Serial.println(sensorReading-threshold); //Will send only positive and absolute values of waveform }//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("");
delay(1000); //this rechecks every 1 seconds?
}
|
|
|
|
« Last Edit: February 14, 2013, 05:01:07 pm by TrailerTrash »
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #1 on: February 12, 2013, 11:19:49 pm » |
You lost me right here: val = digitalRead(Temp1); digitalWrite(Temp1, 0); val = digitalRead(Temp2); digitalWrite(Temp2, 0); val = digitalRead(Humid1); digitalWrite(Humid1, 0); val = digitalRead(Water); digitalWrite(Water, 0); val = digitalRead(Tank1); digitalWrite(Tank1, 0); val = digitalRead(Tank2); digitalWrite(Tank2, 0);
You are reading lots of things into val, and then discarding them. int Temp1 = 42; //DS18B20 temperature sensor under camper
...
//start DS18B20 temperature sensor under camper. if (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 (Temp1 >= 1) { digitalWrite(Relay1, LOW); }//and then shuts it off
Temp1 is always going to be 42 (the answer to the meaning of life, BTW) so there is no point checking if it is <= 0. You need to save the readings into variables (not just "val"). Even if you did: val = digitalRead(Temp1);
val will be 0 or 1. It won't ever be greater than 1. You are confusing the pin numbers with the readings you get from the pins.
|
|
|
|
|
Logged
|
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #2 on: February 13, 2013, 11:59:40 am » |
You are confusing the pin numbers with the readings you get from the pins.
well thanks for the reply. now what? pin number 42 output is either going to be below freezing 0c or above freezing 1c. and then i have to figure it out in F degrees cause im in usa
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
Offline
Sr. Member
Karma: 5
Posts: 398
|
 |
« Reply #3 on: February 13, 2013, 12:03:32 pm » |
We can use the metric system in the US if we want. That's what freedom is all about. Nobody making you use Fahrenheit.
|
|
|
|
|
Logged
|
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #4 on: February 13, 2013, 12:08:56 pm » |
We can use the metric system in the US if we want. That's what freedom is all about. Nobody making you use Fahrenheit.
i just learned Celsius yesterday, so i should let the user choose when i start on my droid code.
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #5 on: February 13, 2013, 12:10:35 pm » |
maybe i need the word "const" in front of all my int`s?
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 47
Posts: 1390
May all of your blinks be without delay
|
 |
« Reply #6 on: February 13, 2013, 12:13:26 pm » |
The first thing to do is to read the sensors properly as has been explained. This code val = digitalRead(Temp1); digitalWrite(Temp1, 0); looks at the pin you have named Temp1 (pin 42), stores it in a variable called val, then sets the same pin to 0 (LOW). The value read from the pin is never used again and, indeed , is overwritten very soon after and is, therefore, not available. What are those 2 lines of code, and several other like them actually meant to do ?
|
|
|
|
|
Logged
|
|
|
|
|
California
Online
Edison Member
Karma: 37
Posts: 1840
|
 |
« Reply #7 on: February 13, 2013, 12:14:16 pm » |
maybe i need the word "const" in front of all my int`s?
The first thing you should do is fix the complete lack of indenting.
|
|
|
|
|
Logged
|
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #8 on: February 13, 2013, 12:20:58 pm » |
The first thing to do is to read the sensors properly as has been explained. This code val = digitalRead(Temp1); digitalWrite(Temp1, 0); looks at the pin you have named Temp1 (pin 42), stores it in a variable called val, then sets the same pin to 0 (LOW). The value read from the pin is never used again and, indeed , is overwritten very soon after and is, therefore, not available. What are those 2 lines of code, and several other like them actually meant to do ? i will delete those then
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #9 on: February 13, 2013, 12:27:49 pm » |
maybe i need the word "const" in front of all my int`s?
The first thing you should do is fix the complete lack of indenting. happy 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 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 Temp2 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: const int ElectretLED1 = A2; // led connected to analog pin 2 will light up when i talk const 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 = 1023; int threshold = 1200; //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(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 (Tank1 <= 17) { digitalWrite(RB2, HIGH); }//led alerts me when 20lb propane tank 1 is low if (Tank2 <= 17) { digitalWrite(RB3, HIGH); }//led alerts me when 20lb propane tank 2 is low if (Tank1 >= 18) { digitalWrite(RB2, LOW); }//led is off for propane tank 1 if (Tank2 >= 18) { digitalWrite(RB3, LOW); }//led is off for propane tank 2 //end load sensors
//start DS18B20 temperature sensor under camper. if (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 (Temp1 >= 1) { digitalWrite(Relay1, LOW); }//and then shuts it off if (Temp1 <= 0) { analogWrite(RB1, HIGH); }//turns on warning LED inside if (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 ((sensorReading >= threshold)) { Serial.println(sensorReading-threshold); //Will send only positive and absolute values of waveform }//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?
}
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6320
-
|
 |
« Reply #10 on: February 13, 2013, 12:35:55 pm » |
Tank1 is the pin number of the input. This code just compares the pin number against 17. Obviously that is pointless since the pin number does not change. If you want to read the state of the pin you need to use digitalRead() or analogRead() to get it. In this case you seem to be expecting an analog value so analogRead() is probably what you need here. It would loook like this: if (analogRead(Tank1) <= 17)
Similarly in all the other places where you have used the pin number directly, instead of the value read from that pin.
|
|
|
|
|
Logged
|
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #11 on: February 13, 2013, 12:49:49 pm » |
thanks a bundle dude! so i will just paste this to all the mistakes analogRead( stuff ) how about 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 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 Temp2 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: const int ElectretLED1 = A2; // led connected to analog pin 2 will light up when i talk const 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 = 1023; int threshold = 1200; //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(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 (analogRead(Tank1) <= 17) { digitalWrite(RB2, HIGH); }//led alerts me when 20lb propane tank 1 is low if (Tank2 <= 17) { digitalWrite(RB3, HIGH); }//led alerts me when 20lb propane tank 2 is low if (analogRead(Tank1) >= 18) { digitalWrite(RB2, LOW); }//led is off for propane tank 1 if (Tank2 >= 18) { digitalWrite(RB3, LOW); }//led is off for propane tank 2 //end load sensors
//start DS18B20 temperature sensor under camper. if (analogRead(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 (analogRead(Temp1) >= 1) { digitalWrite(Relay1, LOW); }//and then shuts it off if (Temp1 <= 0) { analogWrite(RB1, HIGH); }//turns on warning LED inside if (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 ((sensorReading >= threshold)) { Serial.println(sensorReading-threshold); //Will send only positive and absolute values of waveform }//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?
}
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
Earth
Offline
Full Member
Karma: 2
Posts: 103
Webmaster
|
 |
« Reply #12 on: February 13, 2013, 01:25:32 pm » |
i am gonna go get some snow and goto dollartree. //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: const int ElectretLED1 = A2; // led connected to analog pin 2 will light up when i talk const 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 (analogRead(Tank1) <= 17) { digitalWrite(RB2, HIGH); }//led alerts me when 20lb propane tank 1 is low if (Tank2 <= 17) { digitalWrite(RB3, HIGH); }//led alerts me when 20lb propane tank 2 is low if (analogRead(Tank1) >= 18) { digitalWrite(RB2, LOW); }//led is off for propane tank 1 if (Tank2 >= 18) { digitalWrite(RB3, LOW); }//led is off for propane tank 2 //end load sensors
//start DS18B20 temperature sensor under camper. if (analogRead(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 (analogRead(Temp1) >= 1) { digitalWrite(Relay1, LOW); }//and then shuts it off if (Temp1 <= 0) { analogWrite(RB1, HIGH); }//turns on warning LED inside if (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, LOW); } if (threshold<600) { (LED1, HIGH); } //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?
}
|
|
|
|
|
Logged
|
Webmaster living off grid in a camper with 300watts of solar panels charging 9 absorbed glass mat 12V batteries. i own about 40 dot coms. i can read, write and debug HTML, CSS, JSON and PHP. I can understand some javascript. A++ is new to me. i thought it was a dead language. lol! A rogue planet called Nibiru is close by and will cause disasters all over earth including fireballs, earthquakes, meteors and volcanic eruptions. But i will be ready with Project Camper
|
|
|
|
California
Online
Edison Member
Karma: 37
Posts: 1840
|
 |
« Reply #13 on: February 13, 2013, 02:35:24 pm » |
happy now?
I'm not unhappy.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #14 on: February 13, 2013, 04:27:34 pm » |
@TrailerTrash: Your signature is a bit much. It is distracting when trying to read your posts.
|
|
|
|
|
Logged
|
|
|
|
|
|