Show Posts
Pages: 1 2 [3] 4 5 ... 1863
31  Using Arduino / Programming Questions / Re: Saving int arrays to EEPROM? on: July 31, 2014, 03:47:49 pm
It's an unfortunate coincidence that the number of rows is the same as the number of bytes in an int in your first example.
32  Using Arduino / Programming Questions / Re: LED/Photocell on: July 31, 2014, 03:44:06 pm
Yup, ten into eight don't go.
33  Using Arduino / Project Guidance / Re: Serial Port Data Transfer Problem (Weird Character) on: July 31, 2014, 03:26:09 pm
Well, you can either not send it, or not display it.
If you're not up to fixing VB (I'm certainly not), I'd go with filtering out on the Arduino side.
34  Using Arduino / Project Guidance / Re: Serial Port Data Transfer Problem (Weird Character) on: July 31, 2014, 03:17:44 pm
Carriage Return / Line Feed

A throwback to mechanical teletypes.
35  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 03:11:16 pm
Quote
Can atoi be useful in this?
Maybe, but printing char(acters) as char(acters) rather than as "int"s may yield simpler results.
36  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 02:52:02 pm
Evidently, given that you are expecting the packet: "W128", AWOL is too subtle:
It's probably my only failing.  smiley-cool
37  Using Arduino / Project Guidance / MOVED: Measuring CPU and GPU Temperatures on: July 31, 2014, 02:39:18 pm
This topic has been moved to Interfacing w/ Software on the Computer .

http://forum.arduino.cc/index.php?topic=257930.0
38  Using Arduino / Programming Questions / Re: Saving int arrays to EEPROM? on: July 31, 2014, 02:36:41 pm
I have an entirely rational aversion to magic numbers.
(Uncompiled, untested)
Code:
#include <EEPROM.h>

const byte ROWS = 2;
const byte COLS = 8;
const int ADDRESS_OFFSET = 50;

int my2dArray[ROWS][COLS] =
{
  {0x8888, 0x9999, 0xAAAA, 0xBBBB, 0xCCCC, 0xDDDD, 0xEEEE, 0xFFFF},
  {0x9999, 0xAAAA, 0xBBBB, 0xCCCC, 0xDDDD, 0xEEEE, 0xFFFF, 0x8888}
};

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

  int address;

  Serial.println ("Writing data.....");

  for(int j=0; j<ROWS; j++){

    Serial.println();

    for(int i=0; i<COLS; i++){

      EEPROMWriteInt(address= ((ROWS*i)+(j * COLS * sizeof (my2dArray [0][0]))+ ADDRESS_OFFSET), my2dArray[j][i]);
      Serial.println(address);
     
    }
  }
  Serial.println();
  Serial.println();
  Serial.println ("Reading data.....");

  for(int j=0; j<ROWS; j++){

    Serial.println();

    for(int i=0; i<COLS; i++){

      unsigned int value= EEPROMReadInt(address=(ROWS*i)+(j*COLS*sizeof (my2dArray [0][0]))+ADDRESS_OFFSET);
      Serial.print(address);
      Serial.print('\t');
      Serial.println(value,HEX);

    }
  }
}

void loop(){
}

//integer read/write functions found at http://forum.arduino.cc/index.php/topic,37470.0.html
//This function will write a 2 byte integer to the eeprom at the specified address and address + 1

void EEPROMWriteInt(int p_address, int p_value)
{
  byte lowByte = ((p_value >> 0) & 0xFF);
  byte highByte = ((p_value >> 8) & 0xFF);

  EEPROM.write(p_address, lowByte);
  EEPROM.write(p_address + 1, highByte);
}

//This function will read a 2 byte integer from the eeprom at the specified address and address + 1
unsigned int EEPROMReadInt(int p_address)
{
  byte lowByte = EEPROM.read(p_address);
  byte highByte = EEPROM.read(p_address + 1);
  return ((lowByte << 0) & 0xFF) + ((highByte << 8)& 0xFF00);

}
39  Using Arduino / Motors, Mechanics, and Power / Re: Servo Randomly Turns to 180 degrees on: July 31, 2014, 02:06:27 pm
Code:
     if (brakeVal > 10);
Oops
40  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 02:01:34 pm
http://www.asciitable.com/
41  Using Arduino / Interfacing w/ Software on the Computer / Re: Measuring CPU and GPU Temperatures on: July 31, 2014, 01:45:37 pm
Quote
I have found some codes that are not correct. They always give me same results. Any idea?
Don't use those codes.
Seriously?

Post your code.
42  Using Arduino / Programming Questions / Re: Combining Codes - LED with pushbutton and timer interrupt on: July 31, 2014, 12:00:47 pm
Quote
However, it's not consistently working
150ms is a long time to miss a short switch operation.

What is stopping your inputs from floating?
43  Using Arduino / Programming Questions / Re: Combining Codes - LED with pushbutton and timer interrupt on: July 31, 2014, 10:00:30 am
Quote
Any suggestions?
The usual - get rid of calls to "delay()" and look at the blink-without-delay example.
44  Using Arduino / Programming Questions / Re: traffic lights on arduino atmega 256 on: July 31, 2014, 08:44:12 am
You can almost certainly write all 20 outputs using digitalWrite in less time than it would take a human to notice the lag.

Concentrate on making them failsafe, not fast.
45  Using Arduino / Programming Questions / Re: Help with Platform I/o definitions on arduino on: July 31, 2014, 08:06:43 am
It depends on which board you're using - that's why the code is written like it is.
Pages: 1 2 [3] 4 5 ... 1863