Show Posts
Pages: 1 [2] 3 4 ... 10
16  Using Arduino / Programming Questions / How to format data for I2C on: July 02, 2014, 02:33:26 pm

I have about 10 values to transfer via I2C. What is the best way to format and transfer it?
4 of these values are Temperatures ( for example 120.3, float). Since the I2C library is just transfering bytes, how do I "convert" them? multiplicating with 10 doesnt work..

3 of the values are values like 1 and 0, no problem.. (uint8_t)

3 others are values from 0 to 6000 ( uint16_t)

The uint16_t and float values are requested in an intervall of 5-7hz, the uint8_t values ~20hz...

So I will do something like this since the "onRequest" funktion doesnt allow to choose what to request
#include <Wire.h>

uint8_t values[5] = {12, 45, 87, 34, 98};

void setup()
void loop() {}

void requestEvent() {
  Wire.write("hello ");

void receiveEvent(int howMany) {
  uint8_t c;
  c =;

void datarequested(uint8_t whichbyte) {

But how to transfer values like 123.4 or 6000 ?
17  Using Arduino / Programming Questions / Re: Keeping all libraries in the Arduino sketch directory on: July 02, 2014, 10:23:39 am
Thanks, what about the folder for the library?

for example
#include ".../myFolder/myLibrary.h"

18  Using Arduino / Programming Questions / Keeping all libraries in the Arduino sketch directory on: July 01, 2014, 03:09:45 pm

I know that you are supposed to place any external libraries under the "libraries" folder of the arduino install directory, but I have a project that uses several libraries that I have created for the project and mainly to keep all that code self contained and out of the main pde file. However, I have tried to place the libraries in the same directory as the main PDE file so that I can more easily keep everything synced up in subversion (I work on this on multiple computers) and I don't want to have to keep going back and syncing up the libraries separately. Also, just for the sake of being able to easily zip of the sketch folder and know that it contains everything it needs.

So, is this possible anyhow?
19  Using Arduino / General Electronics / Re: BLE shield Arduino on: June 17, 2014, 05:36:39 pm
20  Using Arduino / Displays / Re: Looking for a bright 2.2" display on: June 16, 2014, 05:14:40 pm
An the last two sheets

21  Using Arduino / Displays / Re: Looking for a bright 2.2" display on: June 16, 2014, 05:13:38 pm
Yes, thats what I thought :-/.

I just found an 2.4" OLED color display with 320x240

The good thing is that Im already using 320x240, so I don't need to rescale my GUI smiley-grin.

Does anyone know if there is a sketch/driver for that?

22  Using Arduino / Displays / Looking for a bright 2.2" display on: June 15, 2014, 05:09:21 am

Im looking for a bright 2.2" color graphics Display. I was using the Adafruit 2.2" which is good but not readable in direct sunlight.

I was already looking for an OLED but it looks like they're not available in 2.2", at least not in this particular rectangle shape.

It would be a dream if it would have a resolution of 240x320...
Are there any available?
23  International / Deutsch / Re: Array einer funktion zurückgeben on: June 11, 2014, 06:50:10 am
Danke Ralf und jurs, so werde ich es wohl machen.

Habe gerade anscheinend noch Probleme mit meiner Syntax, könnte das eventuell jemand korrigieren?

int *getTime() {
 uint8_t myDate[6] = {0, 0, 0, 0, 0, 0}; //seconds,minutes,hours,date,month,year (last 2 digits)

  // send request to receive data starting at register 0
  Wire.beginTransmission(0x68); // 0x68 is DS3231 device address
  Wire.write(0);                // start at register 0
  Wire.requestFrom(0x68, 7);    // request 7 bytes (seconds, minutes, hours, day, date, month, year)
  while (Wire.available())
    for (int i = 0; i <= 6; i++) {
      if (i == 3) {
        int throwAway = bcdToDec(; //we dont care about the dayOfWeek
      else {
       myDate[i] = (bcdToDec(;
  return (myDate[]);

Ich bekomme noch folgenden Fehler
MUO_2_2inch.ino: In function 'int* getTime()':
MUO_2_2inch:254: error: expected primary-expression before ']' token

24  International / Deutsch / Re: Array einer funktion zurückgeben on: June 11, 2014, 03:03:09 am
Aber die funktion DateGenerator() generiert mir ja das Array das es vorher nicht gibt. Zwar kann ich es im loop definieren jedoch kann die funktion dann nicht darauf zugreifen und schreiben, oder sehen ich das falsch?

Mein Ziel ist es ja das von DateGenerator() generierte Array an die Funktion displayTime() zu übergeben....

Soweit ich also verstanden habe geht es nicht. Schade, also muss ich alle meine Arrays global definieren, ich dachte ich könnte meinen Code etwas übersichtlicher gestalten und so die unnötigen Array definitionen weglassen.

25  International / Deutsch / Array einer funktion zurückgeben on: June 10, 2014, 04:13:00 pm

Ich möchte ein Array aus einer Funktion an eine andere funktion übergeben ohne das ich diese global definieren muss, geht das?

Quasi in etwa so

void loop() {
  // put your main code here, to run repeatedly:
int* DateGenerator(){
  int MyArray[]= {0,0,0,};
  return MyArray[];
void displayTime(int DateArray[]){
 //do something with DataArray

Wie mache ich das richtig?
26  Using Arduino / Networking, Protocols, and Devices / Re: Problem with ArdOSCForWiFlyHQ on: June 10, 2014, 01:48:04 pm

I got it finally working (kind of)! Im receiving messages and can send messages to Touchosc using the wifly.

But the thing is, im Receiving messages like this:

/field1/rotary1 ,f BEï�
/field1/rotary1 ,f A
/field1/rotary1 ,f Bwb2
/field1/rotary1 ,f B™Z
/field1/rotary1 ,f B«.I
/field1/rotary1 ,f B¶
/field1/rotary1 ,f B\Û9
/field1/rotary1 ,f BÆ£
/field1/rotary1 ,f AÓöˆ
/field1/rotary1 ,f AK¹Ñ

Im using Serial.write( ); to read the data from the wifly, does anyone know what I'm doing wrong? Do I have to convert the value?

Also, when I hold the button in TouchOSC the message is repeatedly sent, after one second of pressing the button this is what I get:

/field1/rotary1 ,f @Ãï¢/field1/rotary1 ,f @ÂW•/engine/r/fi/fi/fie/fie,/ot/fi/fi 

Is this a buffer overflow?
27  Products / Arduino Due / Due SPI slow (especially for specific pin (DueExtendedSPI)) on: June 10, 2014, 09:35:53 am

I was just experimenting with my Adafruit Display which is using an ILI9340 Chip. It was quite slow so I tried to tweak it a little bit. The first thing that came to my mind was to change the clockdiver.

Im using this libary:

Stock clockdivider is 11 which is 7-6Mhz
Benchmark result:
Adafruit 2.2" SPI TFT Test!
Benchmark                Time (microseconds)
Screen fill 1913383
Text                     121685
Lines                    1147001
Horiz/Vert Lines         157330
Rectangles (outline)     101025
Rectangles (filled)      3972593
Circles (filled)         610004
Circles (outline)        500776
Triangles (outline)      363771
Triangles (filled)       1314108
Rounded rects (outline)  221244
Rounded rects (filled)   4345116

I changed it to 9
Benchmark results. Clockdivider = 9
Adafruit 2.2" SPI TFT Test!
Benchmark                Time (microseconds)
Screen fill 1803141
Text                     116696
Lines                    1100386
Horiz/Vert Lines         147317
Rectangles (outline)     94720
Rectangles (filled)      3743585
Circles (filled)         579950
Circles (outline)        480619
Triangles (outline)      348937
Triangles (filled)       1227087
Rounded rects (outline)  210705
Rounded rects (filled)   4093446

Which was a little bit better... Now, I just wanted to know the limit of the Display (or what happens when the signal is to fast). So I changed it to 2
Benchmark results. Clockdivider = 2
Adafruit 2.2" SPI TFT Test!
Benchmark                Time (microseconds)
Screen fill              1290915
Text                     92619
Lines                    872079
Horiz/Vert Lines         105513
Rectangles (outline)     68141
Rectangles (filled)      2680671
Circles (filled)         434087
Circles (outline)        380752
Triangles (outline)      276503
Triangles (filled)       882989
Rounded rects (outline)  162050
Rounded rects (filled)   2938015

Hm, I was puzzled... The screen is very fast and even the lines and small letters were without any fault. I thought there would be some kind of dead pixels or something, but nothing. The Display is cripy as always..
It was even working with a clockdivider of 1, so at full speed 84Mhz!

After this I tried the new "Sam feature", adding the SPI Pin for this mode and it made it terrible slow

Benchmark results. SPI.setClockDivider(2,_cs)
Benchmark                Time (microseconds)
Screen fill              1876418
Text                     120145
Lines                    1132974
Horiz/Vert Lines         153278
Rectangles (outline)     98503
Rectangles (filled)      3896083
Circles (filled)         600755
Circles (outline)        494876
Triangles (outline)      359256
Triangles (filled)       1276280
Rounded rects (outline)  217630
Rounded rects (filled)   4259117

Can anyone explain what is happening? Is the display really running at 42Mhz? And why is the new function slowing it down so much? I'd really like to use the SPI mode for specific Pins, but not when it is that slow. I think then it will be faster to write your own output specific Clockdivider function.

28  Using Arduino / Networking, Protocols, and Devices / Re: Problem with ArdOSCForWiFlyHQ on: June 06, 2014, 06:25:27 am
So, no one?

I thought this could be a simple fault in using some kind of function wrong :-/
29  Products / Arduino Due / Reset Button not working. on: June 05, 2014, 05:27:55 pm

I have a problem with my due. The reset button is not working. I tried to test it using a simple Serial write sketch...
Does anyone know why or how to fix this?
I noticed this as I was testing my Displayshield. Somehow it only showed something as I flashed the sketch to the Chip, after connecting/disconnecting the Arduino it was just showing a white screen.

int led = 13;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  Serial.println("reboot succesfull!");

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
Serial.println("not rebooting :(");
30  Using Arduino / Networking, Protocols, and Devices / Problem with ArdOSCForWiFlyHQ on: June 04, 2014, 05:15:16 pm

I just downloaded ArdOSCForWiFlyHQ and WiflyHQ and wanted to build the SimpleReceive example but I get the following error, Im using an Arduino Due:

C:\...\WiFlyHQ.cpp: In member function 'int8_t WiFly::getDHCPMode()':
C:\...\WiFlyHQ.cpp:1515: error: 'strncmp_P' was not declared in this scope
C:\...\WiFlyHQ.cpp: In member function 'boolean WiFly::getres(char*, int)':
C:\...\WiFlyHQ.cpp:1611: error: 'strncpy_P' was not declared in this scope

Here is the Sketch (which I just downloaded):
// How to send OSC messages from an Arduino.
// This Example is in the public domain.

// Important known issues:
// The Wifly provides no means to get the data from a single UDP package at a time
// Everything is just dumped to the serial connection.
// The only hint that a package is finished is that reading from the serial *might* time out
// To make things work anyway:
// 1. Use a high baud rate for communication with the Wifly: 115200 on a hardware serial is perfect.
// 2. Adjust the timeout in server.availableCheck(). 2ms works fine with 115200baud.
// 3. If possible, let the controlling Program pause at least 1.5 times the timout between sending OSC messages.

#include <WiFlyHQ.h>
#include <ArdOSCForWiFlyHQ.h>

//uncomment this to use a software serial if you dont own a MEGA
//#include <SoftwareSerial.h>
//SoftwareSerial softSerial(softSerialRx,softSerialTx);

WiFly wifly;
OSCServer server(&wifly);

int ledPin=13;

void setup()
  //use the convenient setup. Replace <HardwareSerial> by <SoftwareSerial> if you use one.
    &Serial1,   //the serial you want to use (this can also be a software serial)
    9600, // if you use a hardware serial, I would recommend the full 115200. This does not work with a software serial.
    true, // should we try some other baudrates if the currently selected one fails?
    "WLAN-466B23",  //Your Wifi Name (SSID)
    "SP-213B33501", //Your Wifi Password
    "WiFly",                 // Device name for identification in the network
    "",         // IP Adress of the Wifly. if 0 (without quotes), it will use dhcp to get an ip
    8000,                    // WiFly receive port
    "",       // Where to send outgoing Osc messages. "" will send to all hosts in the subnet
    8001,                     // outgoing port
    true // show debug information on Serial
  wifly.printStatusInfo(); //print some debug information

  pinMode(ledPin,OUTPUT); //prepare to fade th einternal LED by OSC
   // Register a callback fuction of the LED fading.
   // When a message is with the adress "/ard/ledFade" is received, "setLedFade" will be invoked.

void loop()
//check for new incoming messages. If a message with a registered adress is recieved, the callback function will be invoked.
    //debugoutln("alive!"); //callback after process

void setLedFade(OSCMessage *_mes){
  //get 1st argument(int32) and use it to fade the LED
  int fadeValue=_mes->getArgInt32(0);
  analogWrite(ledPin,fadeValue );

Link for the libraries:


Pages: 1 [2] 3 4 ... 10