Pages: [1]   Go Down
Author Topic: HELP PLEASE!!!!  (Read 390 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, Well i am from chile and i have a question

This is my code

Code:
/*
 ---------------------------------------------
  Contador de pulsos
 ---------------------------------------------
 
  Programa que muestra por pantalla (consola serial) el número
   de veces que el pulsador ha sido presionado, se realiza un
   proceso que de acuerdo al número de pulsaciones se enciende
   un LED,
 
 Cosas de Mecatrónica y Tienda de Robótica
 
*/
 
//--------------------------------------------------
//Declara puertos de entradas y salidas y variables
//--------------------------------------------------
int conta = 0;  //Variable para guardar el conteo de los pulsos
int num = 3;
 
//------------------------------------
//Funcion principal
//------------------------------------
void setup() // Se ejecuta cada vez que el Arduino se inicia
{
  Serial.begin(9600);   //Inicia comunicación serial
  pinMode(2,INPUT);     //Configura el pin 2 como una entrada, pulsador
  pinMode(13,OUTPUT);   //Configura el pin 13 como una salida, LED
pinMode(3,INPUT);
}
 
//------------------------------------
//Funcion ciclicla
//------------------------------------
void loop() // Esta funcion se mantiene ejecutando
{           //  cuando este energizado el Arduino

if (digitalRead(3) == LOW)
  {
    digitalWrite(13,HIGH);  //Enciende el LED Verde
    digitalWrite(14,LOW); //Rojo Apagado
   
    num = 0;
  }
 
  // Si el valor del contador es 8
  if (digitalRead(3) == HIGH)
  {
    digitalWrite(13,LOW);  // Apaga el LED Verde
    digitalWrite(14,HIGH);// Enciende led rojo
    num = 1;
  }
 
  // Si el pulsador esta oprimido
  if ( digitalRead(2) == HIGH )
  {
      // Si el pulsador no esta oprimido, flanco de bajada
      if ( digitalRead(2) == LOW )
      {
       
  if(num == 1)
      {
        Serial.println("Posible Fuga");
       
      }
      else
      {
         conta++;               //Incrementa el contador
         Serial.println(conta); //Imprime el valor por consola
         delay (100);
         // Retardo
      }
      }
     
     
  }
 
  // Si el valor del contador es 5
 
 
}
 
//Fin programa

I want send the variable "conta" to a php code or a data base (mysql)

plese help
Logged

Victoria, BC, Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 222
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You will need to write a program on your PC side to do something with this value - put it in a database, or send it to PHP, etc.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25860
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I want send the variable "conta"
I don't speak very much Spanish, but this
Code:
Serial.println(conta); //Imprime el valor por consola
seems to be doing what you want.

Receiving it is another matter.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

but how i can send the "conta" to a mysql data base?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25860
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino is sending "conta" (or at least, as I read it it is).
What is on the other end of the serial line?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: