Recent Posts

Pages: 1 ... 7 8 [9] 10
81
Hardware / Arduino e Ardupilot
Last post by LucaAlba98 - Today at 05:38 pm
Buonasera!
Volevo sottoporvi una domanda: è possibile far comunicare Arduino Uno R3 e un ArduPilot in modalità master- slave???
In pratica quando mi arriva un segnale su arduino (master), ardupilot (slave) mi fa volare un esacottero...
è possibile?
grazie :)  :)
82
Programming Questions / Re: return-statement with a va...
Last post by ilpg - Today at 05:38 pm
Hello!
sorry for the unformatted first post...first had to be pushed to read about how to post code...

i guess the error is in the function because in the error report lines there is written that there (i guess) a problem with the return value/format of my function.... i guess i have done something wrong with declaring the return value of the function...

i hope you get along with the code despite there is german mixed in  to comment the code...

thanks a lot!


Code: [Select]


//Rotary encoder

      #define ENC_A 14
      #define ENC_B 15
      #define ENC_PORT PINC
      float benzin; //this variable will be changed by encoder input
      float fuel= 0;
      float zaehler = 0;
      int set = 0; // soetwas nennt man auch "Merker"
      int read_encoder();
//flowmeter
      #include "LiquidCrystal.h"
      LiquidCrystal lcd(7, 8, 9, 12, 11, 10);
     
      // which pin to use for reading the sensor? can use any pin!
      #define FLOWSENSORPIN 2
     
      // count how many pulses!
      volatile uint16_t pulses = 0;
      // track the state of the pulse pin
      volatile uint8_t lastflowpinstate;
      // you can try to keep time of how long it is between pulses
      volatile uint32_t lastflowratetimer = 0;
      // and use that to calculate a flow rate
      volatile float flowrate;
      // Interrupt is called once a millisecond, looks for any pulses from the sensor!

//switch
      const int buttonPin = 4;     // the number of the pushbutton pin
      const int ledPin =  5;      // the number of the LED pin
     
      // variables will change:
      int buttonState = 0;         // variable for reading the pushbutton status

 
void setup()
{
// rotary encoder variables Setup encoder pins as inputs */
      pinMode(ENC_A, INPUT);
      digitalWrite(ENC_A, HIGH);
      pinMode(ENC_B, INPUT);
      digitalWrite(ENC_B, HIGH);
      Serial.begin (115200);
      Serial.println("Start");
      //float tmpdata;
      float benzin = 0;
      float fuel;
 
// flowsensor variables
      Serial.print("Flow sensor test!");
      lcd.begin(16, 2);
      pinMode(FLOWSENSORPIN, INPUT);
      digitalWrite(FLOWSENSORPIN, HIGH);
      lastflowpinstate = digitalRead(FLOWSENSORPIN);
      boolean useInterrupt(true);
   
// button variables
      // initialize the LED pin as an output:
      pinMode(ledPin, OUTPUT);
      // initialize the pushbutton pin as an input:
      pinMode(buttonPin, INPUT);   
}

void loop() 
{
  /////////////////status switch//////////////////////
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);// check if the pushbutton is pressed. if it is, the buttonState is HIGH:
  if (buttonState == HIGH)
  {
    digitalWrite(ledPin, HIGH);// turn LED on:
    // bei gedrücktem button anzeige mit rotary encoder erhöhen wenn rotary gedreht wird
  ///////rotary encoder///////////////////////////////////////////////////////
         //static uint8_t benzin = 0;      //this variable will be changed by encoder input
         float tmpdata;
         //float read_encoder();
         
          tmpdata = read_encoder();
          if( tmpdata )
            {
              Serial.print("Benzin: ");
              Serial.println(fuel);
              benzin += tmpdata;
              benzin = constrain(benzin,0,150);// 150 entspricht 15 litern tankinhalt
              fuel = benzin/10;
            }
         
          //function    returns change in encoder state (-1,0,1)
           int read_encoder();
          {
          static int8_t enc_states[] = {0,  -1,  1,0,  1,0,0,  -1,  -1,0,0,  1,0,  1,  -1,0};
          static uint8_t old_AB = 0;
          old_AB <<= 2;                   //remember previous state
          old_AB |= ( ENC_PORT & 0x03 );  //add current state
          return ( enc_states[( old_AB & 0x0f )]);
          }
       
  }
  else
  {
              // turn LED off:
              digitalWrite(ledPin, LOW);
             // wenn button losgelassen nehme fuel und substrahiere permanent den verbrauch
    ////////// flowmeter   /////////////////////////////////               
              lcd.setCursor(0, 0);
              lcd.print("Pu:"); lcd.print(pulses, DEC);
              lcd.print(" l/h:"); lcd.print(flowrate);
              Serial.print("Freq: "); Serial.println(flowrate);
              Serial.print("Pulses: "); Serial.println(pulses);
              float fuel = pulses;
              fuel /= 1920;
              //liters = 15-liters;
              flowrate = flowrate*0,5194;
              //liters /= 60.0;
              Serial.print(fuel); Serial.println("l Benzin");
              lcd.setCursor(0, 1);
              lcd.print(fuel); lcd.print(" l Benzin");
             
              delay(1000);
  }
}



these are the error lines

Code: [Select]

fuel_meter_v2.ino: In function 'void loop()':
fuel_meter_v2.ino:95:49: error: return-statement with a value, in function returning 'void' [-fpermissive]
return-statement with a value, in function returning 'void' [-fpermissive]


83
Yes you are correct, it is the number of bytes printed to serial monitor. My question is why? I dont have any direct instruction to that effect. I know it is a logical problem on my part, only that I cannot see it yet.
Maybe re-read reply #5?
84
Deutsch / Re: Gore-Tex Dichtungen
Last post by nix_mehr_frei - Today at 05:37 pm
Freut mich, auch wenn die "Sichtung" schon ca. 20 Jahre zurückliegt. Es sind ca. 5 centgroße Dichtungen, die einen selbstklebenden Rand haben.
Ich habe bereits bei TME und Digikey mal die Suchfunktion bemüht - Fehlanzeige  :smiley-sad-blue:
Wenn jemand dazu einen Distributor findet, der auch an privat verkauft, verlinkt das bitte mal. Ein paar Stück davon kann man immer im Schubfach haben  ;)
85
Hardware / Arduino rele e carichi indutti...
Last post by Ernesto079569 - Today at 05:37 pm
Ciao a tutti ho un arduino Uno e ho collegato una scheda rele alimentata esternamente. Ho collegato ad essa scheda una pompa a 230VAC (lo so in questo forum non si parla di tensioni alte infatti non ne parlerò) ho letto su internet che una pompa è un carico induttivo e che potrebbe creare disturbi ad arduino non so quali... Sapete dirmi che disturbi può creare e come è possibile eliminare tali disturbi???Grazie :)
86
hi,
I have get rid of this problem by using waitForKey() function. Thanks for the help.
87
I want to transfer encryption coding in Arduino into Eclipse at another PC/laptop.However,I want to transfer it without installing Arduino IDE or driver.Do you think it possible or not?? If possible how to do it.For your information, the other laptop is using windows 7.
88
I don't understand how you can program them without an FTDI.
89
Deutsch / Re: Arduino Sleep
Last post by michael_x - Today at 05:34 pm
Wieviel Strom braucht denn das Ethernet Modul? Macht es überhaupt Sinn, mit allem anderen Arduino-Overhead neben dem atmega328p, diesen überhaupt schlafen zu legen?

Ich dachte, sleep ist gut, um von 15mA auf 0.3mA zu kommen ;)
90
I searched the datasheet and the first Vih I found was probably the one for I2C. Did not look further which was a omission from my side.
Pages: 1 ... 7 8 [9] 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