Recent Posts

Pages: 1 ... 8 9 [10]
91
Bar Sport / Re: Achieve the simplest task ...
Last post by weedpharma - Today at 03:59 pm
They are right when they call C a write only language. It is impossible to read it unless it is fully commented!

Weedpharma
92
Okay i did the code :) But I didnt understand the simple State machine so i did something else that should logically work here it is
Code: [Select]

// PWM and Speed Control for Power Supply Project

#include <LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
int tempPin1 = A1;   // the output pin of LM35
int tempPin2 = A2;   // the output pin of LM35
int tempPin3 = A3;   // the output pin of LM35
int tempPin4 = A4;   // the output pin of LM35
int tempPin5 = A5;   // the output pin of LM35
int fan1 = 11;       // the pin where fan is
int fan2 = 12;       // the pin where fan is
int fan3 = 13;       // the pin where fan is
int relay1 =14;      // The pin where the relay is
int relay2 =15;      // The pin where the relay is
int relay3 =16;      // The pin where the relay is
int relay4 =9;       // The pin where the relay is
int led = 8;         // led pin
int temp1;
int temp2;
int temp3;
int temp4;
int temp5;
int tempMin = 30;   // the temperature to start the fan & First Relay stage
int tempMax = 70;   // the maximum temperature when fan is at 100
int temprelay = 50; // Tempture second relay stage starts.
int fanSpeed;
int fanLCD1;
int fanLCD2;
int fanLCD3;
int readTemp1() {  // get the temperature and convert it to celsius
  temp1 = analogRead(tempPin1);
  return temp1 * 0.48828125; }
int readTemp2() {  // get the temperature and convert it to celsius
  temp2 = analogRead(tempPin2);
  return temp2 * 0.48828125; }
int readTemp3() {  // get the temperature and convert it to celsius
  temp3 = analogRead(tempPin3);
  return temp3 * 0.48828125; }
int readTemp4() {  // get the temperature and convert it to celsius
  temp4 = analogRead(tempPin4);
  return temp4 * 0.48828125; }
int readTemp5() {  // get the temperature and convert it to celsius
  temp5 = analogRead(tempPin5);
  return temp5 * 0.48828125; }
  
void setup() {
  pinMode(fan1, OUTPUT);
  pinMode(fan2, OUTPUT);
  pinMode(fan3, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(tempPin1, INPUT);
  pinMode(tempPin2, INPUT);
  pinMode(tempPin3, INPUT);
  pinMode(tempPin4, INPUT);
  pinMode(tempPin5, INPUT);
  lcd.begin(16,2); 
}
 
void loop() {                // Fan 1-3 Temp sensor 3-5
   temp3 = readTemp3();     // get the temperature
   if(temp3 < tempMin) {   // if temp is lower than minimum temp
       fanSpeed = 0;      // fan is not spinning
       digitalWrite(fan1, LOW);       
   } 
   if((temp3 >= tempMin) && (temp3 <= tempMax)) {  // if temperature is higher than minimum temp
       fanSpeed = map(temp3, tempMin, tempMax, 32, 255); // the actual speed of fan
       fanLCD1 = map(temp3, tempMin, tempMax, 0, 100);  // speed of fan to display on LCD
       analogWrite(fan1, fanSpeed);  // spin the fan at the fanSpeed speed
   } 
   temp4 = readTemp4();     // get the temperature
   if(temp4 < tempMin) {   // if temp is lower than minimum temp
       fanSpeed = 0;      // fan is not spinning
       digitalWrite(fan2, LOW);       
   } 
   if((temp4 >= tempMin) && (temp4 <= tempMax)) {  // if temperature is higher than minimum temp
       fanSpeed = map(temp4, tempMin, tempMax, 32, 255); // the actual speed of fan
       fanLCD2 = map(temp4, tempMin, tempMax, 0, 100);  // speed of fan to display on LCD
       analogWrite(fan2, fanSpeed);  // spin the fan at the fanSpeed speed
   } 
   temp5 = readTemp5();     // get the temperature
   if(temp5 < tempMin) {   // if temp is lower than minimum temp
       fanSpeed = 0;      // fan is not spinning
       digitalWrite(fan3, LOW);       
   } 
   if((temp5 >= tempMin) && (temp5 <= tempMax)) {  // if temperature is higher than minimum temp
       fanSpeed = map(temp5, tempMin, tempMax, 32, 255); // the actual speed of fan
       fanLCD3 = map(temp5, tempMin, tempMax, 0, 100);  // speed of fan to display on LCD
       analogWrite(fan3, fanSpeed);  // spin the fan at the fanSpeed speed
   } 
   temp1 = readTemp1();     // get the temperature
   if(temp1 < tempMin) {   // if temp is lower than minimum temp
       digitalWrite(relay1, LOW);       
   } 
   if((temp1 >= tempMin) && (temp1 < temprelay)) {   // if temp is Greater than minimum temp but lower then relay temp
       digitalWrite(relay1, HIGH);  // Turn Realy One On     
   } 
   if(temp1 >= temprelay) {       // If Temp 1 Is equal or greater then Temp Realy
     digitalWrite(relay1, LOW);   // Turn Relay 1 Off
     delay (200);                 // Delay
     digitalWrite(relay2, HIGH);  // Turn Relay 2 on
   }
    temp2 = readTemp2();     // get the temperature
   if(temp2 < tempMin) {   // if temp is lower than minimum temp
       digitalWrite(relay3, LOW);       
   } 
   if((temp2 >= tempMin) && (temp2 < temprelay)) {   // if temp is Greater than minimum temp but lower then relay temp
       digitalWrite(relay3, HIGH);  // Turn Realy Three On     
   } 
   if(temp3 >= temprelay) {       // If Temp 3 Is equal or greater then Temp Realy
     digitalWrite(relay3, LOW);   // Turn Relay 3 Off
     delay (200);                 // Delay
     digitalWrite(relay4, HIGH);  // Turn Relay 4 on
   }
     
   
   if(temp1,temp2,temp3,temp4,temp5 > tempMax) {        // if temp is higher than tempMax
     digitalWrite(led, HIGH);  // turn on led
   } else {                    // else turn of led
     digitalWrite(led, LOW);
   }
   
   lcd.print("Temp1:");
   lcd.print(temp1);      // display the temperature
   lcd.print("C ");
   lcd.setCursor(9,0);     // Move the Cursor
   lcd.print("Temp2:");
   lcd.print(temp2);    // display the tempture
   lcd.print("C");
   lcd.setCursor(0,1);   // move cursor to next line
   lcd.print("Temp3:");
   lcd.print(temp3);    // display the tempture
   lcd.print("C");
   lcd.setCursor(9,1);     // Move the Cursor
   lcd.print("Temp4:");
   lcd.print(temp4);    // display the tempture
   lcd.print("C");
   delay(10000);
   lcd.clear();
   lcd.print("Temp5:");
   lcd.print(temp5);     //Display the Temp
   lcd.print("C");
   delay(5000);
   lcd.clear();
   if(relay1 == LOW, relay2 == LOW);{
     lcd.print("Fan Off"); }
   if(relay1 == HIGH, relay2 == LOW);{
     lcd.print("Fan Low"); }
   if(relay1 == LOW, relay2 == HIGH);{
     lcd.print("Fan High"); }
   lcd.setCursor(9,0);     // Move the Cursor
   if(relay3 == LOW, relay4 == LOW);{
     lcd.print("Fan Off"); }
   if(relay3 == HIGH, relay3 == LOW);{
     lcd.print("Fan Low"); }
   if(relay3 == LOW, relay4 == HIGH);{
     lcd.print("Fan High"); }
   lcd.setCursor(0,1);   // move cursor to next line
   lcd.print("Fan1:");
   lcd.print(fanLCD1);    // display the fan speed
   lcd.print("%");
   lcd.setCursor(1,9);   // move cursor to next line
   lcd.print("Fan2:");
   lcd.print(fanLCD2);    // display the fan speed
   lcd.print("%");
   delay(8000);
   lcd.clear();
   lcd.print("Fan3:");
   lcd.print(fanLCD3);    // display the fan speed
   lcd.print("%");
   delay(5000);
   lcd.clear();
}
 

[/b]
93
Software / Re: Memorizzare stringa su Ard...
Last post by nid69ita - Today at 03:58 pm
Cross posting vietato. Poi in sezione internazionale devi usare l'inglese:
http://forum.arduino.cc/index.php?topic=339668.msg2341719#msg2341719

Ti invitiamo a presentarti (dicci quali conoscenze hai di elettronica e di programmazione) qui: Presentazioni
e a leggere il regolamento se non lo hai giĆ  fatto: Regolamento
Qui una serie di link utili, non inerenti al tuo problema:
- qui una serie di schede by xxxPighi per i collegamenti elettronici vari: ABC - Arduino Basic Connections
- qui le pinout delle varie schede by xxxPighi: Pinout
- qui una serie di link generali utili: Link Utili
94
Sensors / Re: Analog input measures wron...
Last post by Espada - Today at 03:56 pm
Some more news. I made a different voltage divider. This time I used 988/7690 ohm. Although the measurments are not perfect, the measurements are way more stable and the value is very close to the real one. Around 0,4V difference up and around 0,1V lower difference. No cap here

If I put a 0,1uF the measurements are really stable with 0,1V defference up and down but not very often.

I assume you are reference to the "real ones" as testing with a voltmeter on the analog pin?

Before trying to use an offset, you should consider the map() function.
I also knew about this function but dont get how to use it properly here. Lets say I know when my arduino measures 16V, I know the real value is 17V. How do I remmap that? In the map function I change the upper and lower limit but I think in my case if better to add an ecuation like AX+B to fix the offset.
95
Hi,
Where did that sketch come from?
It is not from the links you posted.

We have wasted probably 30 posts with code that was not relevant, linked to code that you were not working with.

Where did the sketch come from?

Tom.... :)
96
anybody knows what i need on controlling rc car via bluetooth and arduino uno via mobile app with the use of cellphones tilt?
i need of course rc car, arduino, bluetooth shield , android phone, android app, and servo motor? am i right?

i need help how should i start it T.T
97
Software / Re: Aiuto libreria OneWire
Last post by gualandd - Today at 03:54 pm
Puoi gentilmente girarmi il link?
98


 ;)

Here is another example/tutorial that also explains how to change the baud rate on the GPS module
99
i need to create some kind of logic function and merge it into my code
sorry im still learning all this and i am trying to clean up my code and get it working for my UI

at the moment i have 2 images a red button and a green button

when the program starts all buttons are off (red)

once one is pressed it will turn green then run another function to activate an electronic device
but then i want to be able to turn it off as well and then turn red

how do i keep up with what state they are in and also keep up with the state once the screen has cleared and gone on to something else. while the system is active i want it to be able to remember the state of all buttons .. but one the system is reset all buttons will be set as off

here is my screen touch code it is  part of  switch case as there are 5 screens i need to keep track off
case 3 is screen 3

Code: [Select]

case 3: {  // Screen 3 Active

          if ((p.x > 130 && p.x < 204) && (p.y > 213 && p.y < 276))

            oneon();

          else if ((p.x > 144 && p.x < 163) && (p.y > 280 && p.y < 320))
           
            twoon();


keeping in mind this is a part of a switch case how do i keep track so

If button 1 is on it will run OneOff();
but on the same touch if it is off it would run OneOn();
the button one XY limits are
((p.x > 130 && p.x < 204) && (p.y > 213 && p.y < 276))


at the moment the on off functions are

Code: [Select]
void oneoff() {
  // Button 1 off
  switch_off(0);
  tft.setCursor(45, 2);
  tft.setTextColor(RED);  tft.setTextSize(2);
  tft.println("Socket 1");
  bmpDraw("off.bmp", 40, 22);
}

void oneon() {
  // Button 1 off
  switch_on(0);
  tft.setCursor(45, 2);
  tft.setTextColor(GREEN);  tft.setTextSize(2);
  tft.println("Socket 1");
  bmpDraw("on.bmp", 40, 22);
}
100
Not a mistake.
Default configuration is the two pads are connected by a trace. Cut the trace if you don't want autoreset to occur.
Pages: 1 ... 8 9 [10]