Show Posts
Pages: 1 ... 64 65 [66] 67 68 ... 111
976  Using Arduino / Audio / Re: MIDI Note Player Help Needed on: January 13, 2013, 05:32:40 pm
Your code is definitely sending the note on and note off messages so I'd suggest that you check your connections again.

Pete
977  Using Arduino / Project Guidance / Re: Excel sheet With arduino UNO on: January 13, 2013, 04:47:01 pm
You can write the data to a file on the SD as a Comma-Separated Values file. A CSV file can be read directly by Excel.

Pete
978  Using Arduino / Networking, Protocols, and Devices / Re: I2C locking with any mor than 3 bytes sent on: January 12, 2013, 04:55:16 pm
The receiver code is reading bytes even if there are none available.
If Wire.available() is non-zero it only means that there is at least one byte available - not that there are however many you need.
Try this (and note how it is been reformatted):
Code:
void receiveEvent(int howMany) {
  for(readit=0;readit<howMany;readit++) {
      // Wait for an available byte
      while(!Wire.available());
      // read it
      data[readit]= Wire.read();
      Serial.print("received ");
      Serial.print(readit+1,DEC);
      Serial.print(" value=");
      Serial.print(data[readit],DEC);
  }
}

Pete
P.S. this is a programming problem. Nothing to do with installation.
979  Using Arduino / Programming Questions / Re: CCITT-16 initialized to 0 any ideo how to compute that on: January 11, 2013, 07:19:48 pm
Quote
• CRC1 is calculated using only the first 6 bytes of the packet.
• CRC2 is calculated using all previous bytes in the packet (i.e. bytes 0 through N).
The result is the same.
If your data are the six bytes $6E,$00,$00,$10,$00,$02
and you tack the CRC on the end to give $6E,$00,$00,$10,$00,$02,$BC,$9A
then the CRC of these eight bytes is zero - this is a property of any CRC.
So, the CRC of either the ten bytes
$6E,$00,$00,$10,$00,$02,$BC,$9A,$00,$0B
or of the two bytes
$00,$0B
is the same - $B1,$6B.

Try it.

Pete
980  Using Arduino / Programming Questions / Re: CCITT-16 initialized to 0 any ideo how to compute that on: January 11, 2013, 07:06:45 pm
P.S. your problem is remarkably similar to this thread:
http://arduino.cc/forum/index.php/topic,96539.0.html

Pete
981  Using Arduino / Programming Questions / Re: CCITT-16 initialized to 0 any ideo how to compute that on: January 11, 2013, 07:00:49 pm
The data are not structured the way you described.
The first block of data is the six bytes $6E,$00,$00,$10,$00,$02 and their CCITT CRC-16 is $BC,$9A
The second block of data is just the two bytes $00,$0B and their CRC is $B1,$6B
Which gives the whole data block,
$6E,$00,$00,$10,$00,$02, $BC,$9A, $00,$0B, $B1,$6B

Pete
982  Using Arduino / Programming Questions / Re: if structure takes too much time on: January 10, 2013, 04:18:23 pm
It's probably because of this:
Code:
//Cas phares de détresse
 else if (digitalRead(PharesDetresse) == HIGH)
 {
  analogWrite(LEDpin, 255);
  delay (100);
  analogWrite(LEDpin, 25);
  delay (800);
 }
If the pin is HIGH, the statement delays 900ms which is "(almost a second approx)".

Pete
983  Using Arduino / Programming Questions / Re: Serial.print not printing... on: January 10, 2013, 11:15:07 am
Ninja'd by a few hours. Sprintf was going to be my lesson for this morning but I slept in smiley

Pete
984  Using Arduino / Programming Questions / Re: Serial.print not printing... on: January 09, 2013, 10:41:17 pm
:-)
985  Using Arduino / Programming Questions / Re: Clipboard does not contain a string on: January 09, 2013, 10:38:36 pm
Works for me on Win 7 and 1.0.3.
Are you highlighting and copying only the code?

Pete
986  Using Arduino / Programming Questions / Re: Serial.print not printing... on: January 09, 2013, 10:34:27 pm
If mainbatt, for example, is 56 your code will print 056, not 0056. If it is 9, your code will print 009.
If any of the three is greater than 99 your code won't print anything.

Pete

 
987  Using Arduino / Programming Questions / Re: Serial.print not printing... on: January 09, 2013, 10:19:37 pm
You got the comparison operator correct here:
Code:
while (compCONNECT == 0)
but wrong here:
Code:
if (loadcell = 0)
and a couple of other places too.

Pete
988  Using Arduino / Programming Questions / Re: Algorithm to rotate data on: January 09, 2013, 12:29:00 pm
This rotates the bits of an 8x8 font:
Code:
unsigned char font[8] = {
  0B10101010,
  0B11001100,
  0B11100111,
  0B00111100,
  0B01001001,
  0B10110111,
  0B11000101,
  0B01011101
};
unsigned char font_r[8];

// print an 8x8 bit font
void print_font_bits(unsigned char *font)
{
  unsigned char c;
  for(int i=0;i<8;i++) {
    c = *font++;
    for(int j=0;j<8;j++) {
      if(c & 0x80)
        Serial.print("1");
      else
        Serial.print("0");
      c <<= 1;
    }
    Serial.println("");
  }
}

// rotate the 8x8 bit font at *f and store the result in *fr
// This will not do a rotate in place so the output font
// must not be the same array as the input font
void rotate_font(unsigned char *f,unsigned char *fr)
{
  unsigned char *fi;
  unsigned char bit = 0x80;
  unsigned char rf;
  for(int i = 0;i<8;i++) {
    fi = f;
    rf = 0;
    for(int j = 0;j<8;j++) {
      rf >>= 1;
      if(*fi++ & bit)rf |= 0x80;
    }
    bit >>= 1;
    *fr++ = rf;
  }
}

void setup(void)
{
  Serial.begin(9600);
  print_font_bits(font);
  Serial.println("");
  rotate_font(font,font_r);
  print_font_bits(font_r);
}

void loop(void)
{
}

Pete
989  Using Arduino / Programming Questions / Re: Can a temp sensor cause the Arduino to lock up? on: January 06, 2013, 04:18:53 pm
The sendData function doesn't close the wifly connection. Add this at the end of the function:
Code:
    wifly.close();

Pete
990  Using Arduino / Programming Questions / Re: Can a temp sensor cause the Arduino to lock up? on: January 05, 2013, 05:47:17 pm
The DS18B20 does not provide the temperature immediately after starting a conversion. For 12-bit precision you have to wait approximately 800 milliseconds before reading the result. For 9 bit precision you only have to wait about 100ms. When in doubt, use delay(1000).

Pete
Pages: 1 ... 64 65 [66] 67 68 ... 111