Show Posts
Pages: [1] 2 3 ... 9
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Help Loop exit on: September 11, 2009, 03:33:41 pm
Please, do not sorry, you are helping me!!

Thank you very much zed0,

Now my program is working, I changed the checkCommand by the Serial.available(), I have no problem sending again the 7 and restarted the fade function.

Thank you very much again.
2  Forum 2005-2010 (read only) / Troubleshooting / Re: Help Loop exit on: September 09, 2009, 02:33:47 pm
Thank you Zed0,

It is "almost working" ( much better that my, of course)

Now I can exit the loop, but to exit the loop I need to send two commands (even if I wait for 10 seconds to send the first command)

Do you know what could be the problem?



Code:
2                             <<I sent 2 and it goes to red
rgb value: 2
7                            <<I sent 7 and it goes to fade
rgb value: 7
2                            <<I sent 2 and nothing change
rgb value: 2      
2                              <<I sent 2 again and it goes to red
rgb value: 2
7
rgb value: 7           <<and the something here again
2
rgb value: 2
2
rgb value: 2
3  Forum 2005-2010 (read only) / Troubleshooting / Re: Help Loop exit on: September 08, 2009, 07:19:01 pm
Thank you AWOL, and excuse me about not using the # button when posting the code, that was my first time posting a code here.

As you can see, the checkCommand is used to see if I sent a serial command to change the color of my rgb led or I fade the rgb led.

Is there any way to solve the problem?  How can I exit the loop as soon as I send the serial command?

4  Forum 2005-2010 (read only) / Troubleshooting / Help Loop exit on: September 08, 2009, 02:26:45 pm
Hello all,

I´m doing a very simple program to control a RGB  with serial.read.

For now when I send 1 I turn on RGB >Red, sending 2 RGB >green, sendind 3 RGB >blue and finally sending 7 the RGB start a loop to mix all colors. (and the mix works fine)

My problem starts when I try to exit the loop, for example, to turn on again the red RGB.  I cannot exit the loop, the program remains in the fade routine.  What I´m doing wrong?

Please, I need help to know how to exit the loop.

Thank you,


// programa para piscina

int redPin = 11;
int greenPin = 10;
int bluePin = 9;

//variaveis
int red = 0;
int green = 0;
int blue = 0;
int wait = 3000;
int WAIT = 100;
int rgb = 0;

//setup inicial

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);  
  pinMode(bluePin, OUTPUT);
  
  Serial.begin(9600);

  //led inicial  
  analogWrite(redPin,   16);
  analogWrite(greenPin, 16);
  analogWrite(bluePin,  16);  
}

    void loop(){
      checkCommand();                    // verifica se chegou algo
  }




    void checkCommand () {   // programa para gerar as cores conforme data recebido
    
    if (Serial.available()) {
     rgb = Serial.read() - 48;
      Serial.println(rgb);
      
      
        Serial.print("rgb value: ");  //for debug
      Serial.println(rgb);
      
       if (rgb == 1) {
       r();
      
      } else if (rgb == 2) {
        g();
      } else if (rgb == 3) {
        b();
      }else if (rgb == 7) {
        fade();
      }
      
      
    }
}  
    // rotinas
    void r(){  //cor vermelha solida
    color(255,0,0) ;
    }
    
    void g(){   //cor verde solida
     color(0,255,0) ;
    }
    
    void b(){   //cor azul solida
    color(0,0,255) ;
    }
    
    void fade() {       //<<<<<< here start my problem to exit  this loop
      
      while (rgb == 7){
        
           checkCommand();      //I can see that the rgb value changes ( when I send 3, for example, it goes to 3) but has no effect in the while loop
      
      for (float f = 0; f < 1; f += 0.0005) {

        
        hsv(f, 1, 1);
    delay(WAIT);
            
      }
     }
    }
    //}
    void hsv(float H, float S, float V) {

  int var_i;
  float R, G, B, var_1, var_2, var_3, var_h;

  if (S == 0) {
    R = V;
    G = V;
    B = V;
  }
  else {
    var_h = H * 6;
    if (var_h == 6) var_h = 0;  
    var_i = int(var_h) ;          
    var_1 = V * (1 - S );
    var_2 = V * (1 - S * (var_h - var_i));
    var_3 = V * (1 - S * (1 - (var_h - var_i)));

    if (var_i == 0) {
      R = V;
      G = var_3;
      B = var_1;
    }
    else if (var_i == 1) {
      R = var_2;
      G = V;
      B = var_1;
    }
    else if (var_i == 2) {
      R = var_1;
      G = V;
      B = var_3;
    }
    else if (var_i == 3) {
      R = var_1;
      G = var_2;
      B = V;
    }
    else if (var_i == 4) {
      R = var_3;
      G = var_1;
      B = V;
    }
    else {
      R = V;
      G = var_1;
      B = var_2;
    }
    
     color(255 * R, 255 * G, 255 * B);  
  
 
  }
}
    
    
    void color(int red,int green, int blue) {

    analogWrite(redPin, red); // Escreve o valor do PWM do led vermelho
    analogWrite(greenPin, green); // Escreve o valor do PWM do led verde
    analogWrite(bluePin, blue); // Escreve o valor do PWM do led azul

}
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Exponent of E on: February 24, 2010, 02:41:38 pm
Hi Fletcher,

Take a look here to give an idea how is the curve and the values:
(My curve is not so linear, but my curve is similar to that)

http://www.lakeshore.com/temp/sen/sd400_ts.html#curve10

In my case I have almost 70 datapoints, that I received for the guy that I´m trying to make a display, instead using a voltmeter to view the temp.

He has a machine that uses nitrogen to cold some wires, (I do not know exactly what the machine does) he uses something called coldhead to maintain the nitrogen temperature, and I know the preassure inside the (Closed) tank is about 10 PSI

Jose
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Exponent of E on: February 20, 2010, 12:43:29 pm
Hi Fletcher,

I´m measuring the temperature (nitrogen K degrees) with a diode, and I needed to divide the curve in two parts in order to work, one 3´th order the other 5´th order.

You´re right, I tried 7´th, 8 ´th and 9th orders and the best fit was the 6´th below 6 is not so good.

I also tried to fit the curve with excel but Origin did a best work.

Cristal
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Exponent of E on: February 19, 2010, 12:43:45 pm
Thank you guys for the answers, but my doubt was exactly that, if the value of E = 2,71828183 or if the value is -0.00002.

I'm using a program called Origin to find the equation of a curve and the result came as y = -2E-05*x6 + 0.001*x5 - 0.036*x4 + 0.410*x3 - 2.215*x2 + 3.715*x + 20.01

Now I know that the value is really -0.00002.

Thank you again.
8  Forum 2005-2010 (read only) / Syntax & Programs / Exponent of E on: February 15, 2010, 01:52:21 pm
Hello all,

How can I write the following formula: y = -2E-05*x6 + 0.001*x5 - 0.036*x4 + 0.410*x3 - 2.215*x2 + 3.715*x + 20.01
The problem is the exponent of E
9  Forum 2005-2010 (read only) / Interfacing / Re: What do I need to control Arduino's board from on: August 31, 2008, 08:23:33 am
Hi everyone,

Here I have my solution.  thank you John.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1220119733/0
10  Forum 2005-2010 (read only) / Interfacing / What do I need to control Arduino's board from web on: August 30, 2008, 01:23:05 pm
Hi everyone,

I´m completely new with Arduino´s board, and I would like to control the board, that it is connected in a PC in my house, from a lanhouse.
I can not use FTP or Telnet from the lanhouse, I only can access web pages.

What do I need to build that project

Thank you for your time and help.
11  Forum 2005-2010 (read only) / Italiano / Re: da RS232 di arduino a RS485 on: December 04, 2010, 02:44:04 pm
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1245694725

Ciao
12  Forum 2005-2010 (read only) / Français / Re: activé une pin avec signal RTS on: July 04, 2010, 08:18:58 am
Bonjour, regardez ici, ce projet est très bon et facile à réaliser

http://real2electronics.blogspot.com/2009/09/arduino-and-rs485-english-version.html
13  Forum 2005-2010 (read only) / Español / Re: Dónde comprar chips ATMEGA168/328 on: January 23, 2011, 07:16:16 am
eBay
http://cgi.ebay.com/ATmega328-ATmega328P-PU-w-Bootloader-Installed-NEW-/170594055342?pt=LH_DefaultDomain_0&hash=item27b832b4ae
14  Forum 2005-2010 (read only) / Español / Re: Pinguino on: May 31, 2010, 08:25:43 am
Hola,

Las resistencias de 470 son conectadas a los pines de entrada/salida

http://www.hackinglab.org/
15  Forum 2005-2010 (read only) / Español / Re: RS485 on: September 11, 2009, 02:11:45 pm
Excelente iniciativa Igor,

saludos
Pages: [1] 2 3 ... 9