Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Are there any macro directives to detect board types? on: May 05, 2014, 12:48:29 am
I have got a tricky way to achieve my requirement as below:

Code:
#if defined (__AVR__) || (__avr__)
//for Arduino UNO/Mega based on AVR IC
dtostrf (value, 8, precision, str); 
#else
//for Arduino DUE based on ARM IC
snprintf(str,len,"%g",value);
#endif

Thanks go to all of you!
2  Using Arduino / Programming Questions / Re: could not be compiled in 1.0.2, but could, in 1.5.6 on: May 04, 2014, 10:58:27 pm
Thank you, the problem is just you pointed out. smiley

I am not sure at the moment whether this line is a must, it is included in the response headers returned from the server, however.
3  Using Arduino / Programming Questions / Re: Are there any macro directives to detect board types? on: May 04, 2014, 09:27:14 pm
The names are not going to be that obvious, but they are listed in the avr/io.h file.

Since there are only one board based on ARM, then how can I find the directive for ARM? Names in avr/io.h are all AVR IC.
4  Using Arduino / Programming Questions / Re: Are there any macro directives to detect board types? on: May 04, 2014, 08:18:53 pm
But it said dtostrf was not declared in this scope on DUE
5  Using Arduino / Programming Questions / could not be compiled in 1.0.2, but could, in 1.5.6 on: May 04, 2014, 08:02:54 pm
Hi, guru,

My Arduino IDE 1.0.2 met a strange problem last night, it compiled the following codes very awfully slowly and in the end it threw out 'Missing the */ from the end of a /* statement*/', but these codes could be compiled under 1.5.6 without any problem, and moreover, the IDE 1.0.2 could compile the built-in webclient sample, however.

Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
char server[] = "www.lewei50.com";    // name address for Google (using DNS)
IPAddress ip(192,168,16,177);

EthernetClient client;

void setup() {
  Serial.begin(9600);

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
  }
  delay(1000);
  Serial.println("connecting www.lewei50.com ...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /http://www.lewei50.com/api/v1/sensor/gethistorydata/2558?Order=1&Limit=1&userkey=029b3884b91e4d00b514158b******");
    client.println("Host: www.lewei50.com");
    client.println("Accept: */*");
    client.println("Accept-Encoding: gzip, deflate, compress");
    client.println("User-Agent: runscope/0.1");
    client.println("Connection: close");
    client.println();
  }
  else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    while(true);
  }
}


I have restarted my IDE and even PC already but do not work.

BR,

Ardypro
6  Using Arduino / Programming Questions / Re: Are there any macro directives to detect board types? on: May 04, 2014, 12:51:21 pm
I'm looking for a macro directive to detect which board is using, so the following code could be compiled whatever board it is:

#if defined DUE_BOARD
   snprintf(); // convert float to string for DUE
#else
  dtostrf(); //convert float to string for UNO or MEGA
#endif
7  Using Arduino / Programming Questions / Are there any macro directives to detect board types? on: May 04, 2014, 03:39:34 am
Dear gurus,

As far as I know, Arduino UNO and Mega doest not support snprintf() to convert float to string, while DUE does. So I need some directives to detect which board is using when compiling the sketch.

BR,

Ardypro
8  Using Arduino / Sensors / Re: MLX90615 in PWM mode interfaced with Arduino UNO on: April 21, 2014, 12:31:33 am
I was running into this problem with MLX90615, either.  The libraries I used were found on github, and the i2c address was changed from 0x5A to 0x00. The sensor seemed working since it gave out ambient temperature and object temperature values, but the two values did not vary at all, even though my hand was  1-2cm close to it or was left.

Ambient = 49.43*C   Object = 49.43*C
Ambient = 120.97*F   Object = 120.97*F
Ambient = 49.43*C   Object = 49.43*C
Ambient = 120.97*F   Object = 120.97*F
...
9  Development / Other Software Development / Re: CodeBlocks Arduino IDE - real C++ IDE for Arduino development (rev.20130827) on: December 10, 2013, 09:18:13 pm
It is out of work accidentally, it could compile the project and have problems in generating HEX file
10  Using Arduino / Installation & Troubleshooting / Re: Is it a flaw of Leonardo's Serial? on: November 25, 2013, 09:03:32 am
The Leonardo was reset while the host application kept the Serial opening,  if I tried to close and reopen the serial port in host application, it would throw out the following exception under Win7, even though the serial port was detected by the Windows already and the serial port number was just same as the previous one before resetting.

Quote
   System.IO.IOException: The specified port does not exist.
   at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
   at System.IO.Ports.InternalResources.WinIOError()
   at System.IO.Ports.SerialStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.IO.Ports.SerialPort.Dispose(Boolean disposing)
   at System.IO.Ports.SerialPort.Close()
   at leo.MainForm.BtnCloseClick(Object sender, EventArgs e) in c:\Users\ardypro\Documents\SharpDevelop Projects\leo\leo\MainForm.cs:line 52
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at leo.Program.Main(String[] args) in c:\Users\ardypro\Documents\SharpDevelop Projects\leo\leo\Program.cs:line 27

11  Using Arduino / Installation & Troubleshooting / Is it a flaw of Leonardo's Serial? on: November 21, 2013, 10:57:18 am
Hi, all,

After uploading sketch into the Leonardo, it would not be restarted as it did with UNO or Mega when the Serial Monitor was opened, because sometimes I need monitor the debugging message by serial port from the very beginning, so I pushed the reset button to force the board to restart, unfortunately the port disappeared and the host application went into idle.  It made no difference if trying to close and reopen the serial port in the host application.  The workaround might be closing the host application and then restarting it again.

If the Leonardo was used in production situation, the host application communicated to the board through com port. The Leonardo was reset by accident, even if the host application detected it, it could not reconnect to the board's serial port by itself, except somebody found this failure and restarted the application manually.

So, is this a flaw of Leonardo or should I use the board in a proper way?

BR,
12  Using Arduino / Programming Questions / Why EthernetClient does not name a type? on: November 03, 2013, 08:42:54 pm
Hi, all,

I am using the Ethernet library to connect the board to the web server, but when I try to compile the following code, it throws out " 'EthernetClient' does not name a type":

foo.h
Code:
#include <SPI.h>
#include <Ethernet.h>

class foo
{
public:
  EthernetClient cli;
};

project file
Code:
#include "foo.h"
//#include <SPI.h>
//#include <Ethernet.h>

foo f;
void setup()

}

void loop()
{
}

It seems both the Ethernet.h and SPI.h files should be re-imported in the project file to get it work. Both of them were imported in foo.h and the project file has included the foo.h already, why does the compiler throw out the exception, even though there were no instances of EthernetClient declared at all ?

BR,

Ardypro
13  Development / Other Software Development / Failed in importing Ethernet lib with Jantje's plugin for eclipse on: December 05, 2012, 04:06:23 am
Hi, there,

I am trying to import the 'built-in' library Ethernet into my project under Eclipse, but it said the w5100.h was not found, after deleting it from the list in project's Includes tree node in Eclipse, it would throw out an error saying 'fatal error: pins_arduino.h:could not find the file' or, sometimes, 'fatal error: arduino.h could not find the file".  It seemed it could not find the w5100.h located under the subfolder Utility.

Any suggestions would be appreciated!

Ardypro
14  Development / Other Software Development / Re: How to open the project made with Jantje's plugin under eclipse on: October 21, 2012, 09:42:44 am
thank you, Jantje, for your kind reponse and your useful plugin.
15  Development / Other Software Development / Re: How to open the project made with Jantje's plugin under eclipse on: October 21, 2012, 01:03:07 am
For example, if a project was created with CodeBlocks, the ext name for the project file would be cbp, double clicked it would fire CB to open it. I did not find a project file in the files created with Eclipse, however.
Pages: [1] 2 3