| Arduino Forum ::  Members :: ichris93
 Show Posts Pages: 1 2 3 [4]
 46 Using Arduino / Programming Questions / Re: help writing library on: December 21, 2012, 11:53:06 am Quote from: johnwasser on December 18, 2012, 04:45:07 pmYou aren't using the private member variables  _Voltage or _pressure so there is not real need to have an object:Code:#ifndef CONVECTRON_h#define CONVECTRON_h//#include "WProgram.h"#if defined(ARDUINO) && ARDUINO >= 100#include "Arduino.h"#else#include "WProgram.h"#endiffloat CONVECTRONReadPressure(const int pin);#endifWouldn't it still be necessary to define public and private variables?
 47 Using Arduino / Programming Questions / Re: help writing library on: December 18, 2012, 10:29:21 pm Quote from: guix on December 18, 2012, 06:15:38 pmLike this:Code:if (voltage<=2.842) //0.375-2.842V{    pressure=(-0.02585+(0.03767*voltage)+(0.04563*voltage*voltage)+(0.1151*pow(voltage, 3))-(0.04158*pow(voltage, 4))+(0.008737*pow(voltage, 5)));}else if (voltage<=4.945) //2.842-4.945V{    pressure=((0.1031-(0.02322*voltage)+(0.07229*voltage*voltage))/(1-(0.3986*voltage)+(0.07438*voltage*voltage)-(0.006866*pow(voltage, 3))));}else if (voltage<=5.659) //4.945-5.659V{    pressure=((100.624-(20.5623*voltage))/(1-(0.37679*voltage)+(0.0348656*voltage*voltage)));}Thank you.  Now I am getting expected unqualified-id error.
 48 Using Arduino / Programming Questions / Re: help writing library on: December 18, 2012, 04:48:35 pm Quote from: johnwasser on December 18, 2012, 04:45:07 pmYour code looks a little wonky.  You have conditional statements all by themselves like  "voltage<=5.659;".  That won't do anything except calculate a true/false value and then throw it away.  You probably intended to use else and if statements.Also note that the highest voltage you can measure is 4.995V  (5V minus one LSB or 1/1024th).  You are comparing the voltage to 5.695 and it will always be less than that.  if you need to measure higher voltages you need a voltage divider to bring the desired range down to fit within the hardware limits.How would I change to else and if statements? I realize that the Arduino can only read to 5V.  I was just going to write the library with the equations given and then change it when I knew what resistors I would be using in my voltage divider.  Thanks
 49 Using Arduino / Project Guidance / Re: Writing a library on: December 18, 2012, 04:24:49 pm Quote from: robtillaart on December 14, 2012, 02:10:57 pmif possible you should try to write the library in such a way that you have a constructor or a begin() method that defines the pins used.Also check if you can make the lib work for other 7 seg displays. with one, 2 or 4 or more segments.What I also would like is the ability to concat 2 or 3 of themmax69.begin(int digits, int pins[]);  // number of digitsmax69.print(int number); // see liudr's postmax69.on();max69.off();  // switch offand of course ...x = max69.read();  // to read the current number displayedmax69.shiftright("1234567890");  // and of course the left variation tomax69.flip();  // rotates the number 180 degrees on the 7 segment display, never seen but can be done.max69.write(int number, HEX);just thinking out loud ...Why would I need to define the pins used?
 50 Using Arduino / Programming Questions / help writing library on: December 18, 2012, 04:18:35 pm Hi,I am working on my first libraries.  Essentially I would like to read an analog pin and get a pressure reading back via some functions.  Here is what I have for the header file Code:#ifndef CONVECTRON_h#define CONVECTRON_h//#include "WProgram.h"#if defined(ARDUINO) && ARDUINO >= 100#include "Arduino.h"#else#include "WProgram.h"#endifclass CONVECTRON{    public:        CONVECTRON_ReadPressure(pressure);    private:        int _Voltage;        float _pressure;};#endifand the .cpp file Code://#include   #if defined(ARDUINO) && ARDUINO >= 100  #include "Arduino.h"  #else  #include "WProgram.h"  #endif#include "CONVECTRON.h"CONVECTRON::CONVECTRON_ReadPressure();{    int senorValue = analogRead(A0);    float voltage = sensorValue * (5.0 / 1023.0);                if (voltage<=2.842) //0.375-2.842V            pressure=(-0.02585+(0.03767*voltage)+(0.04563*voltage*voltage)+(0.1151*pow(voltage, 3))-(0.04158*pow(voltage, 4))+(0.008737*pow(voltage, 5)));{            {voltage<=4.945; //2.842-4.945V                pressure=((0.1031-(0.02322*voltage)+(0.07229*voltage*voltage))/(1-(0.3986*voltage)+(0.07438*voltage*voltage)-(0.006866*pow(voltage, 3))));}            {voltage<=5.659;   //4.945-5.659V                pressure=((100.624-(20.5623*voltage))/(1-(0.37679*voltage)+(0.0348656*voltage*voltage)));}}    return pressure;}Is this correct?  Would just like some help with this.  Thanks!
 51 Using Arduino / Project Guidance / Writing a library on: December 13, 2012, 04:58:16 pm Hello,I am working on a project that will use a MAX6959 to print onto 2 2-digit 7 segment displays.  I am in the process of writing a library for it, but I don't exactly know what I am doing.  Lets say I want the display to be able to print from 0-9999.  How do I put that in the library?  Do I have to code each number and each digit individually? Thanks for the help!
 Pages: 1 2 3 [4]