Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Installation & Troubleshooting / Older arduino NG + 12v on: June 17, 2011, 11:08:56 am
Can I power my old (first-build, got it from SF in 2006 or 7) arduino using a car's 12v, on the 9v input? I could have swore the original arduino documentation said not to power the device with more than 9v, due to the regulator.

I am planning out the feasibility of building an MPGuino using parts I have laying around (and they are numerous!). As to why such a simple question is being asked here in the first place, I will now lament:

Upon looking for my answer on arduino's main site, I was struck with a sense of the achille's heel of open-source. I looked, and looked some more, and only found mentions of powering the arduino with USB. I searched for a good 20 minutes! I discovered that the arduino BT should never receive more than 5.5v, and that 9v batteries may drift a bit but the regulator can handle it.

But nowhere in the getting started guide nor the tutorials, was there a punctual mention of external power and its limitations. Maybe I didn't dig enough?

And that is where I find open-source's "achilles heel". Open source is a great idea and can be fruitful in innovative ways, but to someone approaching the site for the first time, useful information requires a bit of digging through disorganized ramble, and sometimes seems unattainable. The impression I get is, a whole lot of fragments cobbled together and called a product. Please, take this as constructive criticism, arduino creators, I really hope you come across this and my efforts are not wasted.

I entered the scene when arduino first came around. I couldn't imagine being a beginner now. Yes, the basics might be there, but really, some intuitive page organization would greatly reduce the amount of questions posted to the forum.

And that is why I find myself here, asking about a car battery's likelihood of frying my vintage arduino. </wall-of-text>
2  Forum 2005-2010 (read only) / Troubleshooting / Setting bluegiga settings on BT on: May 08, 2007, 08:14:14 pm
Hi. I'm trying to include in my sketch a command for the other end (PC) to set the passkey, among other things.

So, in my setup(), the first lines are:

 nvAddr = 64;
  nvByte = eeprom_read_byte((unsigned char *) nvAddr);
  dataByte = nvByte;
  Serial.begin(115200);        // open serial  
  if (dataByte != 0) {
    pinMode(7, OUTPUT);
    digitalWrite(7, HIGH);
    digitalWrite(7, LOW);
    for (ioByte=0; ioByte < dataByte; ioByte++) {
      nvByte = eeprom_read_byte((unsigned char *) nvAddr);
      Serial.print(nvByte, BYTE);
    nvByte = 0;
    nvAddr = 64;
    eeprom_write_byte((unsigned char *) nvAddr, nvByte);
    digitalWrite(7, HIGH);

nvByte and tmByte are of type "byte". "resetbox" is a function that sets pin 11 low. Pin 11 is hooked to the reset pin, and works properly.

To load the new stuff into eeprom, the code:

       while (Serial.available() < dataByte) delay(1);
        nvAddr = 64;
        nvByte =  dataByte;
        eeprom_write_byte((unsigned char *) nvAddr, nvByte);
        retVal = 1;
        while (retVal <= dataByte) {
          tmByte =;
          nvByte = eeprom_read_byte((unsigned char *) nvAddr);
          if (tmByte != nvByte) eeprom_write_byte((unsigned char *) nvAddr, tmByte);

I was hoping someone could look over this and point me in the right direction. My software sends a string similar to the setup sketch for the bluegiga, lines separated by cr/lf. The code runs, but the passkey doesn't change.
3  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: AVR Bootloader burn error in Arduino 9 and 10 on: November 08, 2007, 10:17:18 am
I have yesterday received my AVRISP mkII and had troubles using the builtin arduino burn bootloader function which uses avrdude.

The error I'm getting is,
avrdude: usbdev_open(): did not find any USB device "usb"

I did however find this guide useful:

This resulted in success burning my blank mega168 using an older arduino NG. Maybe being able to manually verify fuse bits and such, made it seem more likely to work.

Please note the following from the above link:
8. Click the "Board" panel, set and write the ISP frequency. If this is a virgin chip you must select 125.0 kHz. If you have already flashed this chip you can set it to 2.0 Mhz without issues. It will be a long day of programming if you don't take this step, as burning at 1.049 Khz takes forever.

This explains why some such as glasspusher experienced extremely long burntimes. Appropriately setting this frequency sped things up quite a bit.

4  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: found bug in Serial.available() on: March 24, 2007, 10:01:29 am
Note that I have installed the "make your arduino sketch size smaller" patch on 0007 and it seems this fix is included.
5  Forum 2005-2010 (read only) / Bugs & Suggestions / Unexpected results with variable initiation on: March 24, 2007, 10:17:38 am
Hello all,
I seem to be getting unexpected result with the compiler and I'll try my best track this down and document what exactly is happening. I spent a good amount of time hung up on this one.

Around the same time that I moved to multidimensional arrays, I started having problems reading from my sensors. The old manner was like such:

int shtData = 3;
int shtClk = 2;
void setup()
  pinMode(ledPin, OUTPUT);   // sets the digital pin 13 as output
  pinMode(piezoPin, OUTPUT);  
  pinMode(dbp, OUTPUT);
  Serial.begin(115200);        // open serial  
  pinMode(shtData, INPUT);
  pinMode(shtClk, OUTPUT);
  digitalWrite(shtData, HIGH);

void loop()
    logPtr = logPtr + 1;
    if (logPtr > logSize) logPtr = 0;    logTime = millis();
    localLogH[logPtr] = retVal;

and all was well. Then, to further complicate things, a total of 8 sensors was added. Four of these are actually two separate SHT11's with both temperature and humidity. The new code was something like this:

int shtClk = 2;                    // Common clock for both SHT11's
int shtData;                       // Selectable data pin

But there is a problem. For some reason, further on in the program, shtClk reads 0. Somewhere along the way, this variable is either not getting set, or getting reset. By putting a shtClk=2 in my setup() routine right before resetting the connection, everything works as expected. But initializing the variable in the definitions, it does not retain its value. Everything else in my program works properly, and I have checked to make sure that my arrays were been properly referenced and nothing was overwriting memory at any point.

I know that this is not a very... defining description of the rest of the program, but I can post additional information if necessary. I'm more curious if I am misunderstanding how initialization of variables works, or if this is actually a bug, and if anyone has encountered it before. I can move around where my program sets the variable in my setup() routine, to see if I can't figure out where it goes wrong.

Thanks for the help.
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: if statement evaluating complex expressions on: January 22, 2008, 10:03:36 am
So, then I guess both
(curdata >> 16)
~(curdata & 0xFFFF)
result in unsigned ints that get compared? If they resulted in unsigned long then the first statement would evaluate as 0000nnnn and the second as FFFFnnnn, since the leading 0's would be inverted. This is obviously not the case.

Regardless, it is working right in the "fixed" version with (~curdata & 0xFFFF) which is good.
7  Forum 2005-2010 (read only) / Syntax & Programs / if statement evaluating complex expressions on: January 21, 2008, 09:36:58 pm
Hi fellow coders, I'm having trouble wrapping my mind around a confusing issue and need some clarification regarding how if statements are evaluating.

The following code works, but it shouldn't:
if ((preamble == 150) && ((curdata >> 16) == ~(curdata & 0xFFFF))) {
    return(curdata & 0xFFFF);

In my transmitter code, the integer to be transmitted is shifted out, followed by its inverse. Here is the original thread in the hardware forum. In that thread,

I really don't know how it works like this.  If curdata == 0xAAAA5555 and you put it through

((curdata >> 16) == ~(curdata & 0xFFFF))

then (curdata >> 16) = 0x0000AAAA
and ~(curdata & 0xFFFF) = 0xFFFFAAAA

this is because curdata & 0xFFFF evaluates first giving 0x00005555, then the ~ is evaluated giving 0xFFFFAAAA.

I don't understand how that expression can ever evaluate to true. smiley-sad  If somebody knows that part of the puzzle please let me know!  [smiley=huh.gif]

you might want to try something like this:
(((curdata >> 16) & 0xFFFF) == (~curdata & 0xFFFF))

Again this code shouldn't work, but does. It is returning (curdata & 0xFFFF) which should be the real integer's inverse. But, it is returning the actual number sent from the transmitter.

The following code still works like above, but is properly put together and reads correctly:
   if ((preamble == 150) && ((curdata >> 16) == (~curdata & 0xFFFF))) {
      return(curdata >> 16);

The two code snippets work the same, except the former returns (curdata & 0xFFFF) which really should be the inverse of the actual number, and the latter code returns it properly (curdata >> 16). Something about the way the if statement evaluates, is causing it to work when it shouldn't. It has something to do with ~(expression) changing the value held in curdata methinks.

Could someone please explain why the code above works like it does? Thanks In Advance.
8  Forum 2005-2010 (read only) / Syntax & Programs / Start bootloader from within program? on: April 24, 2007, 11:20:54 am
Hi, I would like to be able to update firmware without having the physical unit. I was wondering if there is a way to call the bootloader, or reset the microcontroller, from within my code? This way, the PC software could trigger a reset, then launch the command-line upload program with the new ROM.

9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Sending arrays serially on: February 11, 2007, 03:07:57 pm
Thanks a lot! I'm not keen on the syntax, so I wouldn't have figured out how to derive the lsbyte/msbyte from an integer, to be sent as a byte.

Hopefully this will work for my application.
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: Sending arrays serially on: February 10, 2007, 10:16:39 am
See, that's a little more code-intensive than I wanted. But, I suppose I'll have to do it that way.

Even so, if I have an integer, and call Serial.print(var, BYTE), then if the var is > 255, it won't work.

How would I send an unsigned integer as two bytes? I suppose I could put the LS byte in one var and the ms portion ( that above 0x100 ) in another byte, and send em seperately. Again, it seems to me there should be a way to just send it all in one string by specifying the string (or char array), and length of it. Sort of like how many serial / socket libraries work when receiving data.
11  Forum 2005-2010 (read only) / Syntax & Programs / Sending arrays serially on: February 07, 2007, 03:54:49 pm
This one has me stumped.

What I'm trying to do is store an array in my Arduino, that gets updated with sensor values. These values are unsigned integers.

When the computer requests, I want to send back the array. I am trying to cut back on how much code is used. When sending back data to the computer, I "encapsulate" it by first sending each "packet" with a byte indicating the size of the data to follow.

This isn't working, and I think that it might be more simple if I were to just send the whole array as one string.

Before, I had something like this: (excerpts)
const int logSize = 127;
int localLog[logSize];          // Data while pc is off
        for (int adcCount=0; adcCount <= logSize; adcCount++) {

where that sendData is a function to encapsulate the data. that in itself takes up a lot of resources, so I was thinking if I could send the whole array back to the computer without all these loops, that'd be great.

problems with storing data comes in unsigned integers led to the change to that data type.

A separate program, created solely for the purposes of figuring out this challenge, goes like this:
int unsigned fubar[5];

After asking around on IRC for some syntax help, someone brought me to this:

with my array filled with numbers greater than 255, this works great, and sends back 14 bytes representing the values inside this array.

Problems were encountered, however, when a value of 255 or less was in one of these array elements. This is, because if an integer is less than 255, stored in memory it's "most significant byte" would be zero, indicating end of the string I am sending.

So, I want to send this whole array over, expecting some of the values to contain and translate to character zero, which causes the transmission to cease. Of course I know how much data in the end I will be transmitting, but I could not find any routines that let me tell the serial print function that I am passing it a string/char array, and specify the length.

Therefore, if at any where in my array something less than 256 exists, it interrupts the serial communication and my array is not received on the other end, in full.

So my question is, when sending a string (for example) that contains character 0, but is not intended to mark the end of the string, how would I send to the PC the whole entire string?

I did not see in HardwareSerial.h a definition of the print function also accepting the length of the data to be transmitted. How do you go about sending a full string, even if it has these characters in it?

My reason for this packetization is so that my PC software end of the contraption can discriminate between discrete responses to its requests.

12  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 17, 2007, 04:05:19 pm
I made a rough outline at

When I get some time later today, I'll go through and edit it up.
13  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 13, 2007, 04:40:54 pm
Big thanks to bigengineer and JimS! I'd never have expected it to be that delay right before conversion. Things have been busy here, so I won't get to try this out, but way to go on cracking this one guys!
14  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: December 30, 2006, 12:51:53 am
The atmega8 io pins have a maximum rating of 40mA per pin... But I'm not seeing maximum power consumption for the converter while converting in parasite mode. I did see the voltage drop about half after the start conversion command, so it must be trying to do parasite power.

Enabling pull-up on the data line by the microcontroller didn't seem to fix the problem. Also, I didn't spend too much time on the oscilliscope trying to perfect timings in accordance with the microcontroller.

So the fet is required to supply the device, and in that case, I assume a second digital out could be used to control that pull-up. If it could be done with the USB's 500mA, what would be suitable for this application? I need to order a few, there are no FET shops around these parts.

With a 750ms delay on conversions, if you had numerous devices on a line, it wouldn't be a very quick operation, to say the least. When I saw one when ordering my arduino, I thought it might be an interesting thing to use, but thermistors are just so much cheaper!  smiley
15  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: December 23, 2006, 07:04:00 pm
The datasheet says the chip will return "0" if it is requested, until the conversion is done. I think the temperature is stored in the scratchpad and shouldn't have to be read x amount of time after converting. Your guess is as good as mine :-?
Pages: [1] 2 3 ... 6