text:
Can't store temperature in variable ( for further processing)
I am trying to store temperature data in a variable, so that I can use it for making a JSON object, but the problem is, that when I try to store the temperature in a variable, it prints out the wrong value. I'm using a DHT11 temperature/humidity sensor and a library for calculating the temperature.
Serial.print("Temperature (°C): ");
Serial.println((float)DHT11.temperature, DEC);
int temp1 = ((float)DHT11.temperature, DEC);
Serial.println(temp1);

These 4 lines is printing out this:
Temperature (Â°C): 23.0000000000
10

The first one is correct, but the second line should also be saying "23".
I have tried only loading the data in once with the library, as in outcommenting one line, but that does not work.
It's like I have some syntax wrong, but I can't figure out what.

This line:

int temp1 = ((float)DHT11.temperature, DEC);

casts DHT11.temperature to an float, throws away the value, then assigns DEC to temp1. That is not what you want.

int temp1 = DHT11.temperature;

Thank you so much. This fixed it straight away. I knew it was just some stupid syntax that I was doing wrong, but I just couldn't figure out what. Thnx.

For extra reading: http://en.wikipedia.org/wiki/Comma_operator


text:
Throughput and BER test with nRF24L01+ radio and Teensy microcontroller
I am trying to modify the example given in the this page to a basic throughput and BER test with two nRF24L01+ and Teensy 3.0 modules.
I want to modify the nrf24l01_send_string example in a way that I can remove the powerUp powerDown and delay and transmit the next packet purely based on the ACK received from the receiver. The problem is RF24 class does not seem to have a method to transmit ACK (not ACK+Payload) and the datasheet does give any information on the structure of the ACK message. The example works when powerUp and powerDown are removed, but I need to modify it to measure throughput by removing the delay.

You can't send the ACK manually. The module itself sends the ACK automatically (if enabled that is), once it receives the package. This way the sending module only need to be listening for the ACK for the shortest amount of time, reducing power usage. To attach data to the ACK package you need the writeAckPayload function. But you have to prepare this before any package is received.

Thanks for the reply. The data string in the example in sent in a loop. I have to stop and listen to the ACK before resuming the loop. If I reduce the delay below 500 the arduino serial monitor hangs. Inorder to listen to the ACK using the read() function I need to know the structure of the ACK payload esp. the number of bytes in the ACK message. This information is not there in the documentation. Also, how do I find the CRC checksum after receiving the packet to calculate BER?

You can use getPayloadSize to get the size. No way to get to the CRC, as the module handles the CRC and rejects messages with incorrect CRC.

I'm sending 32 byte payload(in loop) with data rate set to 2MBPS and setRetries parameters of 0(250us) and 3(retries) respectively. The throughput I get is only 45 KBPS. The delay between consecutive 32 byte packets is 700us which works out to the above mentioned throughput. Is there any way to get closer to the set data rate of 2MBPS?

You could try filling the buffer, instead of sending 1 packet at a time to the module. Use startWrite, instead of write. I think however that then you won't be able to determine is a packet was ACKed.

I copy-pasted @Gerben comment as the answer. Please, accept it to close the question or delete the question itself.

Please stop asking to delete questions. The information in the comments might still be useful to someone else. Deleting the question will remove everything.

@Gerben remarked:

You can't send the ACK manually. The module itself sends the ACK
  automatically (if enabled that is), once it receives the package. This
  way the sending module only need to be listening for the ACK for the
  shortest amount of time, reducing power usage. To attach data to the
  ACK package you need the writeAckPayload function. But you have to
  prepare this before any package is received

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Arduino RF24 library Delay after write function causes no byte availability
It's about the RF24 library you can find here. http://maniacbug.github.io/RF24/index.html
I transmit data from one Arduino to another using NRF24L01 radios.
When I use the write-function on the transmitter arduino (joystick is an array) and after that I put in a delay higher then 10, the available function returns false.
Transmitter
radio.write( joystick, sizeof(joystick) );
delay(20);

Receiver
if(!available())
  print('No data'); // delay > 10 --> No data will be printed

Why is it working with a delay of 10 but not above? Has it something to do with timeouts which is mentioned in the docs of the library?: http://maniacbug.github.io/RF24/classRF24.html#a4cd4c198a47704db20b6b5cf0731cd58
Thank you for your answers.

Don't you check repeatedly to see if data becomes available later?  Unless you use an interrupt from the radio to the processor, you will need to.

I check repeatedly in the sense of the standard loop. What I think is, that Arduino prints a huge amount of "No data" because of the delay. When delay is over, one single line is different, then again a huge amount of "No data" lines. I was scrolling the Serial Monitor, but this was not the case. Or maybe I scrolled not long enough? Would be interesting how many milliseconds a small loop needs to complete...But I think it's just better when I use: while(!radio.available()) {} so that only something happens when there is a payload. I will try this today.

Yes, it's not usually useful to repeatedly log that data is not available, thiugh if you are really curious you could count the number of loops until data is obtained and print that with the data.

Nice, that's a great idea. Yes, I'm very curious about this. I will share the result after I tried.

I consider that if statement without brackets kinda risky since it's harder to read than brackets. Apparently there's more code here; can you add that so we can see if there's another issue? I like that you tried to make it smaller, but can you please include an example with enough to compile? Thanks! (On a side note, what's this joystick variable? A class?)

Hey Penguin, thanks for your comment. joystick is an array and I copied the tutorial from here: http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo      Just scroll down or search for "EXAMPLE ARDUINO SKETCHES" on the site. All I did was to hang on the delay after the radio.write in the YD_nRF24L01_Transmit_JoyStick example as you can see in my initial question. I am looking forward for your try :-)

I have exactly the same issue with the same code. Joystick is an array of a few bytes. This seems to be a hardware issue. When I use the same code with nrf24l01 recently bought on Aliexpress I have this issue. With other nrf24l01 from Bangood, the same code works with 800ms delay or any other delay. There must be something different in the hardware of the new nrf24l01.

This is a snippet, isn't it? print('No data'); would not print "No data" because you are using the wrong quotes. It is difficult to answer such questions without the actual code being posted.

I've got the same issue and placed this issue to the Github issue tracker. hope there comes an answer: https://github.com/maniacbug/RF24/issues/68

@Greccofly There will be no answer because that library has been abandoned. Please use the https://github.com/TMRh20/RF24 library. It should also be available in the builtin library manager so you don't have to worry about updating it.

In my situation the issue was with the Transmitter not continuing to transmit after a delay. I was able to resolve the issue using the powerDown (http://maniacbug.github.io/RF24/classRF24.html#aa0a51923a09ba4f3478aba9be0f8a6a1) and powerUp (http://maniacbug.github.io/RF24/classRF24.html#a5cdaf47aa0edd6dca1b9a8bb7972a1a3) functions. Here is a snipet of my code. "radioTx" is the name assigned to my transmitter.
//standard code setup for arduino uno board examples
radioTx.begin();
radioTx.setChannel(108);
radioTx.openWritingPipe(pipe);

}

void loop() {

  int dist_cm = sonar.ping_cm();

  Serial.println(dist_cm);
  radioTx.write(&dist_cm,sizeof(dist_cm));
  radioTx.powerDown();
  delay(5000);
  radioTx.powerUp();

  }

I had the same problem. My solution is:
First make .stopListening()
then .write(&data, sizeof(data))
and behind the write command an .startListening().
Now you can delay for longer times.

Welcome to Arduino SE! I'm having trouble understanding what you mean. The stopListening() command seems helpful, although can you explain how the .write(&data, sizeof(data)) would help? Thanks!

Try using
unsigned long t = millis();
while(millis() - t < DELAY);

instead of "delay(DELAY)"

Please read this: Arduino NRF24L01+ arduino to netmf transmit issue
Although you are not using NETMF, @PhilVallone uses the library and chip together successfully, points out the samples are not asynchronous, and addresses time-out. The OP for that question is using delay(1000) and no answer has been accepted.

I don't believe there is any use of interrupts or threading involved, making this mostly irrelevant.  Do you have evidence otherwise?

Answers should have some relevance to the problem - random unrelated suggestions do not.

And what bootloader bugs do you think might be relevant?  Do you realize how self contained the code in question is? This is not helpful, it's an uninformed grasping at straws.

Please take some time to actually read the code associated with the question...

With your feedback, I have backtracked and await the OP's reply.

Try updating your library to the new TMRh20 fork. That improves the old maniacbug's version a lot (possibly also fixing the bug). tmrh20.github.io/RF24
It's also worth noting that after you've read the message, it will print out "no data" until you receive new message.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Arduino cannot communicate with PC after running servo
I was messing around with my arduino uno r3 and servo today. The book I got said to run the servo through the arduino. Everything was fine. I started changing the code, and then things started to get bad. I noticed that if I did not put a delay in between the servo movements, the board would freeze, and I would have to get lucky. Well now I just can't communicate with the board. I plug the board in to my pc, windows 7 makes the connection sound, the board turns on the ON light, the L light flashes, then goes steady. In the arduino software, the COM3 port, which is where I'm plugging it in, is not coming up. Only COM1 is there. I'm not sure what to do. The board is still functioning, the servo moves. I tried to plug it in with a different port and with the servo disconnected but it still doesn't want to communicate with my pc. The code I'm using is below
#include <Servo.h>

Servo servo1;

void setup()
{
  servo1.attach(9);
}

void loop()
{
  servo1.write(50);
  delay(500);
  servo1.write(90);
  delay(500);
  servo1.write(140);
  delay(1000);

  for(int i = 50;i<140;i+=10){
    servo1.write(i);
    delay(10);
  }
}

I would also like to add that I understand that you shouldn't run the servos through an arduino. I was following the book, and began researching when things went down hill.

Look at your serial devices or unkown devices in device manager.  It only takes a pullup resistor to get the device sound, quite a bit more has to be intact for a functioning port.

I've had some problems in the past reprogramming my Arduino Uno if it writes to the serial port - I don't know if the problem is the same, but here's how I got around it:
Option 1: Hold down the reset switch, then plug your Arduino into the USB port. Select the right COM port (if needed), compile your code (something ultra simple, e.g. blink led), and then, JUST BEFORE IT STARTS UPLOADING, release the reset switch. Wash, rinse, repeat, until you get it to work, through blind luck.
Option 2: Get hold of a ICSP (such as the one I got, USBASP made by FreeTronics  http://www.freetronics.com.au/products/usbasp-icsp-programmer-for-avr-arduino#.VL8Vv3WjlIc which I am v. happy with), plug it into the serial port, plug the other end onto your Arduino UNO ICSP header (6 pins, opposite end of the board from USB), then select Tools -> Burn Bootloader. Overwrites any program, works 100% of the time. Now you can unplug your USBASP, and plug your Uno back in and program it normally. This is also a great tool if you end up using AtMega (or AtTiny) chips directly (AtMega is the chip used to do all the work on the Arduino).
To avoid this, I have gotten into the habit of putting a 5 second delay as the first thing in the startup code.
FOR FUTURE GENERATIONS: I got mine here in New Zealand, so that will probably not help most people. FreeTronics makes them, and I am very happy I got their one (they have a "slow clock" jumper that is very convenient when programming Atmel chips not on an Arduino board), I expect that any USBASP would do the trick too - in response to the question, Amazon has a couple under $4, and I expect that the price will not go up.
Search for "USBASP". Make sure you get a ribbon cable. For Arduino Uno, you need a 6-pin ribbon cable. It is also possible to use these cables to communicated directly with a running Arduino over these same pins.

I would do option 1 however I cannot select COM3/4, which is where I plug my arduino in. Can you point me in the direction of an USBASP. Preferably an Amazon Prime item so that I can get the product quickly.

It just started communicating with the pc again... strange but thankful. Quickly added what you suggested (the 5 second delay) to the start. Thanks for the help.


text:
Is this Bluetooth module cool for Arduino?
I am making a basic project that will have 4 or 5 arduino nodes. Each arduino will have a bluetooth module attached. The thing I want is, I want to be able for each one of these arduinos to know the other is present in the room (let's say, 5 meters). For my experience in the cellphone, I don't even have to pair bluetooth devices to know about their presence, as long as they are in visible mode. Since I just need to know their presence, and no exchange of information will ever happen, I probably will never have to pair them right?
For this project I need a bluetooth (BT) module that:
1) Enables me to change the ID of each arduino, so that, even if I use my cellphone to scan for BT devices I will see (Arduino1, Arduino2, etc...) instead of default-factory-names.
2) Enables me to scan around for existing devices every time each X seconds, because I want each arduino to know if the others are in the room.
Will this module do the trick? http://www.ebay.co.uk/itm/Interface-Base-Board-Serial-Transceiver-Bluetooth-Module-For-Arduino-UNO-R3-/111482008102?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item19f4d87226
Later I will probably hang around with batteries so I will want a low power BT module, having the same 2 capabilities mentioned. Will NRF8001 do the trick for me? http://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF8001
Thanks!

This is not even remotely an Arduino question, but rather one which belongs on EESE.

From skimming that post, I believe that your linked pcb is not a full bluetooth module (note how there is no bluetooth chip or antenna of any kind). This is simply a "base board," which is why it is so cheap1.
You will need something like this that actually has the components you want.
To answer your questions:

The bluetooth library for arduino sets the discoverale name to ARDUINOBT by default, but that can be changed in the setup() method.
"scan around" is a little ambiguous—AFAIK, bluetooth can only connect to one device at a time, but I'm not sure if that's totally true. You may want to look into using radios instead of BT, as they can communicate more freely with one another, are extremely cheap, and have extensive arduino libraries availible. I'm currently working on a project that uses the nRF24L01, and I'd be happy to answer any questions you have about it.

1: It also has a draw of 6v VCC, which is more than the Uno can output.

Also, I believe this arduino forum post is talking about the same exact boards. Lots of information there if you're interested.

I have the idea that while you are scanning for other devices no connection is being made (correct me if im wrong). In that case I won't even make a connection. I am just interested in the part where you scan for visible devices. Like what you do on your phone: https://motorola-global-eng.custhelp.com/rnt/rnw/img/enduser/wirelesssettingsdroidx2bluetooth.jpg
I am interested in that list which shows the devices that I can connect to (but I won't connect because I only want to know their presence and that list is enough for that).

Ah, sorry I misunderstood. Yeah, I'm pretty sure there's a bluetooth library with functions to get an array of available devices to pair to. You would simply then need to write a sketch to print that array to serial or display it in some way. Check out the various bluetooth libraries people have created for arduino—a quick google search should give you a whole bunch.

The first link is for a breakout board only - it has a placeholder for a BT module, similar to the HC Bluetooth models series, but it is not a complete Bluetooth board (hence the "Interface Base Board" in the product's title). Please do not do that mistake - I did it already :)
For your purposes, it seems that something similar to the cheap HC-05 can satisfy both requirements: You can change the device name, and perform inquiry to scan other Bluetooth devices' MAC address, both using AT commands.
It has low operation voltage (1.8v-3.6v), but it operates as the good-old 2.1 Bluetooth standard, which waste a LOT of energy while running. If power consumption is a prime requirement, you might want to consider the more expensive Bluetooth low energy, such as a breakout board for the chip you suggested (the NRF8001).

Should've been a comment, but...
First of all, your questions 1 and 2: yes, that can be done.
I'd go for a HC-05 just like Omer suggests. And if you want to pair them, it is perfectly possible to pair one master with several slaves. Depending on implementation, a slave can connect to several masters too. The HC-05 can switch between these modes.
You can't do it with a NRF8001, as this is a BLE slave device only, it won't do scanning. Try to find a device that can do both, like BLE mini.
You can't mix BLE and Bluetooth devices for this, it's either or.


text:
How can I make pinMode calls faster?
I'm trying to use 3 pins as capacitive pins along side the Mozzi.
I had several attempts and so far the closest I had was using code from the ADCTouch library straight into the main code, but with the current implementation (removing averaging and taking less samples to speed things up) it's only fast enough to process 1 pin and I'd like to use 3.
Here is my implementation so far:
/*  Based on the Gain Example changing the gain of a sinewave,
    using Mozzi sonification library.

    Demonstrates the use of a control variable to influence an
    audio signal.

    Circuit: Audio output on digital pin 9 on a Uno or similar, or
    DAC/A14 on Teensy 3.0/3.1, or
    check the README or http://sensorium.github.com/Mozzi/

    Mozzi help/discussion/announcements:
    https://groups.google.com/forum/#!forum/mozzi-users

    Tim Barrass 2012, CC by-nc-sa.
*/

#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin2048_int8.h> // sine table for oscillator

// use: Oscil <table_size, update_rate> oscilName (wavetable), look in .h file of table #included above
Oscil <SIN2048_NUM_CELLS, AUDIO_RATE> aSin(SIN2048_DATA);

// control variable, use the smallest data size you can for anything used in audio
byte gain = 255;

//ADC Touch setup
int sampleCount[3] = {0};
int values[3] = {0};

void setup(){
  startMozzi(); // start with default control rate of 64
  aSin.setFreq(4200); // set the frequency
}

void updateControl(){
  if(gain > 3){
    gain = gain - 3 ;
  }else{
    gain = 0;
  }
  //begin ADCTouch
  pinMode(A4, INPUT_PULLUP);

  ADMUX |=   0b11111;
  ADCSRA |= (1<<ADSC); //start conversion
  ADCSRA |= (1<<ADIF); //reset the flag

  pinMode(A4, INPUT);

  values[0] = mozziAnalogRead(A4);
  sampleCount[0]++;
  //end ADCTouch

  if(sampleCount[0] == 64){//wait for 64 samples
    if(values[0] > 500) {//did we get a touch with all these samples ?
      gain = 255;//amp it up
    }
    sampleCount[0] = 0;//reset count
  }

}

int updateAudio(){
  return (aSin.next()* gain)>>8; // shift back to STANDARD audio range, like /256 but faster
}

void loop(){
  audioHook(); // required here
}

The issue is as soon as do the pinMode calls for the second pin I'd like to use (A5) so I'm guessing pinMode needs to work faster. To use pinMode(INPUT_PULLUP) and pinMode(INPUT) calls for pins A4,A5 and digital 10, now can I write this using direct port manipulation ?
(I'm new to avr/arduino internals and slowly getting the grips with this).

First, figure out which port and pin you're using. Then, manipulate them.
DDRC &= ~_BV(PC5);
PORTC |= _BV(PC5);

...
DDRF &= ~_BV(PF5);
PORTF |= _BV(PF5);

...
DDRF &= ~_BV(PF0);
PORTF |= _BV(PF0);

Thank you for the quick reply(+1). Since I'm still a n00b I had to do a bit of googling. Found this nice diagram and also found a note that I should rename these constants to PORTC5/PORTF5/PORTF0 and that's how I could compile my modified code. Also, I assume these are for INPUT_PULLUP. and for INPUT I just need to do PORT |= 0,PORTF |= 0 right ? Thanks again for your help and sorry to "pull your sleeve", but could use more details as a novice

@GeorgeProfenza You're not improving your code by renaming the constants. Nobody will be able to understand it when you ask for support or try to Google for information. I'd advise to use the standard names. Download the full datasheet for the ATmega328 from the Atmel website and read chapter 14. I/O-Ports. The AVR datasheets are usually pretty good and you should consider to check out other chapters too. You'll also notice that these register names are used

throughout the datasheet.

@jippie The datasheet actually used PORTC5 instead of PC5 in the older versions of the datasheet. My 2009 version does (guess I should update my local pdf file)

@Gerben Always use the latest release of (any) the datasheet. Check errata if you like, mistakes are corrected every so often an some can cost you lots of troubleshooting time. Whenever possible check the vendor website of a device an use other websites only for backup.

@Ignacio Vazquez-Abrams I don't mind sticking to the constants you recommend. Where these be defined so I can include them in my sketch ?

They're available via <avr/io.h>, which is already included by the IDE.

Hmm, I must be doing something wrong because I added the include but I still get errors finding these constants:sketch_jan28a.ino:64:3: error: 'DDRF' was not declared in this scope In file included from /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/include/avr/io.h:99:0,                  from sketch_jan28a.ino:16: sketch_jan28a.ino:64:16: error: 'PF5' was not declared in this scope sketch_jan28a.ino:65:3: error: 'PORTF' was not declared in this scope Error compiling.

Does your Arduino actually have a port F?

I have no idea, but I'm guessing not since your code doesn't compile ? I did mention I'm new to this and I don't really have control over what I'm doing at the moment. Any hints/tips in the right direction are more than welcome

... Let's start with the very basics. What Arduino are you using?

Thank you for your patience. I am using a SquareWear2.3 board which uses an atmega328p mcu

Take a look at both the Arduino pin mapping for the '168/'328 as well as the datasheet itself.

Thank you for all the advice. Sorry I haven't marked it. I also found this library which looks helpful


text:
W5100 module hookup help - Not a shield
I recently purchased a W5100 based ethernet shield for my arduino Uno, and looks like this. I had been following the guide here, and connected the pins accordingly - 5V to 5V, GND to GND, MOSI to 11, MOSO to 12, SCK to 13, and SS to ten.
I booted up a default sketch (webServer, under Ethernet), and plugged in and ethernet cable. - PWR, LINK, SPD,and FDX all lit up, with Rx blinking for first 10 or so seconds. I then go to the IP specified on the arduino sketch, and nada. Also, my router doesn't show the shield under the attached devices.
Therefore, I figure it's a problem with my connections. Can anyone help me? Googling has only brought my lots of info about shields, and little info on these modules.

Just to sanity check - can you post the IP address of your router (or your PC) and the IP address you used in the sketch?

Router's address is 192.1681.1.1 - a default. The IP used in the sketch, for the Ethernet's 192.168.1.177

First, if you cannot connect to arduino by ethernet, use Serial Monitor and add some Serial.println to your code to log what is going - what part of program Arduino is executing.
W5100 module has no automatic reset module as opposed to Ethernet shield.
So try to connect W5100 RST pin to for example D8 and reset module in setup.
Here you are example from my (working) project:
const int W5100_RESET_PIN = 8;

void setup() {
  Serial.begin(SERIAL_SPEED);
  Serial.println();
  Serial.println(F("node starting..."));
  pinMode(W5100_RESET_PIN, OUTPUT);
  digitalWrite(W5100_RESET_PIN, LOW);
  delay(100);
  digitalWrite(W5100_RESET_PIN, HIGH);
  // give the Ethernet shield a second to initialize:
  delay(3000);
#ifdef USE_DHCP
  Serial.println(F("DHCP..."));
  while (Ethernet.begin(mac) == 0) {
    Serial.println(F("DHCP failed."));
    delay(10000);
  }
#else
  Serial.print(F("static IP..."));
  Ethernet.begin(mac, IPAddress(MY_IP));
#endif
  Serial.print(F("local IP:"));
  Serial.println(Ethernet.localIP());
  Serial.println(F("node started."));
}

Also after setup if your arduino lost ethernet connection and cannot get it again, you can try to reset w5100 and initialize Ethernet again.


text:
Sparkfun Red board and CC3000 shield not allowing multiple HTTP_GET requests.
I have a SparkFun Red board (Arduino Uno R3) with a SparkFun CC3000 shield attached. I am trying to post data to the "data.sparkfun.com" service in order to test a basic Wifi data logger. I am using the AdaFruit CC3000 library for the sketch.
The problem is am having is that immediately after a power off and reset, the HTTP Get is successful. However, when the loop runs again, the post fails. Usually on the 2nd attempt. I have had a few times where it has looped 2-3 time before failing. But it always fails. If I reset the board with the push button or by disconnecting the serial monitor and reconnecting, it still fails to send the HTTP request.
I have checked my ram usage, and it doesn't appear to have any sort of leak in that regards. I have spent days looking online for similar issues, and can't seem to find anything related.
To make this all the more confusing, the board just seems to freeze, it doesn't give any sort of error on anything. And the freeze seems to happen at different places, nothing seems consistent.
Would someone mind checking my sketch code, seeing if there is anything glaring; maybe I have a bad board?
    #include <Adafruit_CC3000.h>
    #include <SPI.h>
    #include <avr/wdt.h>

    ////////////////////////////////////
    // CC3000 Shield Pins & Variables //
    ////////////////////////////////////
    // Don't change these unless you're using a breakout board.
    #define ADAFRUIT_CC3000_IRQ   2
    #define ADAFRUIT_CC3000_VBAT  7
    #define ADAFRUIT_CC3000_CS    10
    #define IP_ADDR_LEN     4   // Length of IP address in bytes

    #define SensorPin A0

    ////////////////////
    // WiFi Constants //
    ////////////////////
    #define WLAN_SSID "Hayes"
    #define WLAN_PASS "123456"
    #define WLAN_SECURITY WLAN_SEC_WPA2
    #define timeout 30000
    #define website "data.sparkfun.com"
    #define publicKey "MGg93JbM8LFJAQxG3jK0"
    #define privateKey "nz9M8WZVaXU7WXz4VnlX"
    #define NUM_FIELDS 1

    // Initialize the CC3000 objects (shield and client):
    Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,
                             ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);

    /////////////////
    // Phant Stuff //
    /////////////////
    const String fieldNames[1] = { "value" };
    String fieldData[1];
    uint32_t ip = 0;

    //////////////////////
    // Input Pins, Misc //
    //////////////////////

    void setup()
    {
      wdt_disable();
      Serial.flush();
      Serial.begin(115200);
      Serial.println(F("\nInitializing..."));
      if (!cc3000.begin())
      {
        Serial.println(F("Couldn't being()! Check your wiring?"));
        while (1);
      }

      //Connect to WiFi network
      Serial.print(F("Connecting to WiFi network... "));
      Serial.println(String(WLAN_SSID));
      cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY, 3);
      Serial.println(F("done!"));
      while (!cc3000.checkDHCP())
      {
        delay(1000);
      }
      Serial.print(F("data.sparkfun.com -> "));
      while (ip == 0)
      {
        if (!cc3000.getHostByName("data.sparkfun.com", &ip)) {
          Serial.println(F("Couldn't Resolve!"));
          while (1) {}
        }
        delay(1000);
      }
    }

    void loop()
    {
      cc3000.printIPdotsRev(ip);
      Serial.println(F(""));
      float moisture = analogRead(SensorPin);
      fieldData[0] = String(moisture);
      Serial.println("Sensor Reading: " + String(moisture));
      int t = millis();
      //wdt_enable(WDTO_8S);
      Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
      if (client.connected()&&
        ((millis() - t) < timeout))
      {
        Serial.println(F("Connection to Sparkfun data server."));
        Serial.print(F("Sending Request..."));
        client.print("GET /input/");
        client.print(publicKey);
        client.print("?private_key=");
        client.print(privateKey);
          client.print("&");
          client.print(fieldNames[0]);
          client.print("=");
          client.print(fieldData[0]);
        client.println(" HTTP/1.1");
        client.print("Host: ");
        client.println(website);
        client.println("Connection: close");
        client.println();
        Serial.println(F("HTTP command posted, getting response."));
      }
      else {
          Serial.println(F("Connection to website failed."));
        }

    //  while (client.connected())
    //  {
    //    while (client.available())
    //    {
    //      char c = client.read();
    //      Serial.print(c);
    //    }
    //  }
      client.close();
      Serial.println(F("Posting Data Complete"));
      //wdt_reset();
      //cc3000.disconnect();

      //reset watchdog and disable
      //wdt_reset();
      wdt_disable();

      delay(15000);
    }

Why do you have //cc3000.disconnect(); disabled? Without experience with your wifi board, it seems like this line could be important causing it to not reset, thus causing it to not totally disconnect from the client.

the cc3000.disconnect(); is used to disconnect from the AP. At this point, since it is plugged into constant power source, I assumed that I wouldn't want to disconnect from the AP, thus allowing my subsequent posts to the site to occur faster... by not having to reconnect to the Wifi AP again and again.


text:
Arduino Nano -- cannot download, no /dev/tty*** device
It appears to me that each Arduino has (should have?) a unique /dev/tty...USB... number assigned. Why this isn't explained anywhere (that I can find) is a mystery. When I plug my problem Nano into a USB port on my iMac no /dev/tty... for it appears. It used to work. Have I fried it? Can this be fixed?

Check in system monitor or whatever they call it for unknown devices - you may have lost the FTDI (or whatever) driver.

Did you select the 'Nano' on the Tools->Board dropdown menu?

Sure. I have successfully programed a Micro and 2 other Nanos.

This is probably a duplicate question and duplicate answer, but ...
Flip the board over, look at the bottom. If it says "FTDI" then this answer doesn't apply. But many cheap clones have moved to the CH340G chip for USB serial communication, it's a tenth of the cost with a tenth of the (unused) features.
You can find CH340/341 drivers from the manufacturer at WCH.CN or linked at the bottom of this post.
Or, skip the USB altogether and search for "ISP" on Tindie and grab a USBASP or TinyISP programmer.

My nano does not say FTDI on the bottom so I loaded the driver. Didn't work. I don't understand the Tindie ref.?

Do you at least get a power LED when you plug that device in? That should work independently. USBASP and TinyISP programmers (among other models) connect to the 2x3 pin header on the side opposite the USB connector and allow one to directly upload code, bypassing USB altogether.

Yes, the power light is on and the led labeled "L" on and off. If the 6 pins bypass USB then how would I access them from my iMac. BTW: I have 3 Arduinos that don't do the USB: old 1 Micro from Ada (FTDI, used to work, I must have fried it, still has power), 2 from Aliexpress @ $2.70 ea. (non-FTDI, poorly soldered pins). BTW: you might be interested in http://dicks-raspberry-pi.blogspot.com/ (my blog). Mostly Rpi but posts 66-68 about Aruino.


text:
uBlox Neo 6M GPS module not responding
I started recently working with a uBlox Neo 6M GPS module (data sheet http://www.u-blox.com/images/downloads/Product_Docs/NEO-6_DataSheet_%28GPS.G6-HW-09005%29.pdf). I connected it to an Arduino Uno as shown:
GPS  Arduino
VCC-- 3.3V
RX -- D11
TX -- D10
GND-- GND
I tried this example code from TinyGps++ (of course, changing the pins and the gpsbaud to 9600, which is the gps' default).
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 10, TXPin = 11;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup() {
  Serial.begin(115200);
  ss.begin(GPSBaud);
  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();
}

void loop() {
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();
  if (millis() > 5000 && gps.charsProcessed() < 10) {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo() {
  Serial.print(F("Location: "));
  if (gps.location.isValid()) {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid()) {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid()) {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  } else {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

However, I do not get the GPS LED to blink, as well as my Arduino's RX LED, so the module is not transmitting any data. This is the output from the code:
A simple demonstration of TinyGPS++ with an attached GPS module
    Testing TinyGPS++ library v. 0.92
    by Mikal Hart

    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00
    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00

Thanks!

Where did you get the gps from? Its possible the one you got was configured to use the uBlox binary protocol as default instead on NMEA

Another comment: I spent a while working with some of the u-blox LEA-6T gps modules, and they were REALLY intolerant of baud-rate mismatches, to the point where it wouldn't talk to my device speaking 115200 baud even through the baud rate was only ~2% off. I wound up specifically choosing a baud-rate that worked well with the local oscillator I had. I don't know if the NEO-6M modules are similar, but it could be a possibility.

The Neo 6M takes a bit of time to fix when first powered on. If your board is fitted with a small battery it will most probably be flat and will take an hour or two to charge up. It is there to provide charge to the EEPROM and the onboard RTC.
Also check that the leads on the battery are not shorting.
You do not get a valid data sentence out of the GPS until the RTC can sync time.
The Error message that you got from Mike Hart routine first says that there is not enough data to do a FIX and second the Date Time is not syncing.

I thought my GPS was faulty. Thank God I saw your answer and let my module stay ON for an hour... And guess what... It worked perfectly... The on board LED started blinking

After 2 days of troubleshooting I found the solution

Use 3.3 volt external supply
Use voltage dividers to make 3.3 volt compatible to module
go outside(open space)

That's it

Try to connect your GPS module with an FTDI cable directly to the Serial-Port of your computer (and read it with screen or any other terminal program). Once that works, proceed with the Arduino.
And check what your GPS-module not blinking does mean. Usually it says there is no 'fix', which means it does not see enough satellites. The output you showed would fit into that theory. Which would mean everything is ok, except your module is not seeing the sky...

Thanks! There was no actual problem, it was just that I was in a close space and had no patience ;)

1) Try outside or near the window.
because the signal may not reach inside a house.
2)Check the connection.
3) Print the number of satellites connection to know the device is connectied by
Serial.println(gps.satellites.value());

Good luck!!!


text:
Is it wise to use analog input pins to read digital buttons?
I am thinking about building a circuit that is literally going to take 11 of the 14 digital pins of an UNO to communicate with an SD card and an external EEPROM chip (EEPROM programmer).
Using 4 shift registers and the SD card, I will have 1 digital pin left.  Well, I'm also reserving pins 0/1 for serial communication.
Anyway, I need to read some external buttons and I have the 6 analog pins that I haven't touched.
I will only need about 4-5 push buttons in my design so they should fit nicely on A0+.
So, my question is, will I run into any issues doing this?  Or, are the analog inputs better left for true analog reading?
Thanks.

Possible duplicate: http://arduino.stackexchange.com/questions/4011/can-i-specify-that-analog-pins-be-used-for-digital-output

The Analog pins are essentially identical in functionality to digital pins when used as digital I/O.
If desired you could "be clever" and use an analog input in analog mode to read multiple keys using one pin. eg using 10k, 22k, 39k, 82k, 150k in series with 5 buttons from V+ to pin and a say 4k7 to ground would result in 5 voltages which were easily distinguished using an analog read. This is a very very old technique indeed and allows far more than 5 keys on one input pin. THere are limitations which can be discussed if required.
R1 ... R5 correspond to buttons 1...5
Vout = V+ x Rb / (Rb + Rbutton)
Example only
Rb = 39k
R1 = 10k
R2 = 22k
R3 = 39k
R4 = 82k
R5 = 150k
Gives

The % of V+ in column 2 when a button is pressed.
The voltage in column 3 with V+ = 5V

Delta-V is the difference between that key and the one below - very ample clearance.

Awesome answer.  Thanks!  BTW, I didn't even think about using the analog pins to read multiple buttons that way.  Thanks for the tip too.

Can this method be extended to detect multiple buttons pressed at the same time?

@LoganBlades Yes - within limits. If you think of button resistors as ~= injecting current into the lower resistor you'll see I have chosen values that are in an approximate binary ratio subject to std E12 values. ie I aimed at 10 20 40 80 160 and then took closest E12 value. So if you take the inverses it shows ABOUT how much they will pull a low value resistor up by - I say low value as that better approximates a current source. So contributions are in inverse R order of about 16 8 4 2 1 current units. So if you press B1 + B3 you get 20 current units, B3 + B5 = 3 etc. ...

... The 3CU of B3 + B5 lies between the 4 CU of B3 and the 2 CU of B4 so you need enough resolution to distinguish between them. If you used the resistors to control a "proper" current source and binary weight the resistors you get 2N^N levels for N buttons keys. So 8 buttons gives 256 levels AND with a 10 bit ADC vyou notionally have 2 bits between each level. That would almost certainly be tighter than you could easily manage in practice - you'd need 0.1% resistors and a 0.1% accurate current source. 6 buttons is probably doable. Easily experimented with using eg an Excel spreadsheet.

If you have no use for analog pins there is no problem. A5/A6 are used for I²C (on the Uno).


text:
Is Arduino IDE enough to program with C or C++?
I am using Arduino IDE to program my ATmegas with bootloaders. I can directly manipulate ports, use timers, interrupts, PWM pins and timers, etc. Everything is working.
But this question arises: Does the Arduino IDE differ from AVR Studio in terms of using C or C++ on an ATmega chip?
I know AVR Studio has some features or something. My question is not about that. My question is that I am coding everything, not using extra libraries, features etc.

In terms of the core language features, there's virtually no difference. In the background, the Arduino IDE and Atmel/AVR Studio both use GCC to compile the code.
GCC is an excellent toolset which supports all the core language features of C++. Admittedly, the version which currently comes with the Arduino IDE is a little old, so it doesn't support C++11 onwards. However, a lot of C++11 features are not very relevant or useful for microcontroller programming anyway (e.g. threading).
You're also likely to use the same standard library for both, which is AVR Libc. It provides pretty much all the standard C functionality that you're likely to use in an AVR project. It doesn't include the C++ stuff though, such as streams, containers, and algorithms. These tend to be very resource-hungry though, so are best avoided anyway.
The major difference is basically flexibility. Atmel/AVR Studio is designed to let you work on a wide range of projects and customize the build to suit very specific needs. You can also use alternative libraries with it more easily. In theory, the Arduino IDE can be modified in similar ways, but it's a major hassle because it provides no GUI to do it.
It's also important to note that the Arduino IDE does a number of non-standard things, such as re-organising declarations and including libraries in strange ways. It's designed to be more user-friendly, but often ends up just getting in the way. There are usually ways to work around those issues though.

I absolutely got the point. I got the answer I am looking for. Thank you.

It is unclear exactly what you are asking. The Arduino is different to most computers - it has NO OS (if you exclude the bootloader).
You can use a c/c++ compiler which translates your code to machine code. If you include libraries this may include machine code which someone else has compiled into a library.
You could write 100% of your code in assembler and produce exactly the same result.
Even in the good (bad?) old days of the 1970s before we had compilers on microprocessors it was common to have prewritten code (libraries) for common functions.
You haven't lived until you have written your own assembler (hand coded).

For my type of projects, assembly would be too complicated.

@milliways - I've written only parts of a hand coded assembler (never finished), BUT I started programming in machine language on a 6800 (6802 mostly). ie no assembler - write mnemonics, compile "in head", hand calculate relative branches, key in code from hand drawn listing with hex keypad (occasionally binary switches). Creed 7B baudot printer "after a while". I submit for your valued consideration that that qualifies as "having lived" in this context :-). No?. [As you might expect, I recently had my 1,000,000 th birthday].

1,000,000th birthday in binary isn't that old :)


text:
Can I program AVR Microcontrollers using Arduino Development board with AVR Studio?
I know and I can program any AVR microcontroller with Arduino IDE and Arduino Uno board. Can I use Arduino board with AVR Studio? Or I have to buy an AVR Development board?

You can use Atmel Studio to write code for the MCU(s) on the Arduino boards. If the IDE itself does not support uploading the code to the Arduino then it is still possible to use AVRDUDE or BOSSA to upload it via the command line.

Using Atmel Studio, could he program via ISP (SPI)? I have never tried it as I have a Dragon and STK500.

I'm sure he could. But the Arduino likely already has a perfectly good bootloader on it for serial uploading.

@IgnacioVazquez-Abrams Then what happens If wanted to upload code from Atmel Studio while Arduino has it's own bootloader loaded on the MCU? Does that matter?

@Zgrkpnr__: All the Arduino bootloader does is allow serial programming instead of requiring ISP. It does not affect the development environment in any other way.

@IgnacioVazquez-Abrams You are giving answers as If you read my mind.

There is an Arduino plugin available for AVR Studio, which allows you to upload sketches to an Arduino, just like you would with the Arduino IDE. I think this also enables you to upload plain C/C++ files created with the standard AVR tools.
Alternatively, if you have an AVR ISP programmer, you can use this to upload compiled C/C++ to the Arduino from AVR studio without needing the Arduino plugin.


text:
US-100 Ultrasound sensor doesn't work on Arduino mega 2560
Im using a Arduino Mega 2560, and I tried to connect a us-100 ultrasonic sensor for distance measurement.
I connected it as shown in the image
The code I used was:
const int trigger=6;
const int echo=7;
float distance;
void setup(){
Serial.begin(9600);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
}
void loop(){
// Trigger US-100 to start measurement
// Set up trigger
digitalWrite(trigger,LOW);
delayMicroseconds(5);
// Start Measurement
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
// Acquire and convert to mtrs
distance=pulseIn(echo,HIGH);
distance=distance*0.0001657;
// send result to UART
Serial.println(distance);
delay(50);
}

But It won't work, as in the only output i get is 0.00 cm as shown in the image
Can someone tell me if I'm doing something wrong(also, i tried putting two probes between the vcc and one of the gnd pins, and a resistance was shown.This should mean the sensor isn't broken.yes?)? this is my first time using arduino and I greatly appreciate help to fix this.

To get the result in cm, multiply distance only by 0.01657 ;)

Try sending the value of pulse in via serial to see if that is returning the right value.

People can answer your questions much more quickly if you add a direct link to the datasheet in your question.

This questions lacks the details needed to be answerable, and has been abandoned without any attempt to provide them for half a year, so should be closed as off topic.

I'm going to close this question as "unclear what you are asking". A link to the datasheet would help. I can't personally see from the photo what is connected to what. Feel free to edit the question with new information. Thanks for your understanding and cooperation!

Have you removed the "Serial Data Mode" shunt to put the device in "Pulse Width Mode"?
On the other hand, perhaps the "Serial Data Mode" would actually work better for your application?
Where I work, we have a coding style that strongly encourages
all "magic numbers" to be documented
with a link to the website it came from
or a reference to the book and page it came from.
Would something like this work for you?:
void loop(){
    // Trigger US-100 to start measurement
    // at least 50 us high, then set it low,
    // as recommended by
    // https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module
    digitalWrite(trigger,HIGH);
    delayMicroseconds(50);
    digitalWrite(trigger,LOW);
    // Acquire
    unsigned long echo_microseconds = pulseIn(echo,HIGH);
    // debugging
    serial.println( echo_microseconds );
    Serial.println(F(" microseconds"));
    // conversion factor from
    // https://www.bananarobotics.com/shop/US-100-Ultrasonic-Distance-Sensor-Module
    unsigned long distance_mm = echo_microseconds * 34 / 100 / 2;
    Serial.print(distance_mm);
    Serial.println(F(" mm"));
    delay(50);
}

It might be easier to use the Ping library as described at
Arduino-Info: UltraSonic Distance Measurement.
You might find the
Arduino Forum: Measuring Distances with Ultrasonic Sensors
thread educational.

I tried all the above ways you said. None of the works. :/ I tried both serial data mode and PWM.


text:
Unstable system when controlling power to serial peripheral devices and sleeping
In the process of trying to make a small system that will last a while on 4 AA batteries, I've reduced my Arduino project to a barebones system that when asleep draws a tiny amount of current from the batteries.
However, to achieve this, I found it would be necessary to cut power to the two attached peripheral devices (connected to an ATMega328P-PU). One of them is an I2C device, and the other is a serial device, and both are attached to the hardware serial/I2C pins as appropriate.
In terms of powering the peripherals, the bases of two transistors are connected to two of the digital pins, and power to them is controlled from code via these transistors. Both devices are 5V, and when the system is running the total current draw is around 200mA.
Basically this setup works, however I'm getting "random" system hanging and essentially an unreliable project. Sometimes when I power it up it will work as normal, but then hang and not sleep. Other times, it will sleep, but then freeze after waking or just get stuck during waking (which I can tell because the serial device powers up first and does nothing, but the I2C device remains off).
My best guess is the root of the cause is either something to do with the serial communication being interrupted by sleeping the MPU (I'm using the maximum power saving sleep, which is woken by an external interrupt on pin 2), or possibly some sort of power problem (sudden current draw from battery?) that occurs when the peripherals are powered on in code (though I don't know how I should test this).
So far, I've tried calling Serial.end() before sleeping the MPU, and Serial.being(9600) on waking, and have scattered delay(1000)s throughout to ensure everything has enough time to get running, but the problem still remains.
Does anyone have any pointers on things I could change/test, or an alternative approach I could take to make the same power savings?
EDIT: Some more details
The transitors used are TIP 120's. The connections are essentially an exact copy of the image here: https://ctheds.files.wordpress.com/2007/10/tip120.jpg, except the resistors used are 560 Ohms (just what I had to hand, no other reason, didn't think it would change anything).
The I2C peripheral is a 20x4 LCD (which I believe is HD44780 compliant). The serial device is an GT511C3 fingerprint sensor. I don't believe either of them have any automatic power saving features, though I haven't looked for such things in the documentation explicitly.
The exact code I use to call sleep is
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();

which I'm lead to believe is the lowest power mode, and aside from this problem works well for my system.

Please show us how you connected the peripherals with the transistors? Which transistors did you use? What peripherals do you use, as some have power saving features themselves? Also, please post the code where it hangs. Power spikes/dips seems like a possible explanation. You could use the watchdog timer to reset the arduino when it hangs, but that isn't really a fix for original problem.

What sleep mode do you use? In some recent experiments, I found out that ATmega USART (serial comm) was not compatible with ANY sleep mode except the IDLE mode.

Also you might consider replacing your transistors with MOSFETs, which shall reduce consumption further.

Does it work as intended if you remove the transistors, but use the sleep mode? I mean, maybe the sleepmode is the problem itself

Thank you all for your comments, I have updated the question with more details.
@Gerben I had considered the watchdog timer, but as you say it wouldn't help me as I would lose the state my program was in before it was reset.

@jfpoilpret I'm interested to hear more about your experiments. Do you mean serial will simply not work after sleep? Just to be clear, I am not using a serial interrupt to wake the MPU.

@AllanNørgaard The previous iteration of my project did exactly this. The MPU was put to sleep, but the peripherals were always on. The battery just didn't last long enough to be viable.

Make sure all output pins going to the peripherals are set to high, or you might damage them. Try adding a large capacitor to the power rail, and see if that helps. You probably want to disable the brownout detection during sleep (sleep_bod_disable()). (I haven't had problems with powerdown and serial communications.)

@Gerben Thanks for the suggestions. I already have a 10uF capacitor on the rails. I don't think I need to go bigger? It seems the chip I'm using doesn't have BOD sleep, since when I try to compile with it I'm told it's not defined. I've done a few more experiments and I'm "quite" sure that the serial device is causing the problem. I'm not sure if it helps to mention, but the library can be found here: http://goo.gl/jOemCc. By default the library uses SoftwareSerial, which I thought was the problem, so I modified it to use HW serial. Have you needed to call Serial.end() to sleep in the past?

I didn't call Serial.end(), but I only used it to send data to my PC, never to receive. The sleep_bod_disable() Macro isn't available in the Arduino IDE for some reason, but you can probably find the actual code somewhere (or use this one). I'd try a bigger cap, if you have one, as it's very little effort, and might just fix it. Where did you put the transistors? On the 5v or on the GND going to the fingerprint reader.

@Gerben Thanks, I'll give the bigger capacitor a try. I'm using the transistor to switch the sensors ground wire, the 5V is connected to the 5V rail. I assume you were using hardware serial in your project as opposed to a software serial port?

If you switch the GND, you have to make sure all the pins going into the module are also 5V or (high impedance) inputs. Or current could flow from the 5V rail, through the module, to the GND on the signal wire, possibly damaging the module, and even the arduino. I'm not saying that's the case here, as it depends on how the module/IC is build. Most datasheet tell that the input voltage should be more that a few tenths of a volt below ground. If ground is disconnected/floating, a low input signal will be like -5V. PS yes, I used hardware serial.

Be aware that running the AVR straight from the battery works, but might require to speed down the clock (16MHz requires a minimum of 3.7v according to the spec) I had a couple of similar problems in my project and 'solved' them with a rather brutal approach (https://holadimake.wordpress.com/2015/01/24/building-a-cellular-tracker-part3a-circumventing-unreliable-watchdog-with-external-555-timer/).

I see, do you mean use a 555 timer to act as a slower, external clock? My power source is 4.8V, so I would have thought that would be good enough to mean that an external clock is not necessary?

I'd suspect the clock rate too. Plus make sure you don't run out of memory. Most common causes for freezing code is low memory.

Using an NPN transistor to control power to a peripheral may be problematic.
An NPN transitor would presumably be used as a low-side switch interrupting the peripheral's ground line, however, even when turned on this will have a non-trivial voltage drop.
Most logic level definitions are asymmetric, ie, the maximimum legal voltage for a logic "0" is relatively low. If you insert the voltage drop of a bipolar transistor into a peripheral's ground line, then it may be borderline unable to drive a fully legal '0' to the ATmega, which is reference to the lower true ground and would see the peripheral's ground difference added to its output voltage.
A better approach would be to use either a high-side switch (as there is typically more room between the minimum legal '1' and the supply) or else to use an FET switch which would have a much lower voltage drop.
Also keep in mind that most IC's are not specified to tolerate lasting I/O voltages much outside of the range of their power suppliers, and in fact their protection diodes may mean that application of such voltages effectively powers them through the I/O pin.  So before turning off power to a peripheral, you probably want the ATmega software to assert all shared I/O lines towards the side of the peripheral supply which is not being disconnected, ie, for a low side switch drive everything high and for a high side switch drive everything low.
Finally, the process of power cycling could potentially confuse peripheral interface engines and it is possible that some error flags set in this process might never be cleared.  So you may want to clear the flags of and generally re-initialize your USART, I2C, etc on resume.

Sadly, this is a long dead project, and the bits to put it back together are a bit scattered... Nevertheless, I am most interested by your take on things. These are problems I hadn't considered (or even realised existed, coming from a largely software background). Thanks very much! I hope that if I get around to trying something like this again in the future it will succeed!

I hear great things about the cosa core for Arduino. It's a fantastic alternative Arduino core and exposes the power management capabilities of the micro-controller that are not exposed by the standard Arduino core.
You might find it is too different for your experience but then again it is excellent and worth a look.
https://github.com/mikaelpatel/Cosa


text:
Pressure Sensor and Arduino
I am currently working on reading pressure values using a tekscan a201 sensor. The sensors I have are limited to 25lbs.
My plan is to use eight on these sensors of them with a arduino Mega. Since I am measuring the resistance, I am thinking of making a 8 similar voltage divider circuits and grabbing the voltage reading via arduinos analog pins.
At the moment, I am not sure how to convert these readings to engineering units. Any ideas?

I have not previously met the Flexscan sensors but from the datasheet it appears that there are versions of the A201 rated at 100 pounds are you committed to the 25 lbf version?
A201 datasheet here
Here is a 15 page user manual thatexplains how to produce a voltage output using a single opamp per sensor - bottom of page 9.
Many idea starters here

What is your application and why do you wish to use these sensors. These seem to be a low accuracy alternative to eg load cells and seem to be expensive for what you get. If you need 8 for your task a loadcell based solution may e cheaper.

Thanks for responding.
I am helping out a few friends who are planning to use these sensors to test out compression wear for women. They already brought the tekscan sensors so I am kind of stuck with them.

You are right, they don't seem to be very accurate.

I decided go with the voltage divider approach as it seemed simple enough. The sensors themselves needed to be calibrated, which took me a while as I didn't have the required weights.
After the calibration, I used the line of best fit approach to find an equation that translated voltage to force.


text:
Programming an Array of ATTiny
I am designing a board for my electronics project and i am using a number of ATTiny85 for it. The ATTiny's will be SMD so i will not be able to remove them for programming.
Moreover all of the pins of my uCs will be used for connections (apart from reset).
Is it possible in this case to achieve that, any ideas and suggestions are welcome
EDIT: Well, Vcc and Ground will be common, i will be using an external oscillator for all of them, the reset pin will be free, the other three pins will be used for gpio communication between the attinys.
I am connecting about 10 attiny in a daisy chain kind of thing

Lots more detail needed. You may be in substantial 'trouble' here and may not. How many uCs? What state are the MOSI/MISO/SCK in on other processors when you program one of the,? Are they "hard connected (wire) and do they have to be? - eg could you add resistors between uCs so you can drive a MISO or MOSI or ... pin high or low ehen it is held in a fixed state on other boards? May it be possible to have an "enter programming" mode where all processors explicitly deload all commoned pins as much as possible during programming of 1 of N. | If you reset ALL uC's and SCK is able to be ...

... clamped low at all but one IC then you could program one only most signals applied to all except SCK which is low for all but the target uC. You MAY be able t do similaar;y and clamp MISO low on all but one but that is getting dangerous as all will clock in the all-0 MISO state. This probably does no harm but would need to be checked. ||| It will be possible to do something which meets your need with minimal disturbance of the design BUT we need much better details in order to be able to interact with you usefully. [I was in Mumbai a few days last March. I'd like to visit longer someday.]

See table 3 in AVR910 ICSP App Note - resetting all uCs and clamping (or pulling) MOSI high or low on all except target uC should safely isolate all others from programming action. So the ability to isolate MOSI as required on all except target uC would address your requirement. Loading can still be an issue.

@RussellMcMahon I think you have given lots of relevent info here and you should form it up into an answer. As far the the board designing is concerned the entire design is upto me so i can add resisters wherever required as long as it does not cause drop in high and low levels. As far as design is concerned one of the three pins left (MISO MOSI and SCK), one will be common to all uCs (10 Attiny85 that is) and others will form daisy chain. My concern is that all  of them will not be input (one input from previous and one output to next. As far as driving is concerned i am not worried )

but as you pointed out having another input on same line is an issue. I am willing to add other resistors, capacitors, but adding any other IC will be a problem. It would be highly preferable to not have any jumpers or switches of the kind because we are trying to make the circuit so that any novice can program it. I would love if you want to get into electrical design concepts (me studying EE ofcourse). Do visit college if you come to mumbai again, you may find pretty interesting stuff here :)

As long as whatever you're connecting the MISO, MOSI, and SCK pins to doesn't mind being driven externally, you can still program the ATTiny in-circuit - just break out those pins with reset to a standard 6 pin header and program them that way.
If one or more of those pins can't be driven externally (eg, because they're connected to another device that drives them and has no output disable), you'll need to add a tristate buffer IC between the MCU and the other device, or some jumpers you can remove when you want to program them.

The pins i am connecting them are MISO, MOSI and SCK of other ATTiny, so will putting other attiny in reset work?? i do not want to add a tristate buffer IC :P

Sure - as long as you separate the reset pin for each MCU, it doesn't matter if they share the SPI pins; only the one the programmer holds in reset will get programmed.

@Rishabh Note that your query re reset and Nick's answer reflected opposite understandings between you of the state of reset during programming.

@Rishabh - Here is Atmel's ICSP programming guide. http://www.atmel.com/images/doc0943.pdf.|It notes "To enter and stay in Serial Programming mode, the AVR microcontroller reset line has to be kept
active (low). Also, to perform a Chip Erase, the Reset has to be pulsed to end the Chip Erase
cycle. To ease the programming task, it is preferred to let the programmer take control of the target
microcontroller reset line to automate this process using a fourth control line (Reset)." ie the device being programmed has reset asserted and the ones not being programmed are NOT reset. ...

@Rishabh You need to look at the loads provided on MISO MOSI and SCK by the other processors when they are not being programmed. IF a given line is an input all MAY be well. If it is an output you may have problems. Even inputs plus enough cabling etc plus a low drive capability programmer may cause problems. If you want assistance with the electrical aspects here you need to provide a more detailed description. How to connect them may be mainly Arduino related but you are getting into the lectrical design aspects. (I'll play :-) ).

@RussellMcMahon We're not in the lands of TTL anymore! A programmer with 5mA output drive capability is going to be absolutely up to the task of driving a few CMOS inputs. Good point RE reset and making sure the others aren't driving, though.

Well you need access to pins 0 & 1 to program them, so you either do it off-board, or design in a way to access them - perhaps a PCB hole you can wire to temporarily, or a link you can fit/remove that changes the connection.
You will probably need to program them before the rest of the board gets filled up?
You havn't said what you will be connecting to these pins nor how many is an "array" which kind of limits how specific we can be here!

Sorry, but this is not a meaningful answer.

Lookin' forward to your answer then... I don't quite see why you feel that way though, you DO need to access those pins & if you're going to wire up an array of linked processors, you have a problem - hence the question. It is short on detail to provide a terribly definitive reply though.

Quite simply, you have not addressed the question actually asked.  Also, your one specific statement about pins is not accurate for the ISP programming that is the topic.  When a question is short on detail, start with comments - not a change of topic "answer".


text:
Chain of, or one big if sentence
(This might be more of a common C question)
I want to test several conditions in an IF-sentence
if(variable) {            // fastest check
  if(register) {          // a bit slower
    if(read_peripheral) { // very slow check
      // [do something]
    }
  }
}

It seems obvious that I want to start with the fastest check, and move on to the slower ones afterwards, potentially avoiding to check them if the above was false.
Now since I need to check quite a few conditions, I'd like to know if the following is the same, or if all conditions will be evaluated prior to making a decision?
if(variable && register && read_peripheral) {
  // [do something]
}

Putting them all in a single condition like that is absolutely fine. C/C++ uses "short circuit evaluation" which means it will stop as soon as it's determined the outcome. If everything is combined using logical AND operators (&&) then that means it will stop as soon as one of them evaluates to false.
For example:
 if (blah() && foo()) { ... }

If blah() returns false, it will never call foo() at all because it already knows the overall outcome is false.
The reverse happens with the logical OR operator (||):
 if (blah() || foo()) { ... }

If blah() returns true in this case, it won't call foo(). That's because it already knows the overall outcome is true.


text:
Can't program Arduino via Bluetooth (HC-06) with a Mac
I bought a HC-06 Module for my Arduino Uno the other day, yesterday it arrived and I'm having trouble using it with the Arduino IDE.
I set it up, connecting 5V, GND and RX/TX crossed. After a bit of searching, it shows up on the bluetooth settings on the macbook. When I click "connect", it fails, after I click "Options", then set the Pin to 1234 it says "Connected". The LED on the HC-06 is still blinking (which is OK I guess, since I'm not yet communicating).
I have a Sketch running on the Uno that prints out some text. When I open the serial monitor (after connecting like above) it works, displaying the values I expect. However, after closing the serial monitor the HC-06 changes to "not connected" on the mac.
Also, if I try to upload code via the Arduino IDE it states: avrdude: ser_open(): can't open device "/dev/tty.HC-06-DevB": Resource busy
ioctl("TIOCMGET"): Inappropriate ioctl for device or throws a processing.app.SerialException: Fehler beim Öffnen des seriellen Ports "/dev/tty.HC-06-DevB". (German for "Error while opening Serial Port "/dev...." ").
Do I have to configure the HC-06 or the Arduino IDE in any way to make this work, and, if so, how can I do that?
Edit:
I've also connected TX and RX uncrossed, though that alone doesn't solve the problem.
Thanks in advance for your Support!

not enough rep to vote up Roldofo's comment, but his suggestion to rename to "ArduinoBT01" seem to make all the difference!

The on-board USB-to-serial pulses the reset line to start the bootloader. HC-0x don't have the extra signal available that USB uses for that so you'll have to manually reset the Arduino just as - or very slightly after - you click to start the upload on your Mac; you may need to experiment to get the timing right, but once you know it, it isn't hard to do. Keep Rx & Tx crossed as you do for Bluetooth terminal communication. And even with all that, I've never achieved anything like USB upload speeds (baud rate for baud rate) using Bluetooth.
Update:
In brief, it could be timing, baud-rate, or pairing.
I find it easy to get the timing: hold reset / click (and let go) the upload button / release reset. It doesn't need to be so fast that it's a challenge to coordinate but do it faster than counting seconds.
Your HC-06's baud rate will have to match the baud-rate your boot-loader expects. It looks like Uno's bootloader's use 19200 baud (and there are some way older ones that used 9600). My bare, pre-programmed chips' boot-loaders from Adafruit.com use 57600 baud. Your preferences.txt file should contain a line like 'atmega328o.upload.speed=115200'; assuming you're able to upload via USB, then use this baud rate for the HC-06. (The path to your preferences file is displayed on the Arduino IDE's preferences dialog.)
The 'Resource busy' message sounds like your Mac isn't paired with your HC-06. In the MacOS Bluetooth System Preferences pane, pair the Mac with the HC-06 and be sure HC-06's LED is on steady (not blinking).

So it's a timing Problem? I tried countless times to reset the arduino while I uploaded, but I never succeeded. Is there a way to reset the arduino automatically? And does the baud rate of the HC-06 matter?

Did you also try it with Tx Rx crossed?
And the baudrate of both devices should be the same.

In bootloader code baud rate is set 19200: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/bootloaders/atmega/ATmegaBOOT_168.c

I'm having similar problems: http://forum.arduino.cc/index.php?topic=314356 Any thoughts

If I remember correctly, you do not want to cross TX and RX.
Usually, you cross TX/RX because you are looking at it from the opposite side - the PC's TX is the Arduino's RX and vice-versa.
However, in the case of BlueTooth, the HC-06 has the same perspective as the Arduino - TX (transmit) is TX on the HC-06, since that is what the HC-06 transmits (over Bluetooth).
Also, if you are connect your Arduino via USB, the TX & RX are also connected via USB; I don't know if this would cause cross-talk. It shouldn't (so long as you don't send to your Arduino using Bluetooth AND USB at the same time), but it may. Also, as you're programming the Arduino using Bluetooth, you may get the Arduino's responses coming back to you via Bluetooth.
ADDITIONAL:
Go read http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader - this is all about the bootloader.
It seems from that that current bootloaders run at 19200, some older ones run at 9600. There are commands to program the speed on HC-06 - instructions can be found at http://www.instructables.com/id/AT-command-mode-of-HC-05-Bluetooth-module/ (this covers the hc-06 too).
Based on the bootloader tutorial, I think you have "less than a second" (only two specific boards are mentioned, so this is a best guess; I am amazed that it is this long, I expected a few milliseconds). If you have a USBISP, you could compile and upload a new firmware, with settings more to your liking - this is outside the scope of this article.
Another option is to create a completely separate uploader - an AtTiny could do it. Connect the AtTiny to the serial port, and then get the AtTiny to reset and program the board, or even program it via ICSP. This is a lot of work, and also outside the scope of this article.

Yeah, makes sense. Thank you! Unfortunately, it doesn't solve the problem if I connect the cables uncrossed. I've updated the question to reflect this.

Regarding the ability to upload, that is correct - you won't be able to upload code via Bluetooth. In addition to providing a serial connection, the USB connection does something extra (hold reset, I think), when you upload via serial-over-usb.

So it's not possible at all to upload code via Bluetooth? That's bad..

Well, if this is true, you can try to hold reset while uploading over serial?

You can also implement software reset: f.e. sending 'secret reset command' and searching is in input stream. If found - reset

After dealing with the problem for several hours I unexpectedly solve the problem.
The HC-06's LED keep blinking after I entered the "1234" code. In my case (I'm using Windows 10), the HC-06 status changed to "connected" for few seconds and then changed to "Paired". Once I opened the correct COM port to receive data from the HC-06 to my PC computer, the LED changed to solid ON. Then I was able to catch data from my Arduino UNO. As soon as I closed the COM port in my PC (I used CoolTerm), the LED changed to blinking back again. The COM port I used to receive the data was the one indicated with direction "Outgoing" in the PC's Bluetooth settings. So, I was expecting the HC-06 to behave as my Bluetooth speakers or my Bluetooth headphones: Always connected. I was wrong and it cost me several hours of testing.
In my firsts tests I focused opening the COM port with direction "Incoming". Nothing happened here and I lost a lot of time. I tested my wiring between the arduino and the HT-06 module by changing the device name from "HC-06" to "ArduinoBT01" and it worked.
This is the sketch I used to receive data form the Arduino via Bluetooth:

This is the CoolTerm's window capture:

Mysteriously, the CoolTerm speed setting is 14400bps but the speed in the device manager for COM34 is 9600bps. After triying opening many times the COM34 port with 9600bps I got this error in CoolTerm:
"An error occurred while attempting to open the port".
"1168: Error 1168"
So, it only works with 14400 bps. Crazy!!
I hope this helps.
Sorry for bugs in my English.


text:
What are the environmental requirements of an Arduino?
I'd like to use an Arduino Yún in a somewhat outdoor environment (in a metal box on a truck).  I think I've seen that the temperature requirements of the Uno are -40 °C to +85 °C, but I can't find that information about the Yún.  It would be nice to know where to find information about the temperature and humidity safe working requirements for every Arduino model.

The AtMega32u4 (the chip that drives the Arduino Yun) has an operating requirement of -40 to +85, so if you go outside that range, you will definitely void warranty (which is not to say it will break, of course!). See datasheet at http://www.atmel.com/devices/atmega32u4.aspx
A datasheet for the AR9331 seems to say that it only works down to 0°C ( http://www.eeboard.com/wp-content/uploads/downloads/2013/08/AR9331.pdf page 305, "Commercial Case Temperature") - this seems awfully high for a minimum temperature.
While that does not mean that, inside that range, you are safe, I would GUESS that you probably are - I would guess that the AtMega32u4 or AR9331 is going to be the most delicate part in there.
Of course, to get a definitive answer, you (or someone) would have to check the specs on each part.

+1 Useful albeit incomplete aswer. You are unlikely to void warranty on temperature excursion alone. I do not know why anyone would downvote this.

That's only for the chip itself. Since the chip might have a different expansion coefficients as the PCB, the soldered connection might tear/crack over time. Same goes for all the other components on the Yun's board.

@Gerben. Indeed - but if one component is specified at  eg -40 to +85 and another at eg 0 -125 you can be confident [tm] that the overall figures is not outside 0 - 85 - unless extra work and specific design renders it otherwise. .


text:
Adafruit CC3000 jumper pads
if I solder the jumper pads on the adafruit cc3000 for use with the Arduino Mega will it still work fine with the Uno?

+1 Looks like there is a phantom down-voter doing the rounds

What specific pads are you talking about? There seem to be some on the back of the module but those seem to be there for only testing.

@seb - did this meet your need?

I know this is a bit late, but is this question referring to the solder points for the ICSP pins on the full CC3000 board (not breakout)? If so then it will work fine with both, but then you're using two sets of pins for the same thing. Annoying design.

This module is designed to be "plug in and go" without access to anything except the connector pads at the board edge. While there are a number of pads on the face of the board these are for "experts only" access and are unneeded for normal operation.
The only soldering required should be the addition of a 9 pin row of pins to allow the CC3000 module to be plugged into a solderless breadboard or a socket. If this is all you do then the module will work directly and interchangeably with  Arduino Uno, Leonardo/Micro & Mega. These are the only Arduino versions that a full library is available for so far. ADAFruit promise more versions will be supported "sometime".
Additional information is available from
WIRELESS / WIFI / ADAFRUIT HUZZAH CC3000 WIFI BREAKOUT WITH ONBOARD ANTENNA
Solder on connector and go ...
Larger version of photo here makes pin use clear - + see link above

Example use weather station
Low power use tutorial
Example use wireless lamp
Library


text:
I am looking for the source and/or proper definition for the int() function
I am looking for the source and/or proper definition for the int() function.
I have searched through the source in Arduino.app, without much success.
The reference gives a terse explanation
int(x)
 x: a value of any type
 Converts a value to the int data type

Passing 1, '1' or 49 returns the int 1. I haven't tested other types.
This seems to be an Arduino specific function - it doesn't seem to be in any c/c++ library.

int(x) is not a function but another way to perform an explicit cast of x to an int. It is part of the C++ language itself, that is why you could not find it in a library.
This is not Arduino-specific.
In C and C++ you can cast a value to an int by doing this:
int y = (int) x;

C++ has extended this notation by allowing to do it this way, which is equivalent:
int y = int(x);

You can find this in more details in C++ language reference.

to clear things i think add long x; above int y = int(x); in my opinion this would be better?

Thanks. I could not find this in any of my (admittedly old) c++ books, or in Xcode documentation.


text:
What is Vin for the EthernetPOE board?
I am working on a project that needs to drive a relay board. I'm looking at the ETHERNET board with PoE and according to the documentation here (http://arduino.cc/en/Main/ArduinoBoardEthernet) the output of the PoE module is 9V.
Is that the voltage to expect out of the Vin pin?
The Relay board that I want to use (http://numato.com/downloads/dl/file/id/29/product/47/user_manual.pdf) specifies that it wants a 7-12V power supply.
I want to confirm that this is the case so I can use the voltage out of the PoE and I don't need to add a separate DC power supply to this system.

I wouldn't expect you to take any power from V-in-, but it actually seems like you can!
If you take a look at the schematic for the Rev.3 Arduino Ethernet, you can see the power rails from Ethernet is connected to Vin. (V1+, V1-, V2+, V2- --> Vin in the leftmost part of the schematic)

Thanks! I actually just received the boards and measured it. I got 10V on Vin and the Numato board looks like a shield that shares Vin through the bottom pins. However with the POE module the shield doesn't exactly fit, so I'm just running the wires from Vin to the Numato Vin pin.

Your question is a little confusing, so let me give you a couple pieces of information.
First things first - the VIn pin on the Arduino is strictly for power going to the Arduino board, you shouldn't be drawing power from this pin. The documentation in the link you sent is a little misleading on this - it's basically saying 9v is coming OUT of the PoE module, and going IN to the VIn on the Arduino itself. If you wanted to tap into this 9v power, you should connect to the PoE module VOut instead.
PoE by default can deliver 37-57 volts or 42-57 volts, depending on what type of PoE you're using (which 802.3 specification). Wikipedia has a good overview of this information.
That being said, the Arduino Ethernet board you're using can't handle this voltage by itself - unless these boards have changed, they require an additional PoE module, which is basically just a DC-to-DC buck converter that will convert the high PoE voltage down to 9v or 12v. At this point, the Arduino's built-in converter can consume that 9 or 12v and distribute it at 5v across the board.
Now, to your problem - you want to power a relay that requires 7-12v. You could theoretically connect the relay to the VOut of the PoE module, giving you 12v. However, if the relay draws too much power for too long, you will either get brownouts (and your Arduino will restart) or potentially damage the Arduino board. Unless the relay draws a lot of current or is being powered for extended periods, you should be fine. If you want to be more thorough, you could put a large capacitor between your PoE module and the relay.
You should NOT try to connect the relay directly to the PoE VOut, as the voltage will be far too high.

I think the PoE is not following 802.* standards. "the output of the PoE module is 9V."


text:
Issue with PWM output pin
I'm just starting off with using the Arduino and was learning about PWM
(http://arduino.cc/en/Tutorial/PWM).
Below is what my circuit looks like.

Below is the very simple code.
const int pinNine = 9;    // LED connected to digital pin 9

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  // set the digital pins as outputs
  pinMode(pinNine,OUTPUT);
}

void loop() {
  analogWrite(pinNine, 0);
}

I was expecting my LED to not be lighted as its a 0% duty cycle. I even change the pinNine outputValue to (64, 127, etc) but for some reason the LED is always lighted. Any ideas?

Loks correct, alas. Try another pin to see if it changes. Try digital write on / off to see that port behaves as expected. Bad port pih possible. What pin is serial on?

Check that the ground (-) rail on the breadboard is definitely going to ground on the Arduino. If it's going to +5v instead, and if your LED is the wrong way round, you could end up with it being lit all the time. (Pin 9 would basically be acting as ground.)

See my updated answer. Your code runs as expected on a Nano. Problem is probably hardware related.

Where does that red wire go to? i.e. Is the other side of the led connected to 5V by any chance? Try running the Fade example sketch (File=>Examples=>01.Basic=>Fade).

Ok, it seems my understanding of the PWM was wrong. I tried the circuit and code from here (http://arduino.cc/en/Tutorial/Fade) and it worked as expected (fade in and out).
Actually when i wrote my original code i was expecting the LED to blink. So, as i got closer to 255 i was expecting it to spend more time being 'lit', as compared to 0 where it should spend less time being 'lit'.

I even change the pinNine outputValue to (64, 127, etc) but for some
  reason the LED is always lighted.

It being lighted makes sense. What i missed out was it being dimmer when the value was lower.
Thanks for all your help..

Added at top:
Your code runs correctly on a $US3 Arduino Nano :-)
It seems extremely likely that you have a hardware problem of some sort.
If you have a voltmeter you can try these easy checks.
I carried these out to be sure that I got what was expected and the results are as you would expect them to me. Use a meter set to DC Volts - typical common meter circuitry averages the PWM well.

Remove LED etc connection to pin 9.
Measure the voltage from the 5V pin to ground. If powered from USB this will usually be slightly below 5V.

Run your code with the analogWrite set to 128 ie
analogWrite(pinNine, 128);

Measure the voltage on pin 9 relative to ground. It should be close tohalf the voltage on the 5V pin in 1. above. This is because the analogWrite value is controlled by PWM with values from 0 to 255. 128/255 ~= 50% so output is 50% of Vref = 5V by default. in a 5V system.

Set analogWrite to
 analogWrite(pinNine, 25);

The voltage on pin9 should be about 10% of the voltage on the 5V pin.

IF you get approximately the voltages shown in 3. and 5. your code is working OK and your hardware is OK.  If not then 'summat aglae'.
Try another analog pin.
Check that the red wire to the LED goes to UNO ground.
The voltmeter is a surer way of checking that the LED is as you can see actual numeric values that result.

OLDER:
It always helps greatly if you show PIN IDs on photos so people can be confident re what you have done.
If you view the whole UNO-R2-R3 connector with numbering it is obvious that the important pinouts are the same.
If however you view part of the connector with no numbering/ pin names shown,  then on the R3 there are additional pins on the ARef end of the connector which make comparisons'more difficult).
You APPEAR to have an Arduino UNO R3
It would help if you gave actual model and weblink in future "just in case it matters". .
You appear to have connected to pin 9  (as you intended to)
Pin 9 has PWM capability, as required.
It seems that your code should work.
Thusly

IF the red wire connects to ground the circuit seems electrically correct.
Does it?
Code LOOKS OK.
Try digital write on / off on pin 9 to see if LED changes and that the port behaves as expected. A bad port pin is possible.
What pin is serial on?
Try another pin with PWM capability to see if it changes.

ARDUINO UNO R3 from UNO home page
The connector pinouts vary widely between models of UNO.

Did they change pinout for UNO between versions? I'm pretty sure he wired it correctly. Edit: You can see from the reset button on his picture that it is Rev.3.

@Allan Look at the page referenced to see the differences. | I imagine that a dyed in the wool Arduino aficionado can tell not only the version but which corner of the vineyard it was grown in and how long it was left in the cask to mature. BUT when asking question and YOU have the information to hand it makes sense all round to tell as much of what you know that is relevant so question answerers can avoid duplicating the 'research'.

I agree completely that it should be noted when possible. OP probably didn't realise this would come in handy (I don't even own an UNO..:) I don't see anywhere in your link that the pinout has changed. They all feature the same chip, having PWM on 3,5,6,9,10,11. My old Duemillanove is the same :)

@AllanNørgaard - loose terminology on my part - I meant the connector pinout or functionality. In his photo you cannot see the module's labelling  - which can be seen on the photos I have added. He has connected it correctly and on my $US3 UNO the code runs as expected. He has some sort of hardware issue. I'm about to update my answer.

@Russell McMahon . Thank you. I will remember to show PIN IDs and actual model next time i post. Maybe a 'top' view of the circuit is most ideal.

Flat side of LED is -. This means that your white wire is on - side and your red wire on + side. Therefore your power rail connection is reversed... and therefore your LED is ON when you send 0 on PWM. By the way, you will set the LED OFF by writing 255 on PWM.
Solution: connect power rails correctly and everything will be back to normal.

Maybe. H did say "... I even change the pinNine outputValue to (64, 127, etc)  ...". So that depends on the range of values of "etc". At 5V you'd expect ~~~~ I=V/R = (5-3)/220 =~ 9 mA and at 2.5V you'd expect close to 0 mA. As he said he's tried PWM level 128 at ~= 2.5V you'd expect the LED to change very substantially. |"Flat side"? - I need to upgrade my (old) eyes :-).

Yes, I saw what he wrote. But it may be difficult to see the intensity change between 50% and 100% as our eyes are not linear, mostly for a bright light dot. He didn't write that he tried 255. Concerning the flat side, this is what I (old eyes too) see on the left of the LED on the picture (not very distinct I must admit).

You might be right. No certainty until he answer questions. I too asked about polarity of feed. | BUT it seems likely he'd notice at full and half voltages, from 0 to 128 the voltage halves but the LED meeds a minimum Vf to operate so brightness will be way down. |An InGaAlP green LED may gave Vf in the 1.7V - low 2.xV range and an InGaN green Led may be 2.7V up. Even at 1.7V and 5V drive I~~~= (5-1.7)/220 =~ 15 mA and at 2.5V ~~~= 4 mA. That's a very low voltage green LED and for higher Vfs the ratio is even larger. When looking for changes anything over 2:1 is extremely noticeable.

@RussellMcMahon. As he is not filtering the output, he will never generate 2.5 V, so the average current should be linear with the code. What is not linear is our perception of brightness. But according to his answer below, the issue was more fundamental and now things are solved.

yes/maybe/no/ ... :-). I build LED lights - that does not make me automatically right :-) but I am experienced therewith. . Arduino PWM is (I read) 490 Hz so yes, minimal filtering with stray capacitance. | Eye and LED responses combined are close enough to linear with these levels of current. At 2:1 most people can distinguish between two sources viewed one at a time. When viewed simultaneously a difference of 1.5:1 is typically visible. For adjacent wall washing > 20% difference can be seen by average user.

I have a few things you could try:

Remove pinMode(pinNine, OUTPUT), this is only used for digitalWrite(), the PWM controller might be affected by this.
Did you select the correct Arduino Chip in the IDE? Arduino maps pin 9 to a hardware pin (PB1 for UNO), which is not consistent between different boards
Try inserting a delay(100) after analogWrite(...). I'm not sure if the analogWrite call restarts the PWM cycle, resulting in very fast switching that might be seen as 'always on'

Other than that, your sketch seems to be correct. I assume the black wire in the breadboard is wired to Ground, correct?


text:
Tile NeoPixel NeoMatrix 8x8
As a programmer I am new and lack some knowledge in electronic and I will appreciate the help.
I wish to connect 3 Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix (https://www.adafruit.com/products/1487) can some one please provide me a scheme how to connect/tile 3 these NeoMatrix 8x8 to one Arduino Uno.
Thanks a lot

To add to both existing answers.  Memory ends up being your problem because each pixel needs 3 bytes for it's color value.  I would highly recommend that you read all of adafruits info for that product AND their uber guide, When you're finished you will understand (I did anyway).  One more thing adafruit site has conflicting info, they DO now have libraries for this type of LED (WS2811/ws2812) for the rasperberry pi, the info in Russell McMahon's answer is out of date, but it's because so is adafruit's page--elsewhere adfruit does have libraries for the pi

On the page that you cite they say
If, say, you need MORE blinky, you can chain these together.

For the second shield, connect the DIN connection to the first panel's DOUT.
Also connect a ground pin together
and power with 5V.
There you go!

You can chain as many as you'd like although after 4 or more panels you may run low on RAM if you're using an UNO. Watch your power usage too, you may need a 5V 10A power supply for so many of these!

Related:
They also say:

There is a single data line with a very timing-specific protocol. Since the protocol is very sensitive to timing, it requires a real-time microconroller such as an AVR, Arduino, PIC, mbed, etc. It cannot be used with a Linux-based microcomputer or interpreted microcontroller such as the netduino or Basic Stamp.
Our wonderfully-written Neopixel library for Arduino supports these pixels! As it requires hand-tuned assembly it is only for AVR cores but others may have ported this chip driver code so please google around.
An 8MHz or faster processor is required.

Hi, Thanks. Could you please provide me a scheme of how to connect them.

On the products page, they link to the Neopixel Uberguide, which should really contain what you need :-)
The good thing about the NeoPixels is that they can be chained, since each pixel is supplied with VCC, GND, Data in and Data out. Data out of LED1 will be data in for LED2, and afaik you can make infinitely long chains this way

I found the http://fastled.io/ libary to be a useful and well documented (https://github.com/FastLED/FastLED/wiki/Overview) alternative to Adafruit's NeoPixel library.
FastLED has some clever compression of palettes, and many other nice features that might save you valuable memory when using many neopixels.


text:
Getting sensor data wirelessly from arduino to PC
I am working on a project that involves sending motion sensing data wirelessly from an arduino to computer. Sensor readings have to be transmitted continuously (say every mili second). I am not sure if Xbee is my bet. I came across this link
which suggest s that there should be atleast 10 ms delay between packets if you're using xbees.
What are your experiences with xbees? I don't want to waste money.

what is the distance between devices?

Not more than 5 - 10 meters I think.

if you don't want to waste money take bluetooth adapter. HC-06 is around 4$. Also there are NRF24L01+ 2.4GHz trasceivers. They are cheap and fast

How much data do you need to transmit every millisecond? I like the nRF24l01+ units and have found them reliable at ranges around 10-15 metres but they have a max payload of 32 bytes and top speed of 2Mbps, both of which will limit throughput.

I can connect atmost six sensors to the arduino. So It should be around 20 bytes tops. What do you guys think about xbees? I know I can get those easily in my country. Not entirely sure about nRF24l01+.

Xbee costs about 1000INR. They are really expensive. You should buy HC-05 module, which costs about 320INR.
You can easily interface them with Bluetooth of your Laptop using Processing Application.
You can even use ESP8266 ESP-01 Wireless Module. They Cost about 3$.
Wireless module gets connected with your router. this tutorial will help you to start. You can by this module from here.
nRF24l01+ modules can not be interfaced with Laptop...

Thanks a lot for the suggestion but I am specifically looking for a rf or wifi solution

ESP8266 ESP-01 Wireless Module is a WiFi solution to your problem!!