Recent Posts

Pages: 1 [2] 3 4 ... 10
11
My flex pads all come with double sided tape already fitted. Failing that, I would use any thin double sided tape, carpet tape would work.
12
Español / Re: Generador de frecuencia
Last post by Lucario448 - Today at 06:43 pm
¿Has probado con tone?
13
Arduino Yún / Re: My matricial keypad is han...
Last post by DarkSabre - Today at 06:43 pm
As ShapeShifter mentioned, Bridge uses pins 1 and 0 for communication with the sketch.
If the keypad is holding one of those lines low/high, then the bridge will almost certainly hang.

Probably unrelated, but my usual startup sequence is:
Code: [Select]
void setup()
{
  Serial.begin(9600);
  delay(5000);
  Bridge.begin();


Later on, you may find that this doesn't work
Code: [Select]
//Método para enviar Strings a la base de Datos (Send Strings to database method)
void enviarDatos()
{
   
    Process p;
    p.begin("/mnt/sda1/bascula.php");
    p.addParameter(String (peso1)); //Enviar Peso a Web
    p.addParameter(String (cargatotal)); //Peso de camión a Web
    p.run();
}


You may need to call your php interpreter using begin and then add the file as a parameter.
A typical php process looks like this for me:
Code: [Select]
Process query; //this sends information on stations 1 and 2 to the db
  query.begin("php-cli");
  query.addParameter("/mnt/sda1/db_cpunified.php");
  query.addParameter(String(timestamps[0]));  //insert timestamp for these readings
  query.addParameter(String(readings[0]));  //insert reading from station 1

(I push data into MySQL using php too. I have php-cli installed as my interpreter)


14
Then i tried to use your code to sort the data which ...
You seem to have things all mixed up.

The call to recvWithStartEndMarkers() should not be inside any IF clause. It should be called directly from loop() - like in my demo.

And, as I said earlier, I thought you wanted to use that function to get data from Serial1 - but you are using it to get data from Serial. Which serial port is your GSM device (or whatever it is?) connected to?

...R
15
how would i do that?
16
electric door lock* (problem of translation)

Code:

#include <SPI.h>

#include <Ethernet2.h>

byte mac[] = {0x90, 0xA2, 0xDA, 0x0F, 0xDF, 0xAB};


byte ip[] = {139, 165, 27, 64};

char DEVID1[] = "vEF115D082FD49CB";       

uint8_t pinDevid1 = 3;


int pinRelais = 7;

boolean etatRelais = 0; //etat du pin
boolean DEBUG = true;
char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;               
boolean lastConnected = false;                 


EthernetServer serveur(80);
EthernetClient client;

void setup() {

  pinMode(pinRelais, OUTPUT);
  pinMode(pinDevid1, INPUT);

  Serial.begin (9600);

  Ethernet.begin (mac, ip);

  Serial.print("*\n-> Le serveur est sur l'adresse : ");

  Serial.println(Ethernet.localIP());

  serveur.begin();

  if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
     // no point in carrying on, so do nothing forevermore:
     while(true);
    }
    else{
      Serial.println("Ethernet ready");
      // print the Ethernet board/shield's IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
  }
}


void loop() {

  gestionClient();

  if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
      {
        if(DEBUG){Serial.println("pinDevid1 is HIGH");}
        pinDevid1State = true;
        //Sending request to PushingBox when the pin is HIGH
        //sendToPushingBox(DEVID1);
      }

     
       if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
      {
        if(DEBUG){Serial.println("pinDevid1 is LOW");}
        pinDevid1State = false;
        //Sending request to PushingBox when the pin is LOW
        //sendToPushingBox(DEVID1);   
      }

  if (client.available()) {
        char c = client.read();
        if(DEBUG){Serial.print(c);}
      }
  if (!client.connected() && lastConnected) {
        if(DEBUG){Serial.println();}
        if(DEBUG){Serial.println("disconnecting.");}
        client.stop();
      }
      lastConnected = client.connected();
}

void sendToPushingBox(char devid[]){
  client.stop();
  if(DEBUG){Serial.println("connecting...");}

  if (client.connect(serverName, 80)) {
    if(DEBUG){Serial.println("connected");}

    if(DEBUG){Serial.println("sendind request");}
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Arduino");
    client.println();
  }
  else {
    if(DEBUG){Serial.println("connection failed");}
  }
}




void gestionClient() {

  EthernetClient client = serveur.available();

  if (client) {

    Serial.println("Client en ligne"); //on le dit...

    if (client.connected()) {

      GET(client); //appel de la fonction de décodage

     

      entete(client);

      corps(client);

      piedPage(client);

      Serial.println("Fin de communication avec le client\n");

      client.stop();

    }

  }

}


void entete(EthernetClient cl) {

 

  cl.println("HTTP/1.1 200 OK");

  cl.println("Content-Type: text/html; charset=ascii");

  cl.println("Connection: close"); 

  cl.println();

  //balises d'entête

  cl.println("<!DOCTYPE HTML>");

  cl.println("<html>");

  cl.println("<head><title>Relais</title></head>");

  cl.println("<body><h1>Relais P. DENEYE mars        2017</h1><hr><br>");

}

//fonction de fabrication du corps de page

void corps(EthernetClient cl) {

  cl.println("<br>");

  cl.print("<br>Relais ");

  if (etatRelais) {

    cl.print("ON ");

  }

  else {

    cl.print("OFF ");


  }

  cl.print(" <a href=?");

  cl.print('c');

  cl.println(" target=_self >Change</a><br>");

}


//fonction de fabrication du pied de page

void piedPage(EthernetClient cl) {

  //balises de pied de page

  cl.println("<br><hr>");

  cl.println("</body>");

  cl.println("</html>");

}

//fonction décodage GET

void GET(EthernetClient cl) {

  boolean lu = 0;

  while (cl.available()) {

    char c = cl.read();

    delay(1); //delai de lecture

    if (c == '?' && lu == 0) {

      c = cl.read();

      if (c == 'c') {

        etatRelais = !etatRelais;

        digitalWrite(pinRelais, etatRelais);
        Serial.println(etatRelais);

      }

      delay(10);

      lu = 1;

    }

  }

}




17
I think you should learn a little about the use of arrays for pins and pin states. And as said before, don't use things like digitalRead(0); if you ever want to change that, you might have a hard time finding every place that you have to change.

Code: [Select]
const int pinLed = LED_BUILTIN;
const int buttonPins[] =  {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
int buttonStates[sizeof(buttonPins) / sizeof(buttonPins[0])];

Now in setup(), you can loop through the button pins using e.g. a for-loop and set them to use INPUT_PULLUP.
Code: [Select]
void setup()
{

  for (int cnt = 0; cnt < sizeof(buttonPins) / sizeof(buttonPins[0]); cnt++)
  {
    pinMode(buttonPins[cnt], INPUT_PULLUP);
  }
}

And in loop() you can read them all in the same way.
Code: [Select]

  for (int cnt = 0; cnt < sizeof(buttonStates) / sizeof(buttonStates[0]); cnt++)
  {
    buttonStates[cnt] = digitalRead(buttonPins[cnt]);
  }


Now the only 'problem' left is accessing the array elements using sensible names; place the below near the top of your code
Code: [Select]
// sensible names for index into the arrays
#define BTN_UP 0
#define BTN_LEFT 1
#define BTN_DOWN 2
#define BTN_RIGHT 3
#define BTN_START 4
#define BTN_BACK 5
#define BTN_GEARUP 6
#define BTN_GEARDOWN 7
#define BTN_GEARLEFT 8
#define BTN_GEARRIGHT 9
#define BTN_GEARREVERSE 10

And in loop, you can access the pinStates like e.g.
Code: [Select]
  if (buttonStates[BTN_UP] == LOW)
  {
    if (buttonStates[BTN_GEARLEFT] == LOW)
    {

    }
    else if ( ... )
    {

      ...
      ...
      ...

  }


If you now ever have to change move a button to another pin, you just change the pin number in the array.

In the last step, you can combine the buttonPins and buttonStates in a struct. But that's another chapter ;)
18
Project Guidance / Re: Mounting 3X4 key pad on pa...
Last post by LarryD - Today at 06:40 pm
Double sided tape on the back of the keypad to a none flex surface.


.
19
Deutsch / Re: Arduino ELEGOO Mega2560 Au...
Last post by Fastgate - Today at 06:40 pm
Sorry ich hab wirklich wirklich kein plan wie ich weiter vorgehen soll...

20
Deutsch / Re: problem Arduino Uno Rev.3 ...
Last post by apeandrefan - Today at 06:39 pm
ich habe neopixel installiert

also ardubu ich finde keine voreinstellungen, ausführliche ausgabe während kompilierung aus ich habe einen mac compi.
Pages: 1 [2] 3 4 ... 10

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy