text:
How can I use a 'Global' class object?
I created a class inside the sketch file(not in another file) and init it as object before setup() and loop() as a global object, after I change some parameters inside the object in setup() , I found in loop() the parameters in the global object remain unchanged.
Here is the pseudocode code to describe my question:
//all of the code below are in the same ino file.
class Animal{
public:
  bool alive = false;
  Animal (bool liveStatus){
    alive = liveStatus;
  }
}

Animal dog(false);
Animal cat(false);
Animal lion(false);
Animal animalArray(dog,cat,lion);

void setup(){

  for (int i=0;i<3;i++){
    Animal current_animal = animalArray[i];
    current_animal.alive = true;
  }
  //here when I print each animal's alive flag is 'true'
}

void loop(){
  for (int i=0;i<3;i++){
         // here the alive flag of each animal is still false  , they should be all true!!
  }

}

It looks like after I quit setup() somehow every change of the global object inside the setup are all gone .
Thanks for helping me ..

I can't replicate this error. Can you post the whole code you were uploading before with the print statements and everything?

Hi BreetAm , the original code is relative complex and long(about 600 lines ) ,post to here won't be a good idea .. is that kind of codes works for you ?

Its great that you've tried to keep the example minimal, but in this case you also seem to have removed the source of your problem. Maybe you can pair down you code while constantly testing for the error and seeing how small you can make it without causing dog's value to reset?

Thanks BrettAM, I am currently doing more test on it , I will push a better example tomorrow and notify you :)

Hi BrettAM, sorry I didn't mentioned that I use array in my code . I've edited the example could you check it out please? :) Thanks...

I still don't have any problems, but this code is pretty far from compiling and the minimal changes I made to get it to compile could be different from your implementation. You should test these on your own first.

Hi BrettAM thanks for your kind help! I've reedited the example could you post your answer down then I could approve it for you and helping more people ,thanks! :DD

Your problem here is that Animal current_animal = animalArray[i]; is making a whole new Animal object that starts as a copy of animalArray[i];, but after that the two are no longer associated. Then when you call current_animal.alive = true;, you are not actually changing the animal in animalArray[i] anymore.
The simplest way to fix this is to make current_animal a reference to the object you pick out of the array, although a pointer would work the same way. With this code:
Animal& current_animal = animalArray[i];
current_animal.alive = true;

current_animal becomes a reference to animalArray[i], instead of a copy. Then operating on current_animal changes the same data that is stored in animalArray[i] like you intend.

Thanks BrettAM for your kindness help , this solution saved my day .This problem should be very common on C or C++ languages which involve with pointer stuff  , such a shame I just forgot it even I was a computer science student ..  Thank you!


text:
Arduino Standalone - photo shows incorrect pin wired to MOSI
I have been building a standalone Arduino on a breadboard following the guide, Building an Arduino on a Breadboard. The guide is generally very good, however, I have yet to get the Arduino working, for a number of various reasons, be it misinterpreted, or misread instructions (the reset pull-up resistor connected to GND instead of Vcc, Tx to Tx, instead of Tx to Rx (and vice versa), to name but a few issues that I have had to resolve).  However, I am sure that the following issue is not down to my careless interpretation or lack of attention.
Look at the photo taken from the webpage, Building an Arduino on a Breadboard, on the Arduino website, showing the Sparkfun AVR programming adapter connected to the ATmega IC.

The MOSI on the adapter is shown to be connected, via a dark green wire, to pin 16 on the ATmega chip, whereas the instructions say:

Be sure to refer to the Arduino pin mapping for help wiring this up.

The MISO pin of your adapter will go to pin 18 or Arduino digital pin    12 of your Atmega chip.
The SCK pin of your adapter will go to pin 19 or Arduino digital pin    13 of your Atmega chip.
The RESET pin of your adapter will go to pin 1 of your Atmega chip.
The MOSI pin of your adapter will go to pin 17 or Arduino digital pin    11 of your Atmega chip.

According to the pinout below, Pin 16 is SS and pin 17 is indeed MOSI.

So, to my mind, the photo is definitely wrong. Indeed I was getting avrdude errors when trying to use a USBasp to load a bootloader, when using the wiring as shown in the photo. When I correctly wired MOSI, from the adapter, to pin 17, the avrdude errors disappeared.
Am I correct in my thinking? Has anyone else attempted to build this circuit, following the instructions on the Arduino website, and come across this issue?
I am just looking for confirmation that I am right, before I contact the owner of the web page.

Dark green wire is indeed incorrect. Not sure what it is you are asking here. Is it still not working with the correction you spotted?

@Gerben - Thanks, I was just looking for confirmation that it was indeed wrong in the photo, and that I wasn't just making a stupid mistake. I shall try to contact the owner of the webpage to get the issue rectified, as I am sure that I am not the only person to get confused by this and lose time trying to figure out what is wrong. It does seem to be working better now, yes, since I have changed the wiring.

I have programmed AVR microcontrollers for a while. I would follow the datasheet, instead of the guide you have.
The Atmega168 Pin Mapping shows SS on 16, MOSI 17, MISO 18, SCK 19 and you will also need to connect to RST 1

source: Stack Exchange

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

sort: votes


text:
Arduino Mini Pro not working with my Neopixel project
my project involves 9 Neopixel LEDs. I have tested my code with my Arduino Uno board successfully. I'm using a mix of breadboard, jumper wires, and solder to connect everything. Powering the strip of 9 LEDs with 4 AA NiMh rechargable batteries, showing 5.2v on the meter. I've put a capacitor (1000mF 25v) in the circuit, right at the power source.
But when I upload the same code to my Mini (5v/16MHz) and swap it in in place of the Uno, I get nothing. No matter how much I jiggle wires or provide a good ground (which helped me get good results from my Uno). Every now and then by messing with wires, or as a few minutes go by, the first few lights might light up, but not in the right colors and no animation.
Just to test the Mini board I uploaded the sample program "blink" and the mini runs that one properly. So I'm certain my code is getting on there. My program is definitely bigger and involves some quick changes (I'm making an "ebbing" glow of supernatural eyes). Connecting the Mini to the Neopixel strip I soldered a wire with a female jumper onto the board, and my strip of lights has a wire soldered on with a male jumper. As a side note, it takes a little physical handling to get the project to work with the Uno (like pressing a little bit on the data wire in it's plug on the Uno or using a jumper wire in the breadboard clamped in a metal measuring tool and my hand to ground out the circuit). So maybe I'm just experiencing some of the shortcomings of the Mini, but I was under the impression that it would do just about anything the Uno could do. Especially in terms of just providing a data line for the LEDs.
I'm new to Neopixel. This is my first project in fact. So it is entirely possible I'm doing something wrong or there's something I just missed completely, or maybe my luck just sucks and I have some piece of faulty hardware... No idea.
Any suggestions would be most appreciated!

For debugging your hardware (which sounds like the problem), use a simple sketch that just turns on one Neopixel after another, and power it from the wall instead of batteries.

I'll give that a shot! I'll whip up a quick and simple sketch tonight like you mentioned and see if I get some results.

Ugh. Don't know what's going on. I made a simple program, tried it, and nothing happens. I load up the program in my Uno, works fine. Tried soldering some connectors to another mini (I bought 3 of them) and nothing. The struggle continues... Still in the dark as to why. I just watched a video of someone lighting up a string of 144 lights with animation using a mini. So I know this is supposed to work. Oh well. Thanks for the suggestion, jwpat7. I'll continue troubleshooting.

Some random ideas to check:  Are there ATmega328 chips on both your Uno and your Mini Pro? (Ie are the processors the same on both, as one would expect?)  Have you verified +5V on all the +5V pins?  Perhaps post a closeup photo or two, in your question, in case of some wiring error like hooking unregulated power to Vcc, or regulated power to Raw (which conceivably might work ok with the Blink program but not with something that requires more current).

A quick glance at the boards confirmed they both have the Mega328 printed on them. I'll check voltages at each pin tonight and snap some pics when I get the chance later. Watching the YouTube video I also noticed that the light on the mini was either green or blue couldn't tell with the quality of the vid. My minis have both shown solid red on the boards. I assumed that meant "power on". Maybe it means there is a problem with power? It also occured to me that the board may not like running off of USB power through the FTDI adapter.

The power-indicator LED is red in several mini-pro videos I looked at (vs green on some other Arduino models).  (I don't remember the color on the mini-pro boards I have, and most are inside cases where I don't see the lights)

As I was playing around today I found a solution. Powering the board through the FTDI adapter, which in turn was being powered by a USB juicepack charger, wasn't supplying enough juice and/or ground. It was enough for the Uno to work, so that's what was confusing me. I soldered in a 9V battery and clamped down on the pins with a wrench to ground it out. That made the board happy and it kicked into gear and lit my project up perfectly. It's pretty ghetto but it works! Yeah! :D

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


text:
Training Commands with easyVR
I am using the EasyVR Arduino Shield with Uno.
What i am trying to do is train a custom phrase like a name.
I want to be able to train the phrase directly with arduino whilst it is not connected a pc.  I have noticed in the documentation there are some references to commands like it, but i'm not sure how to go around writing code for such a thing.
thank you

Hi a bit late but I thought it could be useful to someone, I successed to train SD  commands without pc easyvr commander with this code:
// ARDUINO 1.6.6
// EasyVR Shield 2.0
// EasyVR library v1.7

#include "Arduino.h"
#if !defined(SERIAL_PORT_MONITOR)
#error "Arduino version not supported. Please update your IDE to the latest version."
#endif

#define pcSerial SERIAL_PORT_MONITOR

#include "SoftwareSerial.h"
SoftwareSerial port(12, 13);

#include "EasyVR.h"
EasyVR easyvr(port);

//

char label[33];
uint8_t data;

bool train = false;
bool recog = false;

int8_t group = EasyVR::PASSWORD;
int8_t index = 0;

void setup()
{
  pcSerial.begin(9600);
  port.begin(9600);

  while (!easyvr.detect())
  {
    pcSerial.println(F("EasyVR not detected!"));
    delay(1000);
  }

  //

  easyvr.setPinOutput(EasyVR::IO1, LOW);
  pcSerial.print(F("EasyVR detected, version "));
  pcSerial.println(easyvr.getID());
  easyvr.setTimeout(5);
  //  easyvr.setLevel(EasyVR::HARD);

  //

  printCommands();
}

void printCommands()
{
  pcSerial.print(F("Password: "));
  int16_t count = easyvr.getCommandCount(group);
  pcSerial.print(count);
  pcSerial.println(F(" command(s)"));
  for (int8_t idx = 0; idx < count; ++idx) {
    if (easyvr.dumpCommand(group, idx, label, data)) {
      pcSerial.print(idx);
      pcSerial.print(F(" = "));
      pcSerial.print(label);
      pcSerial.print(F(", Trained "));
      pcSerial.print(data, DEC);
      if (!easyvr.isConflict()) pcSerial.println(F(" times, OK"));
    }
  }
}

bool checkMonitorInput()
{
  if (pcSerial.available() <= 0) return false;

  int16_t rx = pcSerial.read();
  //  pcSerial.print(rx);

  if (rx == 's')
  {
    easyvr.removeCommand(group, index);
    easyvr.addCommand(group, index);
    easyvr.setCommandLabel(group, index, "cuss");

    printCommands();
  }

  if (rx == 't')
  {
    recog = false;
    pcSerial.print("say something");
    train = true;
  }

  if (rx == 'r')
  {
    train = false;
    pcSerial.print("start recognition");
    recog = true;
  }

  //

  if (rx >= 0)
  {
    easyvr.stop();
    pcSerial.flush();
    return true;
  }
  return false;
}

void loop()
{
  checkMonitorInput();

  if (train) {
    pcSerial.println("Train a word");
    easyvr.trainCommand(group, index);
  }

  if (recog) {
    pcSerial.println("Say the word");
    easyvr.recognizeCommand(group);
  }

  //

  do {
    if (checkMonitorInput()) return;
  }
  while (!easyvr.hasFinished());

  //

  int16_t idx = easyvr.getCommand();
  if (idx >= 0) {
    if (easyvr.dumpCommand(EasyVR::PASSWORD, idx, label, data)) {
      pcSerial.print("recognized = ");
      pcSerial.println(label);
    }
    easyvr.playSound(0, EasyVR::VOL_FULL);

  } else {
    if (easyvr.isTimeout()) pcSerial.println("Timed out, try again...");
    int16_t err = easyvr.getError();
    if (err >= 0) {
      pcSerial.print("Error 0x");
      pcSerial.println(err, HEX);
    }
  }
}


text:
Problems splitting a string to get authentication and command
Good afternoon,
In a nutshell I'm having some difficulty with splitting and returning part of a string.
Essentially I'm working on the code for transmitting a password (24 character string) and command (string) in a single packet. However, the 'get_command' function is only returning the first character of the string (T) as opposed to the whole string (T1) and I'm not sure why. Any help would be greatly appreciated. Thanks in advance.
The entire sketch is below so you should be able to just drop it in and compile.
char *received_data = "KkV3vKvLgC4PdBZRs5kkKM86T1";
char *password = "KkV3vKvLgC4PdBZRs5kkKM86";

int authenticate_transmission(char *data) {
    if(strncmp(data, password, 24)) {
        Serial.println("no match");
        return false;
    } else {
        Serial.println("match");
        return true;
    }
}

char *get_command(char *data) {
    char command[3];
    strncpy(command, data + 24, 3);
    // Fine here
    Serial.println(command);
    return command;
}

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

void loop() {
    // test received data - message is T1 at the end.
    if (authenticate_transmission(received_data)) {
        char *command = get_command(received_data);
        // But just prints out first char when returned from a function
        Serial.println(*command);
    }
    delay(10000);
}

The command array created inside get_command() is local data. That means it's only available while that function is being executed.
However, you're returning a pointer to it. That means when you're trying to use command afterwards from inside loop(), you're trying to refer to data which has been deallocated. By that point, it's getting used for something else.
There are various solutions to this. A fairly simple approach would be to have the caller allocate the command array, passing a pointer to it into get_command(). For example:
void get_command(char *data, char *command) {
    strncpy(command, data + 24, 3);
}

From loop(), you would call it like this:
char command[3];
get_command(received_data, command);

The command array is still local data in this case. However, it's local to the loop() function (or wherever else you put that code). That means it will still be available when get_command() is called.

Saying static char command[3] instead is slightly easier

@jwpat7 That would work, but it's not good programming practice.

Thanks Peter, that's very helpful. I've got it all sorted now and a bit more insight. Thanks again.

The direct issue is you have a dereference operator (*) in the loop that you don't need:
Serial.println(*command);

This causes it to pass only the first character to Serial.println() instead of the pointer to the memory location. That's the first issue.
Like Peter mentioned, the string gets deallocated when returned from the get_command() function. It's undefined behavior, but it's luck that it worked the way it did.

Good catch. Hadn't spotted that myself.


text:
Arduino R/C compatible transmitter and reciever
I want to make a RC buggy or something down those lines (using Legos of course) and I'm confused while looking what transmitter/receiver to use. Would like a simple classic remote and any compatible receiver for the Arduino.
Found such a remote: http://www.hobbypartz.com/79p-th9x-r9b-9channel-radio.html
But this seems way overkill for what I want to do. Any links or suggestions would be appreciated. Hope the question isn't too broad for stack exchange.

If you want really cheap you could use a old IR remote control.

The price isn't the main factor, but the one I linked is a bit too expensive. I'm guessing 20-30 euros would be good.

If you want to involve an Arduino on the receiver, you may want to choose a transmitter which is compatible with a 2.4 GHz chipset that is both available, and for which you can find Arduino code.  The NRF24L01+ and Beken compatibles are probably the most available, and a lot of RC toys use something compatible, though getting firmware right to interact with them can be tricky.  Beware that there are some other chips in wide use too, which can be harder to source a module for.
You can use an off-the-shelf multi-channel receiver, but that will tend to output each channel on a distinct PWM pin, which is annoying if you want to capture the data into an Arduino.
You might want to spend some time looking on rcgroups and in various hobby drone sites - the latter folks have a similar problem, as they want to collect all the control channels and mediate them through a custom flight computer (which in the early days was sometimes Arduino-compatible).
You can also make your own transmitter - perhaps by retrofitting an NRF24L01+ module and miniature Arduino equivalent into the casing of an older 5/72/75 MHz set - or the IR transmitter from a toy helicopter.

Thanks for the great answer! Making my own transmitter/receiver would be a no go for me as I'm not that good with electronics, so I want to buy a combo of both, then program the Arduino to (I'm a developer) drive the motors n stuff from the received sigal :) I found this: http://www.ebay.co.uk/itm/FS-GT2-2CH-2-4G-Radio-Remote-Control-Transmitter-and-Receiver-RC-Car-Boat-UK-/131121926912?pt=LH_DefaultDomain_3&hash=item1e8779d300
Seems to me, that I could easily connect the receiver to a Arduino and get the channel values?

That is a two channel radio, and unhacked will output each channel on its own wire, so your Arduino will have to time two independent PWM signals.  For only two channels that is reasonable - if you wanted 4 or more it starts to be ugly.

It depends on the number of channels you need, but you could go to HobbyKing, they offer RC remotes for down to 20$


text:
Starting usb on pro micro after deep sleep (ATmega32u4)
I have just started playing with a low power arduino project, and have managed to get the power drain down to about 220uA using powerDown from LowPower.
What I would love to be able to do is start the USB controller and send some data every 8 seconds, but I cant seem to send anything...
Any idea would be greatly appreciated :)
Her is my code:
// **** INCLUDES *****
#include <LowPower.h>

#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>

void setup()
{
  DDRD = B00100000;       // PORTD5 = TXLED
  DDRB = B00000001;        // PORTB0 = RXLed

  Serial.begin(9600);
  while (!Serial) ; // Needed for Leonardo only
  Serial.println("Starter...");
  delay(100);
  Serial.end();

  /*
  *  IKKE FJERN DENNE!!! Da greier vi ikke å omprogramere kortet...
  */
  delay(10000);
  Serial.begin(9600);
  while (!Serial) ; // Needed for Leonardo only
  Serial.println("low-power...");
  delay(100);
  Serial.end();
  flash();
}

void loop()
{
  //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER4_OFF, TIMER3_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, USART1_OFF, TWI_OFF, USB_OFF);//, USB_OFF);
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  //USBCON &= B11011111; //Disable USB Freeze clock USBCON.FRZCLK
  //USBCON |= B10010001; //SET USB_MACRO_ENABLE_BIT USBCON.USBE

    PLLCSR |= B00000010;   //-Enable             PLL PLLCSR.PLLE = 1;
    while (!(PLLCSR & 1)); //-Wait PLL LOCK      while (PLLCSR.PLOCK != 1);
    USBCON &= B11011111;   //-Unfreeze USB clock USBCON.FRZCLK = 0; (Clear to unfreeze)
    //-Clear Resume information ???

  flash();

  /*
  * Test USB kommunikasjon :)
  */
  Serial.begin(9600);
  while (!Serial);
  delay(5);
  Serial.println("Hello world!!!");
  delay(5);
  Serial.end();
   PORTD |= B00100000;
   PORTB |= B00000001;
}

void flash() {

   PORTD &= B11011111;
   PORTB &= B11111110;
   delay(100);
   PORTD |= B00100000;
   PORTB |= B00000001;
   delay(100);

   PORTD &= B11011111;
   PORTB &= B11111110;
   delay(100);
   PORTD |= B00100000;
   PORTB |= B00000001;
   delay(100);

   PORTD &= B11011111;
   PORTB &= B11111110;
   delay(100);
   PORTD |= B00100000;
   PORTB |= B00000001;
   delay(100);
}

Best regards, Richard
EDIT
The manual specifies this resume protocol:
Resuming the USB interface (21.13 USB Software Operating Modes)

Enable PLL
Wait PLL lock
Unfreeze USB clock
Clear Resume Informtion

which I have translated into this:
PLLCSR |= B00000010;   //-Enable             PLL PLLCSR.PLLE = 1;
while (!(PLLCSR & 1)); //-Wait PLL LOCK      while (PLLCSR.PLOCK != 1);
USBCON &= B11011111;   //-Unfreeze USB clock USBCON.FRZCLK = 0; (Clear to unfreeze)
//-Clear Resume information ???

It have no effect whatsoever, have no idea how to clear resume information though...
Also, for the record, the LEDs are flashing happily every 8 seconds.

You might have to put some delay after the serial.write. Once it comes back from sleep, it probably has to reestablish a USB connection (though your code seems to already account for that), and after that send the serial data. It can't do that when it's sleeping.

Hi Gerben, I just tried that with 800ms, but no success, I will try a little more... Is there any low-level USB commands that needs to be issued again maybe?

Also, when running in Idle, 200ms is enough before sending data and receiving... [edit] even 50ms is enough in when idle(usb_off) / serial.end before sending again

Sorry, I never worked with any USB chip, so I can't really help you any further.

I found an answer to a similar question here:
https://forum.sparkfun.com/viewtopic.php?f=32&t=39214&start=15#p175098
Note: it requires you to close and open the serial monitor at proper timings.
// disable the USB prior going to sleep
USBCON |= _BV(FRZCLK);  //freeze USB clock
PLLCSR &= ~_BV(PLLE);   // turn off USB PLL
USBCON &= ~_BV(USBE);   // disable USB

// and wake it up after
//routine to properly wake up
sleep_disable();
delay(100);
USBDevice.attach(); // keep this
delay(100);
Serial.begin(9600);
delay(100);


text:
How to call URL with Arduino Ethernet shield?
I'm working on Arduino and Ethernet shield.
I need to call a URL. How can do it? (This URL is HTTP API to send an SMS to my phone).

url:
http://api.clickatell.com/http/sendmsg?user=mohammed.atha&password=********&api_id=3539384&to=********&text=hello

You need to use the EthernetClient. link
The exemple using your API call is:
if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make your API request:
    client.println("GET /sendmsg?user=mohammed.atha&password=********&api_id=3539384&to=********&text=hello HTTP/1.1");
    client.println("Host: api.clickatell.com/http/sendmsg");
    client.println("Connection: close");
    client.println();
}

Full example from Arduino.cc docs:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make your API request:
    client.println("GET /sendmsg?user=mohammed.atha&password=********&api_id=3539384&to=********&text=hello HTTP/1.1");
    client.println("Host: api.clickatell.com/http/sendmsg");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}

how this can help me !!!
plz help me

Just look at client.connect(server, 80) in code in the example, i've changed to work with your API call.

thnx thnx thnx :D
but why use google.com as server ? (char server[] = "www.google.com";)

Is there a need for subnet and default gateway ?

This is just to check if you have internet connection, simulating a ping in the google server. If it responds you have connection and then you make your API call, you can ignore this if you don't want to check for internet connection.

You don't need the default gateway

serial monitor (connecting...
connected
HTTP/1.1 400 Bad Request
Content-Length: 54
Content-Type: text/html; charset=UTF-8
Date: Thu, 30 Apr 2015 21:40:03 GMT
Server: GFE/2.0
Connection: close
Error 400 (Bad Request)!!1
disconnecting.)
why bad request ?

vitor leal ????

@MohammedAthamneh please vote in the answer if it helped you ;)


text:
Powering arduino uno from Car's reverse light?
I am making a reverse sensing alarm system. I am using a HC-SR04, arduino UNo and a piezo buzzer. The programming was a success however i will like this circuit to be powered when the reverse gear is shifted into place. So I am thinking to power the V in of the UNO with the 10V from the  reverse bulb socket receives. However I think the amperage sent to this bulb is too much for my UNO. What should I do ? and Does anyone have any other recommendations to power the UNO in such a scenario?

Amps are drawn, not sent. A device will only draw the amps it needs. You might have to add some additional protection, as car voltages are very noisy, with huge spikes, that can easily fry your arduino.

Power the Arduino in parallel with the bulb.  Take the V+ wire running to the reverse light and the frame ground.  The frame ground is any bare metal surface of your car will be grounded, just connect a wire to your frame.  Or you can just splice the light bulbs ground wire.  When powering the circuit in parallel you do not have to worry about the amperage draw of the light.  By a barrel jack connector like this connector from spark fun you can buy these cheaper elsewhere just a 2.1mm barrel jack connector.  Connect the positive and negative respectively, and connect the 12v into the Arduino's barrel jack.
As a side note the bulb should be getting 12V not 10V it's not a huge problem, but it is a slight issue that could later be a problem or be caused by an electrical bug.  If everything works don't scramble to fix it, but be aware it exists.

If you put it in series, the bulb will not light up (too little amps going through both). Just place it in parallel. The arduino will only draw what it needs; a few milliamps.

I made a massive brain fart I just switched series and parallel in the answer.  DO NOT WIRE IN SERIES!!


text:
Can I use a UDOO as an Arduino?
I have a UDOO, and I wonder whether or not it is possible to use the Arduino that it has without starting the UDOO's operating system, i.e., I would like use Atmel Studio to load a program within the Arduino at UDOO.

Yes, but you have to erase the flash (and reset the ATMEL SAM3X8E processor) manually before the programming. You can use the J16 and J22 jumpers to do this.


text:
Not sure if programmer or ATMega is burned
some time ago i tried doing this with my original arduino uno r3. I guess i had to plug the power cables in wrong order(i think it's called reversing polarity)  because my arduino stoped working. It turns on (the power diode is on) but i cannot upload any sketch on it. I'm thinking about changing the ATMega chip but, before i do that i want to be certain that it's the chip issue ,not the programmer. I have another arduino uno, and i heard that i can upload sketch with it to another uno. So my idea is, if i do this i will be able to say whether it's the programmer or the chip issue. The only problem is that i don't know how to do this and i wasn't able to find any reasonable tutorials online. Please tell me what to do.
Many Thanks,
Jan

Does the uno show up in the Device Manager? You could also have burned the ATMega16u2 that does the usb-to-serial.

I think it does, i will check it when i'm back home.

The Arduino IDE ships with a built in ArduinoISP sketch, and there is a very detailed tutorial with wiring diagrams etc on the Arduino site.

But doesn't it alow me only to burn a bootloader ? I would like to upload a simplest sketch (for example Blink) to check whether does the chip work.

No, you can program anything you want with ISP. When you use a boot loader, you can only program the non-bootloader section, but the converse is not true.


text:
Clone pro micro serial port 'COM4' already in use
So I just got this board I ordered from ebay and tried to play with it for the first time. http://www.ebay.com/itm/Leonardo-Pro-Micro-ATmega32U4-Arduino-IDE-1-0-3-Bootloader-replace-Pro-Mini-/310634777706?pt=LH_DefaultDomain_0&hash=item4853468c6a
I connected it to my PC and it was installing a driver. I didn't pay much attention to it but I think it finished installing it successfully. I then installed arduino IDE 1.6.3(latest) and tried to compile and upload the empty default sketch just to see if it uploads it. the progress bar got to the end but it was stuck on "uploading..". I waited for a few minutes but it didn't seem like it is going to end so I unplugged the USB and re inserted it back. I then looked in the tools menu and saw it was set to port COM1 which is the communications port on my pc, so I changed it to port COM4(Arduino Leonardo) and the board to Leonardo and again tried to compile and upload the default sketch but now I got this error:
Arduino: 1.6.3 (Windows 7), Board: "Arduino Leonardo"
Error opening serial port 'COM4'. (Port not found)
trying to open the serial monitor gives the same error.
So I checked the item listing on ebay and it said that the board was supported under arduino IDE 1.0.3 so I downloaded it and tried to compile and upload the default sketch but it gave me the serial port 'COM4' already in use error.
I tried resetting the board, uninstalling and reinstalling the driver and the IDEs and disabling/re-enabling the device in the device manager. nothing helped.
I am not sure what I am doing wrong as I am new to this.
Thank you.

Reboot you PC, see if that clears it.
If not then fire up Device Manager and have a look at what COM ports you are using.
I think there is a way of reassigning the ports used by the boards within the control panel, but I can't remember what it is at the moment, so have a quick google.
Its not the fact that its a Clone that's causing you an issue, its Windows drivers that have caused you issues.  If all else fails, uninstall the drivers, reboot twice and try again.  I also don't think using a newer version of the IDE will have a negative affect.

I had already solved that issue months ago though I forgot to comeback and add an answer... I don't remember what I did exactly but it worked since then. I think I just played around with the USB ports trying to connect it in different ones until I got it to work but I am not 100% sure.


text:
Electret microphone amplification
I've got an electret microphone and I understand that I need quite some amplification to get it to be read by an Arduino (0-5V input). So I seeked the web, but answers are as different as people on the street. Some use Op-Amps, some only a transistor cicruit or the like. This guy is using 2 amps before and after his filters Video, LM386 and this guy claims, that exactly this amp isn't good for the job: recommends NOT using LM386.
I really only want to have a threshold switch, so I need no filters whatsoever and not a super duper amplification. What is the simplest solution, with which I can read a voltage with the arduino? With a transistor alone (seems easiest to me so far) - how can I know how much it amplifies (or as I understand it modifies the "other voltage" to look the same)?
I found many different schematics using various op-amps, but regarding them I don't really need another tutorial, but rather a rule of thumb for a "readable" amplification. Is 100 times enough? I found circuits with 1000 times amplification, so I'm really wondering which one works fine.
However the really simple thing would be this: video at 17sec. At second 17 and 50 or so, they show an extremly basic circuit, which would be exactly what would work best for me... However the question is, if this is enough amplification for the ADC in an arduino.
If I can't get a satisfying answer I think I'll build both and see how they compare/work for me.

I've built

This circuit without C4 and everything after R4 (no rectifier, not a single diode used). R4 has to be switched for 100kOhms, since this gives a 100x amplification. I guess this is simple enough for most people.
Thanks for the hints.
The following code can be used to detect claps/noises. It is restricted to a double-clap with silence in between. Parameters can be easily tuned. This works quite well for me, even when I play noise/TV/music to the speaker directly it triggers rarely, or not at all!
// CLAP switch using an electret microphone
// switches ie. a relais or led with a certain
// clap-melody

// sound parameters
const int THRESHOLD = 20;
const int VAL_MEAN = 507;

// trigger characteristics
const int CLAPS_TO_TRIGGER = 2; // number of claps
const int DEBOUNCE_TIME = 150; // ms to ignore double-clapping
const int SILENCE_T = 40; // ms between claps, otherwise reset
const int MELODY_INTERVAL = 800; // ms max time for the claps
const int PAUSE_TIME = 2000; // wait after switch, or noise

// pin-layout
const int analogPin = 0;
const int OUTPUT_PIN = 13;

int output_state = LOW;
uint32_t pause_t = 0;
uint32_t debounce_t = 0;
uint32_t start_time = 0; // timestamp of first clap-start
uint8_t claps = 0;
int sensorVal = 0;
int amp = 0;

void setup() {
  Serial.begin(115200);
  pinMode(OUTPUT_PIN,OUTPUT);
}

void loop() {
  sensorVal = analogRead(analogPin);
  amp = abs(sensorVal-VAL_MEAN);

  // Serial.print(F("sensed: ")); Serial.println(sensorVal);
  // Serial.print(F("amp: ")); Serial.println(amp);

  // at the end of an interval check the number of claps
  if (millis()-start_time > MELODY_INTERVAL & claps != 0) {
    if (claps == CLAPS_TO_TRIGGER & millis()-pause_t > PAUSE_TIME) {
      output_state = !output_state;
      pause_t = millis();
      digitalWrite(OUTPUT_PIN,output_state);
      Serial.print(F("Triggered "));
      Serial.println(output_state);
    }
    if (claps>CLAPS_TO_TRIGGER) { Serial.print(F("- too many")); }
    reset();
  }

  // noise/clap detected
  if (amp > THRESHOLD &\
      millis()-debounce_t > DEBOUNCE_TIME &\
      millis()-pause_t > PAUSE_TIME) {
    // there has to be silence between claps
    if (millis()-debounce_t < SILENCE_T+DEBOUNCE_TIME) {
      claps = 0;
      debounce_t = millis();
      Serial.print(F("reset - silence interrupted"));
      Serial.print(F(" amp "));Serial.println(amp);
    } else {
      claps++;
      debounce_t = millis();
      Serial.print(F("claps "));Serial.print(claps);
      Serial.print(F(" amp "));Serial.println(amp);
      if (claps == 1) { start_time = debounce_t; }
    }
  }
  delay(1);
}

void reset() {
  // time has expired
  start_time = 0;
  claps = 0;
  debounce_t = 0;
  Serial.println(F("reset"));
}

For the most basic circuit you must bias your microphone since it is electret with a 10k pull up resitor. If you do not want to build a complex circuit you could use a breakout board such as this one.  To build your own see here. It is used as a VU meter which is basically the same idea.  Also, make sure you observe polarity(pin with traces touching metal packaging is negative).

You can use Maxim MAX4466 op-amp which works very well with Arduino. There is a breakout available for the same for arduino at Adafruit here. The chip has a select-able gain from 25x-125x. This amplifies works very well to get a nice waveform for audible noise. There are a couple of libraries available for the waveform that you record and can translate it to frequencies. You can also use it to distort or change the voice. Here is a schematic of the circuit if you want to make one yourself.


text:
How to solve Atmega 16A Serial write (println) hang with Arduino Uno firmware?
For doing some experiments I bootloaded an Atmega16a with Arduino Uno. I am powering my Atmega16a from Arduino UNO. I am not using any external clock. Atmega16a is connected to a breadboard. For bootloading I refer the site http://hardwarefun.com/tutorials/use-arduino-as-an-isp-programmer-to-program-non-arduino-avr-microcontrollers I can run blink sketch on my Atmega16a using Arduino as ISP. TX and RX of Atmega16 is connected to Max485's DI and RO respectively.
Atmega16a pin 14 (RXD) -> MAX485 pin 1-RO
Atmega16a pin 15 (TXD) -> MAX485 pin 4-DI
Atmega16a pin 17 (D3)  -> MAX485 pin 2 and 3. Also connects a LED to the pin

I used a boards.txt downloaded from https://github.com/sudar/arduino-extra-cores/blob/master/boards.txt
Issue: hang at Serial.println
I faced issues when I started to interface with MAX485.
The program wont run if I add a Serial.println, see my program below.
void setup() {
   Serial.begin(76800); // I tried 9600 too
   pinMode(3, OUTPUT);
}

void loop() {
  digitalWrite(3, HIGH);
  delay(400);
  Serial.println("20"); //comment this code and could see the led blinks
  delay(2000);
  digitalWrite(3, LOW);
  delay(400);
}

Regression
I tried Latest Arduino IDE as well as 1.0.6 version
I could do a serial communication with Raspberrypi and Arduino Uno via MAX485 without any issues. For the complete connection detail of MAX485 and other Arduino, check my blog.
Some times I receive some string to serial port of Raspberry pi like below. I run a nodejs app in RPi, using serialport npm and parser is RAW.
<Buffer fa>
<Buffer 82>
<Buffer 86 ff>
<Buffer fe>
<Buffer fe>

How to prevent these hangs?

I suspect you are not using the correct core files. The Atmega16A and the Atmega328P have different register locations for the USART (serial hardware). The fact that it hangs suggests to me it is waiting for some register to change state, but it is checking the wrong register. What board do you have selected in the IDE?

Unfortunately you can't just simply upload the Arduino bootloader and expect it to work. The ATmega16 is not the same as the ATmega328. One quick look at the datasheet will already explain why this is not working. The UDR(USART data register) is at 0xC6 on the 328, while it's at 0x2B at the Atmega328. So the ATmega16 will look at the location where the 328 stores the received data and will not find it. This could explain the hang, but I expect that other things like UART setup will have gone wrong before you get to the receiving of data.
If you want serial communication with the ATmega16, try programming it directly in C with the AVR libraries and without the Arduino extensions. That will make it harder to figure out.


text:
What are the advantages of "Arduino compatible" boards
There are countless boards called "Arduino compatible board". Some of them have specialized hardware features such as WiFi, SD card readers etc., but most of them seem like plain Arduino copies to me.
Sure, they are a bit cheaper, but for me the price difference doesn't make me favor the money I'd safe over the potential issues I have yet to discover.
Question: What are the benefits (or disadvantages) of Arduino compatible boards (the ones without the "extras") in general? Do you know an Arduino compatible board that you would recommend for some extraordinary features?

Arduino compatible means that you would be able to use the boards directly with the Arduino IDE and you can use most of the libraries and examples that come for the official Arduino Boards.
The official Arduino boards comes with a standard set of features that are infinitely expandable, but sometimes you have constraints for a project and you need a board that you can easily adapt to a project, the compatible boards come handy in those place. For example, you can use Ardupilot to control UAV's and has a lot of sensors on it with a very small form factor but you can still code it with the Arduino IDE, you can use Femtoduino (which is an arduino board the size of a coin) for very small projects.
Another simple reason for using the compatible boards is that a lot times they are cheaper than the official Arduino Boards (see Sparkfun Redboard)
You should be able to use any Arduino compatible boards without any problems but it would be better to go with a reputable supplier rather than a supplier in China to ensure that you get a good board that works without any problems.

While Arduino is an open source system, "Arduino" is a trademarked name and may only legally be used for products from the Arduino's originators or licensed suppliers. Arduino are quite clear about this requirement - see here - Logo and here Trademark
and here What makes an Arduino board an Arduino? and FAQ
As a result, compatible microcontroller boards are legally required to NOT identify themselves as being "Arduinos", so the term "Arduino compatible" is about the most that even an Arduino-identical clone can claim.

As karan notes, some Chinese sourced Arduino compatibles "have issues".
however, I have had no problems at all with Arduino compatibles manufactured and supplied by this Chinese supplier. As well as the basic devices they sell various interface boards (shields) and related equipment. Prices are astoundingly low, free postage is included in many cases (about 2 to 3 weeks delivery time to New Zealand) or you can pay for courier delivery. I buy Nano or Pro-Mini compatibles devices  - usually in batches of 10. As you will see -  Nano compatible costs $US3 each in 10's. Pro Mini compatible is currently $US1.68 each in 10's. !!!
Uno compatible here is $3.80 in 10s.  The voltage requlator may be a different type than than on 'real' Arduinos (but work OK) and versions with a USB-serial bridge IC use a non FTDI IC and you need to source and load the correct (freely available) drivers.
NB: (1) I have NO commercial connection with this company except as a very happy customer.
(2) I'd expect you to have no problems with these or other products from them but I of course have  no responsibility for what they sell.


text:
How to use an Arduino Uno + Keyboard Firmware to make a "N Key Rollover" Game Pad
Hello I have flashed my Arduino Uno with USB keyboard firmware from this tutorial http://mitchtech.net/arduino-usb-hid-keyboard/#comment-6786, and I have been successful sending individual key presses but, not when trying to press an hold a key. I am attempting to use this firmware to create a custom Game Pad to USB adapter, the only issue is sending simultaneous keystrokes (not sending them one at a time). If you know how to accomplish this task I would be very happy. The technical term for this is "Key Rollover"

Howmany buttons are you checking and to which pins do you have them connected?

My game pad has 12 buttons, and they are connected with shift registers so only 3 pins. Checking the button states isn't the issue. I am trying to use the game pad as a keyboard with the Keyboard firmware from the tutorial above but, to play games I need to be able to press many keys simultaneously.

The easiest option would be to switch to an Arduino that has a USB-capable main MCU, such as the Leonardo.

I understand why this would be a good way to do this since the people from arduino provide a keyboard library for the Leonardo but, with my arduino uno I have already got to be plug n' play as a keyboard. The problem is getting more than one button press at a time. I need to add simultaneous key presses "Key Rollover"

After closer research on this topic I have found the answer to my problem but,thank you to all that have tried to help. In order to do "Key Rollover" I needed to write the additional key states to the remaining values of the buffer array then write the values with Serial.write(buf,8). I can now use my Arduino Uno + My Game Pads as controllers for all my computer games.

You don't want to send random keys do you?
Well consider using the code below as your base.
It's using Port Manipulation to read the buttons (Digital 0 to 7).
void setup()
{
  Serial.begin(9600);//Start serial connection.
  DDRD = 0b00000000; //Set Data Direction Register of port D to inputs (attach keys to digital pins 0to7;
  delay(200); //Misc delay.
}

void loop()
{
  Serial.write(PIND, 8);    // Send states of PORTD (digital 0 to 7)
}

I strongly suggest you use pull-down/up resistors on the buttons also.
Adjust your code to the amount of keys you're using, or pull the pins low if not used. To avoid receiving random/floating pin values.

The problem is not with the '328P itself but with the communications channel with the USB chip.

@IgnacioVazquez-Abrams Thanks, I skipped a bit too fast through the article. The new answer should fit the needs of the 'asker'.

Sorry, this is not what I am having issues with. I have all ready have the game pad and have been able to read the input values from the controller. When I press one button sending the keystroke is easy. It is when I need to have many key presses as held keys. Other wise the game will think I am repeatedly pressing different buttons.

Than you should only send the state of your key when it's changed?

Could you post an example of your updated code?  I'm working on a similar project but a complete n00b as far as using the Arduino goes.


text:
Android Studio project for Redbearlab BLE Shield apps
To interact with its BLE shield, Redbearlab published sample Android apps in the Play Store. The sources for the apps are available on GitHub. How can I build them in Android Studio?

It was much simpler than expected to put together the Android Studio projects. They are on GitHub now.
Note that the apps built from source are actually different from the ones published by Redbearlabs on the Play Store. On top of that, the chat app is not working.


text:
Is it possible to program Arduino UNO with USB/TTL adapter withouth connection Vcc
For some strange reason my Arduino UNO clone board occasionally cause my Mac to reset, when I connect the usb cable. Possibly a power problem in Arduino or the USB hub.
Is it possible to program Arduino UNO with USB/TTL adaptor withouth conncecting the Vcc and GND pins (RX/TX and DTR only.)

Which Mac do you have? I'm pretty sure recent Macs have protection on the USB ports - I recently got an error message when I had accidentally shorted Vcc and gnd on an uno. My laptop (2014 15" rMBP running Yosemite) shut off the USB port until I reconnected the USB cable (after fixing the short, of course).

It is an iMac 21.5" late 2013

Is it possible to program Arduino UNO with USB/TTL adaptor without connecting the Vcc and GND pins (RX/TX and DTR only.)

No.
As a minimum you need to add ground as well - even if the Mac is battery powered.  Serial port signals are ground referenced so removing the ground would prevent operation.
Operation is possible without deriving Vcc from the USB port, but you will then need to derive Vcc from some other source.
If connecting ground alone causes your Mac to reset you have a serious system problem which may damage your Mac and which possibly may be dangerous to you.
Presumably you are NOT using an external power supply for the UNO.
In case you are: If the power supply for the UNO is AC mains powered it should be connected to the same mains outlet as the Mac. If the programmer powerpack is intended to be grounded but is not powered from a grounded socket AND using a 3 wire mains lead (ie with a ground pin and wire) then it s possible in some cases for the programmer to float at half mains voltage with a high impedance capacitive connection to mains. This is not usually dangerous to people but can cause minor nuisance shocks. It can destroy equipment (ask me how I know :-( .)
If you have a DMM (digital multimeter) set it to an AC voltage range greater than your local mains voltage and measure the AC voltage from a known ground (such as a water tap in most cases) and the programmer power supply (either wire or jack terminal). If you measure a voltage of about 50VAC with 100 VAC mains or about 115 VAC with 230 VAC mains then the power supply MUST be operated with a 3 wire mains cord and grounded power socket OR a ground lead from mains ground to power supply output ground.
If the Mac is battery powered and you have reset problems then something is wrong with connections or signal levels. You may be feeding voltage back onto the USB lines or loading the too heavily or ... ?

If you power the board with an external source of electricity (e.g. a battery), it's possible. But as it can force your Mac to reset, it will possibly damage your battery.

At first, I though it was a power problem, like you.  But now I'm pretty sure the problem is caused by the CH340G driver. When I check the panic report, last loaded kext is always wch.usb.

It's possible the reboot isn't a hardware issue, short circuiting, but some kind of operating system issue such as a faulty driver, or conflicts... Best to have a look at the Console after a reboot to see if there are any notes here, or try the same Arduino on another Mac or PC.

When I check the panic report, last loaded kext is always wch.usb so I assume the problem is caused by this driver.

At this point you probably want to look at Apple Support, or a fresh reinstall of the OS and then reimporting your data from a Time Machine backup.

It is a bit of work, but it is possible to use a couple of optoisolators to build a circuit that will electrically isolate the MCU from the serial adapter.

You should still figure out why your computer resets though, as it may not be related to the Arduino at all (e.g. maybe the cable is bad).


text:
HC-05 and HC-06 Bluetooth not communicating well
I am trying to communicate between two Arduino UNO. One has a HC-05 which is configured as master, the other Arduino has HC-06 which is the slave. What I want to achieve is to be able to print a character on the Serial monitor of the slave Arduino when a button on the master Arduino is pressed. I have been able to pair the two and once they are powered, they connect automatically. When I press a button on the master, what I get on the serial monitor of the slave is the 254 instead of the character 'a' which is what I am sending from the master. I have tried changing the data type, and also switched the code for master and slave, but the problem persists. I have also used hardware serial instead of software serial. My HC-05, and HC-06 works well when paired with android phone and can send and receive useful data. My code is as shown below:
CODE FOR MASTER:(SENDER)

#include<SoftwareSerial.h>
const int rxPin = 10;
const int txPin = 11;
const int button = 2;

SoftwareSerial masterSerial(rxPin,txPin);//RX,TX.

void setup() {
   pinMode(button, INPUT);
   Serial.begin(9600);
   masterSerial.begin(9600);
}

void loop() {

   int buttonVal = digitalRead(button);
   if(buttonVal==HIGH){
       masterSerial.write('a');
      delay(1000);
   }
//mySerial.flush();
}

CODE FOR SLAVE( RECEIVER)
#include<SoftwareSerial.h>

const int rxPin = 10;
const int txPin = 11;

int incomingByte = 0;

SoftwareSerial slaveSerial(rxPin,txPin);//RX,TX.

void setup() {

   pinMode(13, OUTPUT);
   Serial.begin(9600);
   slaveSerial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

   while(slaveSerial.available()){
      incomingByte = slaveSerial.read();
      delay(3);
      Serial.println(incomingByte);
    }
}

I have the same problem, anyone solved?

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


text:
Can I use custom ethernet shield with standard libraries?
I would like to make a custom ethernet card that uses the enc28j60 like this:
DIY Ethernet card
but first I would like to know if I can use the standard libraries which can be used with the ethernet card which is in the market like this:
ENC28J60 ethernet module

The libraries don't care whether or not you're using a shield, only that you're using a device they support and that you've wired it up how they expect (or that you've modified the library to use the actual wiring you're using). So find a library that supports the ENC28J60 and knock yourself out.


text:
Ask for available ip on ethernet shield
Is there any way so an ethernet shield to ask the router for an available ip address? For example to ask for an ip an the router to return 192.168.1.2 if it is available. I am asking it because if we set the ip programmatically and it is attached to another device we gonna have problem.

Using the DHCP (Dynamic Host Configuration Protocol) you can obtain an IP address dynamically from a DHCP server (which a router usually also is), without having to hardcode it into the firmware of the Arduino, thus enabling it to work on different networks.
There is also a library for that: http://www.arduino.cc/en/Tutorial/DhcpAddressPrinter. It's an extension of the official Arduino Ethernet library, written for the Arduino Ethernet Shield, but you'll likely find implementations of DHCP in many Ethernet libraries (I am using the EtherCard library) because it's an important feature to be able to connect to a network without a statically assigned IP and "only" requires UDP (on top of IP).
For e.g. the Ethernet library you call the begin function either with only the MAC address of your device or with MAC and IP address:
Ethernet.begin(mac);
Ethernet.begin(mac, ip);

In the first case it will use DHCP to obtain an IP address dynamically, in the second case it will use the static IP address you provide. Be warned that the second case, due to the needed implementation of DHCP, will increase the size of the compiled binary significantly.


text:
What options are available for connecting to a CDMA network?
I am looking specifically to connect to a CDMA carrier from an Arduino. In doing research, I came across a CDMA shield option (requires getting a CDMA module that you drop into a shield), but that ends up being quite expensive - the CDMA module alone is $140, as opposed to a GSM shield which runs $30-$60. I've also tried looking for other CDMA modules, but haven't been able to find much.
Even if it's not sold as a proper Arduino shield, does anyone know of a CDMA module for hobby projects?

There are no CDMA (more correctly known as CDMA2000) modules for hobby projects. There are a lot of reasons for this, which I won't get into, but suffice it to say, it is the way it is.
EDIT
Okay, I'll bite (just a little).

I think the most important reason is CDMA is actually kind of USA-centric technology. While there are now a few other countries that have CDMA networks deployed, it pales in comparison to the number GSM networks globally.
So in the cellular services world there is a service offering called machine to machine (M2M). What this is is a service to allow various machines (think parking meters, vending machines, ATMs, etc.) to have a data connection for control and status messages. These services are usually bought in bulk at rates much lower than equivalent consumer services would cost.
The rest from here on out is just economies of scale. If I am making an ATM machine, would I rather be limited to a handful of countries, or be able to sell in almost all countries. The obvious choice is the latter, so these manufacturers use GSM.
The reason a hobbyist can get anything cheap is because some other industry is using a lot of them. For example accelerometers used to be crazy expensive, that was until millions of cell phones started shipping with them every year, and now you can get them for pretty cheap. GSM modules are relatively cheap because there are lot of devices being made with them for the above mentioned reasons. CDMA modules are not so cheap because there are not a lot of devices using them.

I'm actually really curious why this is.

@JamesKingsbery there you go.

I assume when you state "CDMA" it is Carrier Detect Multiple Access.  There are several that are not very expensive and can go thousands of feet such as a RS485 network.  The premium would be CAN, it will give your CSMA-NDA (Carrier Detect, Multiple Access, Non Destructive Arbitration). A non-destructive bit-wise arbitration is used to control access to the bus. There are many more but these seem to be very popular.  Of course you can always go to an Ethernet Network, that is not that expensive and is typically a star network where the others are point to point. This is not a  complete answer but it should get you going down the correct path.  CAN will not run with one node, it needs a remote node to acknowledge the transmission. Try this link for a better description: "http://bitstream24.com/controller-area-network-can-bus-arbitration-principle/' Check the people that support this forearm, they sell the modules with instructions and of course eBay.
Good Luck,
Gil

The OP was referring to CDMA2000, as in the cellular communication, not CDMA the channel access method (which is used by CDMA2000).

Take a look at this link, you should get the impression that CDMA envelopes a lot more then Cell Phones.
http://www.slideshare.net/mnsh01987/bluetooth-technology?next_slideshow=1
Since you did not state CDMA2000 and I was involved in the automotive industry I took that approach because you can use CAN, RS485 and many other adapters to implement it with the Arduino, to my knowledge a complete CDMA2000 package is not yet available to the Arduino users.  Initially we tested the CDMA theory with open collector transistors on a wire transmission line then we tested CSMANDA with the same hardware. From that point custom chips were designed and implemented. This was in the early 90's.

I am looking at NimbeLink's Arduino baseboard which works with a CDMA modem. Never tried it, but thinking of ordering one. http://nimbelink.com/skywire-arduino-cellular-shield/. Not sure if you'd put this as 'affordable' since it is $40 for baseplate + $130 for modem.
Also this Arduino WCDMA 3G. http://linksprite.com/wiki/index.php5?title=3G_%2B_GPS_Shield_for_Arduino
Frustrating to have all this cheap awesome GSM technology, but only CDMA network in my region.


text:
Converting live vocals to discrete signals
I would like to augment a live music performance by displaying an specific LED for any given musical note.
For vocals:
Rather than attempt to process the audio using the Arduino board, I'd like to use something like an auto-tune box to do the heavy lifting.
For digital instruments: Would like to drive the Arduino board with some kind of digital signal (for example midi)
I'm having trouble finding out which (if any) consumer audio device can provide the pre-processing. Are there any comparable projects or insights?

Confusing question. You list vocals and Digital Instruments, then you ask which audio device provided pre-processing?
There are the auto tunes boxes you mentioned. Since you know about them I don't see how you would be asking about them.
A digital instrument might output midi, and midi is just a simple serial protocol, so there is no device needed.
So what is your question actually?
An auto-tune box does work that would be best suited to a laptop or desktop computer. It first must determine the intended pitch than apply a formant filter to shift the incoming signal to a correct pitch. It requires the use of heavy fast math, Fast Fourier Transforms, FFT.  The smaller boxes you see doing this are actually specialized computers. Do not confuse their size with their power.
Google 'digital tuner software' to get an idea of what goes on.  I do not know of a device that specifically output the 'corrected' midi for an auto-tune, but at that point it would be fairly trivial so it would not surprise me if many did it.  For sure the many guitar to Midi converts do just that, but a good one is several thousand dollars.


text:
connecting GSM 900A module to arduino
I am trying to connect my arduino uno to GSM 900A with the help of this tutorial https://elementztechblog.wordpress.com/2014/10/10/interfacing-sim900a-gsm-modem-with-arduino/
but the calling is not being carried out.
The serial output is as following:
Calling through GSM Modem
Called
ÿÿÿÿ

and the code is
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()

{

  Serial.begin(9600);
  Serial.println("Calling through GSM Modem");

  mySerial.begin(9600);
  delay(2000);
  mySerial.println("ATD99abc19965;");
  mySerial.println("ATH");
  Serial.println("Called ");
}

void loop()
{

  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

You're really missing multiple parts here...
Check out this tutorial: http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/

First of all, did you power up the SIM900A using its PWRKEY pin?
And can you send and receive AT commands?

How do you know that you have a valid GSM connection?
Did you try AT+CREG? and AT+CPIN?

Do you understand the AT commands you send?

You send ATD (with abc in the number?) and after that you immediately send ATH. Thus you would hang up directly after calling, and probably wouldn't even get to the actual calling part.

#include <SoftwareSerial.h>

SoftwareSerial sim900Serial(10, 11); // RX, TX

void setup()
{
   Serial.begin(9600);
   Serial.println("Calling through GSM Modem");
   sim900Serial.begin(9600);
   delay(2000);
   sim900Serial.println("ATD99abc19965;");
   delay(10000);
   sim900Serial.println("ATH");
   Serial.println("Call ended ");
}

void loop() {
   if (mySerial.available()){
      Serial.write(mySerial.read());
   }
}

Also, your code isn't very well formatted. Compare the code above with yours.


text:
How to drive motors and use an ultrasonic sensor simultaneously?
I have a L298 motor driver, which I coded with an Arduino Nano.
The code is very simple at the moment:
// connect motor controller pins to Arduino digital pins
// motor one
int enA = 10;
int in1 = 9;
int in2 = 8;
// motor two
int enB = 5;
int in3 = 7;
int in4 = 6;
void setup()
{
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void demoTwo()
{
  // this function will run the motors across the range of possible speeds
  // note that maximum speed is determined by the motor itself and the operating voltage
  // the PWM values sent by analogWrite() are fractions of the maximum speed possible
  // by your hardware
  // turn on motors
  Motors_FWD_PWM_Initialize();

  // accelerate from zero to maximum speed
  for (int i = 0; i < 256; i++)
  {
    analogWrite(enA, i);
    analogWrite(enB, i);
    delay(20);
  }
  // decelerate from maximum speed to zero
  for (int i = 255; i >= 0; --i)
  {
    analogWrite(enA, i);
    analogWrite(enB, i);
    delay(20);
  }
  // now turn off motors
  MotorsOff();
}
void loop()
{
  demoTwo();
  delay(1000);
}

void Motors_FWD_PWM_Initialize()
{
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
}

void MotorsOff()
{
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}

Currently I have two questions:
Q1: I have an ultrasonic sensor, how can I write the code so that the motors work and 'keep an eye out' with the ultrasonic sensor simultaneously? i.e. When a certain proximity is reached I would like the robot to stop.
Q2: Also I would like my robot to 'rove' around. How can I make it so? I was thinking having a number of subroutines, and making the arduino randomly choose one.

For the first question, you could simply implement an interrupt routine to regularly check the status of your sensor and when it achieves the desired threshold it triggers the action to stop the motor.
You can achieve this by setting timer1. There is a library here for example, where you set the period to execute a desired function, when some distance is detected you just stop the motors.
The second question could be done exactly like you said. Say you have some paths saved in memory, you can just create some options for them and execute whenever you want using switch/case command.
http://playground.arduino.cc/code/timer1

Nope. Not going to be that simple. Find someone or some project that has done it. Do not try to recreate the wheel yourself. Spend more time on google rather than here.
http://www.instructables.com/id/How-To-Make-an-Obstacle-Avoiding-Arduino-Robot/


text:
HC-06 Bluetooth RX & TX voltage (3v3 || 5v)
I acquired a HC-06 Bluetooth module, and understand that the voltage on the pins must be 3v3 and therefore requires the use of a voltage divider to lower the Arduino's 5v to 3v3 like this.

But the page where I purchased the product says the following:

interface level 3.3V, you can directly connect a variety of SCM (51, AVR, PIC, ARM, MSP430, etc.), 5V microcontroller can also be directly  connected, it can not pass without MAX232 MAX232!

Does this mean I can connect without using a voltage divider?
What does "it can not pass without MAX232 MAX232!" mean?

Some chips that run on 3.3v have 5v tolerant inputs. But it doesn't look like the BC417 does (looking at the datasheet).
So just add the voltage divider.

About the MAX232, I have a Dwengo (similar to Arduino) and to use the HC06 I have to disconnect the serial port(=RS232) else I short circuit my HC06.
After some googling, MAX232 is simply the name of that chip which is required to convert your TX/RX from your bluetooth module to something usable by Arduino.
Source: http://en.m.wikipedia.org/wiki/MAX232


text:
Arduino serial informations
Is it possible to change serial information of arduinos board ?
For example I have an arduino uno with this serial informations :
{
      comName: '/dev/cu.usbmodem1411',
      manufacturer: 'Arduino (www.arduino.cc)',
      serialNumber: '75430333137351804230',
      pnpId: '',
      locationId: '0x14100000',
      vendorId: '0x2341',
      productId: '0x0043'
}

I want to modify for example the manufacturer to be able to automatically detect the device whatever the comName is. I don't want to detect arduino board I want to detect arduino board modify by me without make a serial connection.

Have you purchased a vendor ID yet?

No didn't know that was possible... Where I can buy one ? How to use it after that ?

Once you have purchased a USB vendor ID you can edit the firmware within the Arduino installation at hardware/arduino/firmwares/atmegaxxu2/arduino-usbserial/ with your vendor ID, chosen product ID, and other USB parameters as you wish and then rebuild the firmware and upload it to the ATmega16U2 on the board via ISP.
If you do not wish to purchase a vendor ID for the time being then you can use 0x6666, the prototype vendor ID, in the meantime, but you are not allowed to make products using that vendor ID available to the public.


text:
WebCam Face detection and tracking tutorial with Arduino Uno R3 and OpenCV 3.0 RC1 in Ubuntu 14.04
I try to make this Arduino Open CV tutorial for webcams. OpenCV 3.0 RC1 is compiled and installed. I also use Code::Blocks 13.12 as IDE. I am a newbie what comes to OpenCV and I do not know too much about Arduino either but here I am learning. Arduino IDE is 1.7.2. The tutorial is made for Windows 7 and software for this OS but I bet it is possible to repeat this in Ubuntu Linux 14.04 also.
So the tutorial is here:
http://duino4projects.com/face-detection-and-tracking-with-arduino-and-opencv/
When I try to compile and run the techbitarFaceDetection.cpp
the Code::Block IDE gives me following error:

fatal error: Tserial.h: No such file or directory

So please tell me what to do next and how to fix this error.

TSerial.h is part of the Serial C++ Library that is used by the project that you are trying to build (see the section "Software Required" on the tutorial page you linked).
Make sure you have that library installed correctly.

Forget Tserial.h lib. To solve your problem (for serial communication) I sugest you to use "read/write from/to a file" programming method. The serial ports may be written to just like you are writing in a file. In the facedetect.cpp (OpenCV's example), in the detectAndDraw() function (I'm using OpenCV 3.0) add: unsigned char MSB[1] = {0}; //
    unsigned char LSB[1] = {0}; //
    char serialPortFilename[]="/dev/ttyACM0";
    FILE *serPort = fopen(serialPortFilename, "w"); //
than add:
LSB[0]=r->x & 0xff;//
    MSB[0]=(r->x >>8) & 0xff;//

    fwrite((const void*)MSB,sizeof(unsigned char),sizeof(MSB),serPort);//
fwrite((const void*)LSB,sizeof(unsigned char),sizeof(LSB),serPort);//

LSB[0]=r->y & 0xff;//
    MSB[0]=(r->y >>8) & 0xff;//

    fwrite((const void*)MSB,sizeof(unsigned char),sizeof(MSB),serPort);//
    fwrite((const void*)LSB,sizeof(unsigned char),sizeof(LSB),serPort);//

into the if (0.75 < aspect_ratio && aspect_ratio < 1.3) statement.
Finally don't forget to close the file
fclose(serPort);

Hope this will work for you!


text:
MOSFET to dim LED backlight
I have built the following to dim the brightness of the LED backlight of a display:

I am using a BS170 MOSFET (the diode is no extra part but included in the MOSFET, according to the datasheet). The BL pin is the supply of the LED backlight. (I have left out all other pins.)
Unfortunately, it does not work. Even if I set the PWM pin to 255, the backlight does not light (actually it's completely off). If I short BL and Vcc, it lights up as it should.
Also, the voltage readings confuse me: I measure 3.3 V on the gate and drain against ground, 1.5 V on source against ground (= the voltage across the backlight) but only 1 V if I measure drain against source.
So my questions are:

Shouldn't this add up to 3.3 V?
More importantly, why do I get only 1.5 V at BL?
Most importantly, what do I need to change? Different MOSFET? No MOSFET?

The primary aim of controlling the backlight is to be able to switch in off completely, thus reducing power consumption. (Being able to dim it is only a plus.)
EDIT
I should have added details about the display. It's one of those:

I haven't found a datasheet / specs for exactly this model. Most datasheets I found refer to a different version that is not 5 V compatible. A very similar model is described here.
Concerning my question I haven't found information on how much current the backlight would draw. Therefore I didn't want to drive it directly from the PWM pin. (Actually I could just measure it...)

Summary:
It looks as though you can just drive BL directly with the PWM-output.
What happens when you do?

Details:
(1)  As shown, even  if the circuit did what you wanted, all you would be doing is providing a rail to rail (0V to 3.3V ) signal to the BL pin. You can do this by connecting PWM-out to BL directly.
Does this work?
If the LCD and Arduino used differing power supplies the MOSFET may be useful.
(2) To use circuit almost as-is you need a PChannel FET.
Swap Drain and Source and it will provide PWM to the BL pin. When BL is high the FET is off. When BL is low the FET is on. The FET used must turn on with about 3V between gate and source.
(3) To use the N Channel BS170 you must drive the gate +ve above the source by an amount that is enough to just turn it one "plus a little more". This is called Vth (Vthreshold). The BS170 has Vth ~= 1.8V at low currents. Vth varies somewhat between samples. When you connect the gate to +3.3V the FET tried to turn on but as the source rises it reduced Vgs until it reaches about Vth. Raising the source above this level reduced Vgs to below Vth so the FET is not turned on.
ie this is what a=accounts for the 1.5V that you see as 3.3V - 1.8V = 1.5V.
To use the BS170,
connect the source to ground,
connect drain via a say 1k resistor to +3.3V,
connect drain to BL,
drive gate with PWM.
BUT why does not just driving BL with PWM do what you want?
A data sheet for the display would be useful.

Driving BL directly from the PWM might actually work, I will consider that. But what I was trying to learn is what I was doing wrong when using the BS170 like that, and you answered that nicely!

It turns out the backlight draws 4.5 mA @ 3.3 V. So I can get rid of the MOSFET altogether.

Since you are switching on the high side, you need a P-channel mosfet, not an N-channel like the BS170. (Or you need a higher voltage on the Gate to reach the VGS(th)).
I have a similar display, but mine will light up if BL is connected to ground. For these kind of displays you'd use a N-channel mosfet.


text:
Control external device using Java Web Servlet -> Pi -> Arduino -> Device
I'm new to the world of Arduino & PI, so far it's been a fantastic experience but I'm now looking to build something a bit more practical.
My plan is for the PI to host a JSP Servlet website.  I'd like to go to a certain page of this site: 'powerCycleDevice' for example where it would pass a parameter in '?=on' or something similar.  This would then be picked up by the Arduino which in turn would then power said device.
It's also be nice to just use it as a monitoring station.  If I have several Arduinos hooked up (and I plan to - think Wallace & Gromit :)) then it'd be nice to view the statistics of each of the sensors.
My problem is not knowing if a: it's possible (I'm certain it is) and b: where to start.
If anyone can lend any advice, hints or tips on where to get started it would be fantastic.  A noob guide or tutorial would be great as I'd then use the info and expand upon it.
Thanks in advance.

You can use Ardulink. It's a java open source project of mine. It can control an Arduino boad. So you have just to write a servlet that call my library. That's it.
See this post to understand how install ardulink in a PI: http://www.ardulink.org/how-to-install-arduino-pc-link-on-raspberry-pi/
You can read a sample code that sends some messages to Arduino you can read this post:
http://www.ardulink.org/how-to-blink-a-led/
The most important statement is Link link = Link.getDefaultInstance();
Link is the Ardulink class you need to send (and receive) messages.

That's fantastic, thank you. I'll have a look as soon as I'm able to


text:
Making a composite waveform using a single TIMER interrupt
I'm writing software for a laser tag gun, which under the system we use needs the output waveform to be a carrier wave of 57600Hz with a signal wave of 1800HZ for about 50ms
Using the Tone library (https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation) and a transistor AND gate, I've had this working using two timers, however I really want to shrink it down to one timer so that I can use the other for sound (using the TMRPCM library which only needs timer1).
I've modified the Tone library cut down to what I need, with the following methods:
void TagTone::beginPulse(uint8_t tonePin)
{
    _pin = tonePin;
    _timer = 2;

    // 8 bit timer
    TCCR2A = 0;
    TCCR2B = 0;
    bitWrite(TCCR2A, WGM21, 1);
    bitWrite(TCCR2B, CS20, 1);
    timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
    timer2_pin_mask = digitalPinToBitMask(_pin);

    int duration = 50; //50 milliseconds
    uint8_t prescalarbits = 0b001;
    int32_t signal_toggle_count = 0;

    // Note: may need prescaler reimplemented if using 16Mhz, fine on current 8Mhz
    ocr = F_CPU / (CARRIER_FREQUENCY * 2) - 1;
    prescalarbits = 0b001;

    TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;

    toggle_count = 2 * CARRIER_FREQUENCY * duration / 1000; // how many times the carrier toggles before pulse ends

    // want to AND with 1800 Hz signal

    // as duration now set to 50: toggle_count for carrier = 5760
    // equivalent toggle count for signal = 180
    signal_toggle_count = 2* SIGNAL_FREQUENCY * duration / 1000;

    // want to flip signal state every 32 carrier pulses
    signal_cycle_count = 32; //toggle_count / signal_toggle_count;
}

// duration (in milliseconds).

void TagTone::playPulse()
{

    OCR2A = ocr;
    timer2_signal_toggle_count = signal_cycle_count;
    timer2_toggle_count = toggle_count;
    bitWrite(TIMSK2, OCIE2A, 1);

}

ISR(TIMER2_COMPA_vect)
{
    if(timer2_toggle_count  < 0)
    {
        *timer2_pin_port ^= timer2_pin_mask & signal_state; // flip

        if (timer2_signal_toggle_count > 0)
        {
          timer2_signal_toggle_count--;
        }
        else
        {
            signal_state ^= signal_state;
            timer2_toggle_count -= timer2_signal_toggle_count;
            timer2_signal_toggle_count = signal_cycle_count;
        }
    }
    else
    {
        TIMSK2 &= ~(1 << OCIE2A);                 // disable the interrupt
        *timer2_pin_port &= ~(timer2_pin_mask);   // keep pin low after stop
    }
}

What I hope this is doing is 32 toggles at the carrier speed (ie 16 full cycles of 57600Hz), followed by 32 'silent' toggles where nothing happens, followed by another 32 at carrier speed, etc.  I should then be able to fire using:
digitalWrite(signalPin, HIGH);
carrierTone.playPulse();
delay(60);
digitalWrite(signalPin, LOW);

But that doesn't set off the sensor, whereas the simple code below works.
carrierTone.play(57600, 50);
signalTone.play(1800, 50);

Woo, solved it.  My ISR code was completely wrong.  Works using:
ISR(TIMER2_COMPA_vect)
{
  if (timer2_signal_toggle_count != 0)
  {
    // toggle the pin
    if(signal_state == 1)
        *timer2_pin_port ^= timer2_pin_mask;

    if (timer2_toggle_count > 0)
      timer2_toggle_count--;
    else
    {
        TIMSK2 &= ~(1 << OCIE2A);                 // disable the interrupt
        *timer2_pin_port &= ~(timer2_pin_mask);   // keep pin low after stop
    }
     timer2_signal_toggle_count --;
  }
  else
  {
    timer2_signal_toggle_count = signal_cycle_count;
    timer2_toggle_count --;
    if(signal_state == 1)
    {
        signal_state = 0;
        *timer2_pin_port &= ~(timer2_pin_mask);
        //*timer2_pin_port ^= timer2_pin_mask;
    }
    else
    {
        signal_state = 1;
        *timer2_pin_port ^= timer2_pin_mask;
    }
  }
}

I was trying to just AND the signal state into the original pin state, which was completely the wrong thing to do.


text:
Arduino uno r3 not powering up
i bought two arduino uno r3 card (not original)
one is working perfectly:

the other is not powering up (no led is lit), i did some measuring and i found that two usb connector pins on the board are shorted, how can i proceed to repair it taking in account that it works from time to time !

thank you
More images:

Use a De-Solder and remove the solder that is shorting the two USB connector pins.

hi mathsman, there is no solder between the pins, i guess it's one of the electronic component of the board that is causing the two pins to short, but the problem is how to identify it

Is there any connection in the PCB itself?

yes, on of the pins is connected to ground

No, not that, I meant that is there a connection between the shorted USB pins on the PCB itself?

Check the board under a loop/microscope, to see if any components or connection look off. A short between 5v and GND is pretty difficult to detect. You can check the resistance on different location, and see if it's slightly lower/higher. The lower the resistance, the closer you are to the faulty component. But for that you'd need a high precision multimeter. My first guess is the electrolytic capacitor, but that's just a wild guess. Could you post a hi-res photo of the defective board?

If not, it is really difficult to do anything as almost all components in your board are surface mounted.

Hi @Gerben I don't suppose that everyone has a Microscope or Very High Resolution Cameras . Instead , a magnifying glass is much better.

ok i'll upload more photos in a few seconds

Take pictures with a Magnifying glass If you have no High Resolution Cameras.

Sorry. I meant loupe, not loop

no problem sir, i added two photos,
http://s23.postimg.org/y8o4fj9mz/SAM_1432.jpg

http://s11.postimg.org/6ukiv3khf/SAM_1434.jpg
the photos in the post are resized, check the direct link for full size photos
thanks

I see nothing that's obviously wrong. Can you be more specific about "works from time to time"? What happens if you power it from the Jack (only test for a few seconds, as there is no polyfuse, like there is on the USB)?

the first time i connected it it worked for a few seconds then went off, after disconnecting and reconnecting it a few times it worked again, i programmed it and everything was fine, and now it won't work again, thats what i meant by from time to time, for the jack it's the samething as the usb port, i plugged a 9v battery to it and it didn't work

oh man, it's working again right now, this is confusing
http://s30.postimg.org/aesf9tvgx/work.jpg

It looks as though there may be material between at least one USB pin and the ground layer. This may be flux of solder 'splash'.
If visual inspection shows that this may be the case I would try carefully scratching with a sharp poibt (eg scriber) along at least the green arc on the image below. Be careful not to break intended conduction paths (eg as shown in black).

Since it's intermittent I'd try two things:
Easy: Briefly reheat each pin of the USB connector and it's pad, the goal being to make sure the solder joints are solid. Clean away any solder bridging the pads. Of course you can only reach the back side of the board, but this is an easy first step.
More thorough: If the first step didn't get it working, then try desoldering the USB connector, using a solder pump and desoldering braid to remove as much of the solder as possible from all four pins before you try to actually remove the part. Work slowly giving it time to cool between steps so you don't overheat anything. When the part is removed, inspect the top of the board and clean up any solder bridges. Inspect the bottom of the USB connector where it touches the board and clean it, too, if necessary. Then solder it onto the board again using as little solder as necessary to make solid connections.

i'm going to desolder the usb connector because i'm pretty sure it is the source of the problem, when i partially plug the usb cable it works. thanks

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


text:
Picking an Arduino
I'm looking to develop my own personal SmartWatch, hardware, software, and all. My problem is starting off on the hardware portion of it; more specifically what platform I should build it on. I already have an Arduino Uno (R3), nut I was hoping to find something a bit smaller. Any recommendations on what parts I should use?

Asking for purchasing recommendations is somewhat off-topic. You could always use the "raw" Atmega328P chip. That is smaller than the Uno.

What you start with is not too critical as you can develop basic concepts on any Arduino hardware and use it to drive a display of your choice for testing. This can be migrated to whatever is found suitable as the project progresses.
Important to consider are the number of I/O lines of various sorts that you need. Most AVR ICs that you are liable top use will have "some" analog input and PWM output lines. If you were going to drive a "bare" LCD you may need to use a processor with LCD drivers, but in  most designs use of an existing module with eg SPI interface is probable preferable.
Most Arduinos in the UNO, Nano, Pro Mini, ... range are in reality not a lot more functionally that a processor IC, USB bridge (if needed) and voltage regulator(s). For a tidily small watch you may ultimately wish to use a bare SMD AVR IC with an Arduino boot loader code installed. You can move away from AVR ICs to other Arduino compatible systems - with some extra knowledge needed in most cases.
.____________________________________________________
Examples only:
Here is an Internet of things hardware roundup which includes some small controllers as examples.
Panstamps offer MSP430 and ATMega328p (Arduino compatible versions).

. _______________________________________________
RFDuino - from here offer some fingertip sized products with RF capability. Note that this use an ARM Cortex M0 processor, not an ATMega controller. While it is "Arduino compatible" it will not run all code that the typical UNO, Nano, ... boards run.
Manual here

Their Kickstarter page

Why not start with your Arduino Uno, it's got lots of I/O pins, and it's a great little device to start prototyping your watch.
You could add a number of sensors/peripherals such as

a Bluetooth module, - connect your phone
an IMU, - detect different excercises from your wrist movement
a tiny motor - to make the watch vibrate
a speaker for audible notifications
tactile buttons for switch between modes and functions of the watch
a LCD screen, - to see the time and other data
maybe a few LEDs as a torch function.

Once you develop your code and your happy with it, you could shrink your board accordingly, because you will then know how much I/O pins you'll need, and what voltage these sensors need to operate, and their inputs (analog vs. digital). You could even design your own PCB board with all these sensors.
You could use the Uno as a stepping stone.

One Possibility is that you could just use an avr chip without the arduino breakout, but still include the arduino bootloader, and this way it would be easier for you to isolate your preferred features, however with this method you would be sacrificing some safety without short circuit protection, and it would be a bit more work to upload, but this is also the cheapest.

Possibly related: https://create.arduino.cc/projecthub/Sourcery/smallest-arduino-in-an-attiny85-6f714d

Have a look at the LilyPad (Main Board, USB, Simple) and Gemma. The Gemma may have too few I/O pins for your needs, but it really does look small.

I have quite a few nanos / mini pros that I got as plain avr boards. they are great little things.
I also got a few minimus avr - if you want to venture outside of arduino. like the at90 usb stick / key, they are little boards that are 100% self-contained. they are ideal to play with on long flights.


text:
Yun - FileSystem.Open prevents client.println from outputting to web page
The below code is meant to display lines stored in a text file to an arduino based web page (it's a IR gate monitoring solution).
When I visit
I can execute client.println("hello") and I see the word "hello" on the page.
Then I loop round the SD card rows and I can Serial.print (by char) in the Serial Monitor all the lines in the text file. Great - so far so good.
But when I attempt to print to screen (instead of Serial Monitor) it does not work.  The offending line (but don't know why) is the FileSystem.Open - this prevents any further output to screen.
Why does FileSystem.Open prevent client.print from working?

  void loop() {

  YunClient client = server.accept();

  if (client) {
    String command = client.readString();
    command.trim();
    Serial.println(command);

    if (command == "today")
    {
        //client.println("hello");

        // Get a timestamp
        String strTS = getTimeStamp();
        String strFileName = strTS;

        // Build the file name containing the
        strFileName.replace("-", "_");
        strFileName.replace("/", "-");
        strFileName.replace(":", "-");
        strFileName = strFileName.substring(0, 8);
        strFileName = "/mnt/sd/BeerLogger/" + strFileName + ".txt";

        // Display the file name in the serial window
      //  Serial.println((strFileName).c_str());

        // Print the contents of the text file to screen
        File myFile = FileSystem.open(strFileName.c_str(), FILE_READ);

        if (myFile) {
           while (myFile.available()) {
              char c = myFile.read();
              if ( c == '\n') {
                //client.println("");
              }
              Serial.print(c);
              client.print(c);
          }
          myFile.close();
      }
    }

    // Terminate the client connection so we may resume
    client.stop();
    //Serial.println("client disconnected");

  } else {
      MonitorIRGate();
  }
}


text:
Transistor for DC motor and 9v
I have this schematic for a DC motor in my arduino, now I want to add 9v battery.
But I've seen that people use TIP120 transistor, I have BC548B,
can I just put the 9v with that transistor?

What are the ratings of your motor, or do you have a datasheet for. otherwise, connect to 9V directly and measure the current draw and add give that info too.

The datasheet says 30 volt is the maximum.

@Gerben the transistor is max 100mA this is surely not good for a motor?

That's the maximum. Just like you can put a 5w light bulb in the same socket as a 100w light bulb. The motor will use the amount of current it needs, even thought there might be more current available.

@Gerben and if the motor draws too much, poof, white smoke and fun :) The OP never stated a motor type. The OPs circuit is what they want to do(from what I can tell, with Vin as source), although if the motor ran on 5V it is possibly a low current then, but you could max the draw if the thing stalls or is under load. With a 5W you might not see much though.

If you use PWM, be sure to use a Transistor(preferably a MOSFET) that has max voltage 3times the supply voltage and a flyback diode.Also, measure the current drawn by the motor when connected directly to 9V supply.The max current rating of the transistor used should be approx 2 times the current drawn by the motor(in the prev test).

There are many circuits using the TIP120 NPN transistor because it is a darlington transistor. This is used because its max voltage is 60V and the max current is 5A, this means you can control a variety of external high current devices with low voltage circuitry because of the darlington arrangement.
You can use the BC548B with your motor(low current) and a 9V battery as it does handle 30V, but it is limited to 100mA, which is fine for tiny low current motors. But these are actually Amplifier transistors, so there main design area is not for inductive loads.
I recommend the TIP120 as this will ensure that you don't trash a transistor with current spikes as you could easily go over the 100mA spec of the BC548.

Firstly, I see no external power supply in your schematic.
Secondly, you certainly CANNOT use a BC548 for controlling a motor.
MOSFETS are the best.

If you use PWM, be sure to use a Transistor(preferably a MOSFET) that has max voltage 3times the supply voltage and a flyback diode.Also, measure the current drawn by the motor when connected directly to 9V supply.The max current rating of the transistor used should be approx 2 times the current drawn by the motor(in the prev test).


text:
How to read temperature using arduino uno board with PT100 RTD sensor?
I am new to arduino programming. And almost inexperienced.
I am looking to program my arduino Uno board to read 2/3/4 wire configuration of PT100 RTD sensor (in accuracy levels of atleast 0.5°C). The temperature range is 0 to 400°C and -50 to 100°C.
Since I am totally new to this field I would appreciate a rather descriptive information with circuits and images and code.
I have researched a lot on the subject, but couldn't get anything useful or substantial to solve my problem.
Moreover, I cannot use thermistor or any IC to read the temperatures as the machine on which the RTD is installed has PIDs, but I would like to create a datalogger that can fetch temperatures on computer itself.

You can get ICs which can be used for these sensors, wouldn't that be easier?

I am unable to use ICs as already we are using RTDs with PID controllers to control the temperature. I have to use these existing RTDs to get the temperature readings otherwise there might be variation in the temperature readings of RTD and IC. Moreover, we have applications where we require temperature readings of about 400°C with an accuracy of +/- 0.5°C. I doubt that there exists any ICs that can handle such precision and temperature range.

how are the RTDs connected then at the moment

A MAX31865 can handle -200°C to 500°C. Are you concerned about the IC being exposed to temperatures?

Actually, the RTDs are installed on a cable extruder having holes to insert the RTD into them. The temperature currently are being read through PID controllers. And yes I am concerned about having the IC damaged. Moreover, how am I supposed to insert the ICs in those tiny holes in the extruder barrel?

I'd llike to clear up a slight misunderstanding: The PT100 RTD is the SENSOR and the MAX31865 is the SENSOR AMPLIFIER, SIGNAL CONDITIONER and A/D CONVERTER. As such, the MAX31865 is NOT subjected to extreme temperaturas as it is NOT the sensor. HTH.

No need to shout. I was actually pointing out the range that the IC works with, i.e. the resistive output of the RTD. The operating is -65  to 150, in my comments I never stated it was the operating temperature. Also make a worth while contribution to the forum and give answers or ask questions so you can get rep to comment rather than put up useless answers like this.