Show Posts
Pages: 1 2 3 [4] 5 6 ... 143
46  Using Arduino / Programming Questions / Re: Migrating from Arduino IDE -> Atmel Studio , "delay" hangs forever on: July 15, 2014, 12:25:03 am
Do you use int main()?

You will need to call init() or setup timer 0 yourself: http://arduino.land/FAQ/content/2/2/en/can-i-use-int-main-with-arduino.html
47  Using Arduino / Programming Questions / Re: limit on arays? on: July 14, 2014, 11:49:35 pm
yeah, RAM will be an issue long before the limits are reached.

However for a side reference, here is a link to info about the absolute maximums.
http://arduino.land/FAQ/content/6/7/en/what-is-the-maximum-number-of-elements-an-array-can-have.html
48  Using Arduino / Programming Questions / Re: convert string to int on: July 14, 2014, 09:36:32 am
so is there any way to do this?

You can access the internal string using the subscript operator, or the c_str method.

Code:
String s = "12345";

int num1 = atoi( &s[ 0 ] );

//Or

int num2 = atoi( s.c_str() );


The first method is useful if you need to start the conversion part way through the string ( or you could do c_str() + offset ).
49  Using Arduino / Programming Questions / Re: Fast DigitalWrite, made from Wire lib source on: July 14, 2014, 01:56:19 am
I use fat16libs code for many apps. http://forum.arduino.cc/index.php?topic=150325.0

It is around 25 times faster than digitalWrite.
50  Development / Other Software Development / Re: Upload contributions in the Arduino libraries on: July 14, 2014, 01:53:06 am
Log into github, go here: https://github.com/arduino/Arduino/tree/ide-1.5.x/libraries/Ethernet/src

Make your changes, then click save. Cos you do not have write permission github will automatically fork if needed, then put the commit in a new branch.

Then you can create a pull request.

When you work out the developers forum, a discussion there may support the pull request.
51  Using Arduino / Project Guidance / Re: Ethernet Webserver displaying images stores in byte arrays on: July 13, 2014, 08:40:28 pm
As Peter_n says, if you only have raw data, you can use HTML5

A combination of JavaScript to read the data, and a <canvas> element to draw into will do the trick.

Using JavaScript as a helper allows you to store the data in a hidden HTML element you send with the page, or it can even use an ajax request to get the data later.

There would almost certainly be a library here that will do what you want: http://www.cdnjs.com/ Very useful if the browser connecting to the Arduino can also access the internet.
52  Using Arduino / Programming Questions / Re: Where's the (hardware) "Serial" object instantiated in the Arduino ecosystem? on: July 13, 2014, 07:35:30 pm
I suppose it's academic at this point, but it's interesting that HardwareSerial.h doesn't 'include' any file that has the UBRRH/UBRR0H, so why wouldn't my local code see it?

The defines get included from an include in Arduino.h

The serial stuff is included after it. As includes are copy/paste jobs, Arduino.h becomes a long file with the UBRRH stuff first then the Serial, so its visible there.

For example, Func() will be defined as the include order allows SOME_DEFINE to be visible before its used ( if you include myheader.h ):

Code: (myfunc.h)
#ifdef SOME_DEFINE
  inline void Func(){ /*some action*/ };
#endif

Code: (myheader.h)
#define SOME_DEFINE
#include "myfunc.h"

53  Using Arduino / Programming Questions / Re: Where's the (hardware) "Serial" object instantiated in the Arduino ecosystem? on: July 13, 2014, 11:53:05 am
The Serial variables are declared extern in HardwareSerial.h as you say.

Before you include the header in your code, do you make the defines visible to HardwareSerial.h

Quote
#if defined(UBRRH) || defined(UBRR0H)
  extern HardwareSerial Serial;
  #define HAVE_HWSERIAL0
#endif

Maybe write some code using the defines in your local code, see if they are actually visible.
54  Using Arduino / Programming Questions / How can Serial.print() affect my sketch's logic? on: July 13, 2014, 11:06:10 am
Thanks for posting the sketch.

In your checkPass() function add to the top:
Code:
if( Locked ) return;

And in the checkCoin() function:
Code:
if( !Locked ) return;

Your buttons are either not de-bouncing as you wish, or they could be floating possibly due to a bad connection.

 This behavior is revealed using randoms instead of digital reads.
Code:
passPinState = random( 0,100 ) > 50 ? 1 : 0; //digitalRead(passPin);

This shows how your error of '11' is reached, even with "12345678901234"

55  Using Arduino / Programming Questions / Re: How can Serial.print() affect my sketch's logic? on: July 13, 2014, 08:23:47 am
Is  Serial.print( bool )  perhaps the culprit ?    It is a bit unusual to do that.

I've never had any probs with it.

@Jimbo,
Can you post the code you had when you removed the debounce stuff?
56  Using Arduino / Programming Questions / Re: Binary String to base ten int on: July 12, 2014, 08:41:48 pm
There are  strtoul and strtol

Code:
void setup() {

  String s = "11110000";
  
  int i = strtol( s.c_str(), NULL, 2 );
  
  Serial.begin( 9600 );
  Serial.print( i, DEC );
}

void loop() {}
57  Using Arduino / Programming Questions / Re: Time.h compiling error on: July 12, 2014, 08:03:13 pm
Quote
The bigger issue is that I just installed the windows 1.5.7 from the zip image
on XP and it has exactly the same issue with the Time library as it does on linux.

That is the one I have. Didn't bother with cygwin cos I already know its 4.8.1. C++11 features just cause errors in 1.5.6.
I have been avidly following the progress on github and google groups.

As I mentioned before, its the compiler requiring it, not a bug of the OS.
The decision was made to make flash elements constant. Which is what I recommended the OP change in code too.
58  Development / Other Software Development / Re: performance of map() function - an analysis on: July 12, 2014, 07:59:55 am
To celebrate the IDE upgrade to compiler version 4.8.1, I attempted my first C++11 style function.

This will do the maths using either signed long long, or unsigned long long

Code:
template < typename T, typename U > struct IsSameType{ enum { Value = false }; };
template < typename T > struct             IsSameType< T, T > { enum { Value = true }; };

template< typename T, typename U, typename V, typename X, typename Y >
  auto map( const T &x, U &&imin, V &&imax, X &&omin, Y &&omax ) -> T
    {
      typedef decltype( IsSameType< T, decltype( ( signed ) T() ) >::Value ? 1LL : 1ULL ) cll;
      return (cll)(x - imin) * (omax - omin) / (imax - imin) + omin;
    }

Here are the results with mine added onto the end.
Quote
Start
1   1000099   1000099   1000099   1000099
   60   4   4   4
10   1000990   1000990   1000990   1000990
   56   0   0   4
100   1001310   1001310   1009900   1009900
   52   4   4   4
1000   1000215   1000215   1099000   1099000
   52   4   4   4
10000   997863   997863   1990000   1990000
   64   4   4   4
100000   1000100   1000100   10900000   10900000
   64   4   0   0
1000000   1001003   1001003   100000000   100000000
   56   4   4   4

However once the functions are not allowed to inline themselves:
Quote
Start
1   1000099   1000099   1000099   1000099
   64   64   84   52
10   1000990   1000990   1000990   1000990
   52   56   80   68
100   1001310   1001310   1009900   1009900
   56   56   76   64
1000   1000215   1000215   1099000   1099000
   56   56   80   80
10000   997863   997863   1990000   1990000
   68   56   84   80
100000   1000100   1000100   10900000   10900000
   64   56   80   84
1000000   1001003   1001003   100000000   100000000
   64   52   80   96

Could probably squeeze more efficiency out of the template version by only using 'long long' when the inputs are 32 bits or more.

Also one important note, when using integer literals, you must put a suffix if the number is greater than 16bits, templates will treat them as an int and truncate the value.

59  Using Arduino / Programming Questions / Re: Bluetooth Communication on: July 12, 2014, 05:22:12 am
Not sure about the bluetooth, however, this if statement isn't used.

Code:
  if( Serial.available() )       // if data is available to read
  {
    ;
  }

Also in place of using numbers for ascii codes, you can just use a character constant ( single quotes ).

Code:
if( val == 'W' )               // if 'W' was received car moves forward
60  Using Arduino / Programming Questions / Re: Nested "if" with an "else" on the outer "if" on: July 12, 2014, 04:29:05 am
Like this:

Code:
if (outer test){

    if (inner test){
            //stuff
    }
}else{

}

You where missing the }{ on the else, without it the else becomes part of the inner test. I put the brackets on the same line as the code it refers to, it makes things far clearer.

You will need to repeat the inner test if needed in the else part. If its not needed and outer test is not used exclusively you can simply write:
Code:
if (outer test && inner test){
    //Stuff
}else{

}
Pages: 1 2 3 [4] 5 6 ... 143