text:
Changing parameters of pulseIn() to sense different materials
I have a ultrasonic sensor and in order to get the distance I use the pulseIn() function included in the arduino library, and then change it to distance. As the ultrasounds does not work equally in different materials as i have seen in Performance comparison of Infrared and Ultrasonic sensors for
obstacles of different materials in vehicle/ robot navigation
applications. My question is if there is a way of changing the pulseIn() to have different materials, function:
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
{
    // cache the port and bit of the pin in order to speed up the
    // pulse width measuring loop and achieve finer resolution.  calling
    // digitalRead() instead yields much coarser resolution.
    uint8_t bit = digitalPinToBitMask(pin);
    uint8_t port = digitalPinToPort(pin);
    uint8_t stateMask = (state ? bit : 0);

    // convert the timeout from microseconds to a number of times through
    // the initial loop; it takes approximately 16 clock cycles per iteration
    unsigned long maxloops = microsecondsToClockCycles(timeout)/16;

    unsigned long width = countPulseASM(portInputRegister(port), bit, stateMask, maxloops);

    // prevent clockCyclesToMicroseconds to return bogus values if countPulseASM timed out
    if (width)
        return clockCyclesToMicroseconds(width * 16 + 16);
    else
        return 0;
}

or the countPulseASM, which I translate from the asembled code, which can have some errors) as:
// wait for any previous pulse to end
while ((*port & bit) == stateMask)
{
        if (--maxloops == 0)
        {
           return 0;
        }
}

// wait for the pulse to start
 while ((*port & bit) != stateMask)
{
    if (--maxloops == 0)
    {
       return 0;
    }
}

// wait for the pulse to stop
 while ((*port & bit) == stateMask)
 {
    if (++width == maxloops)
    {
        return 0;
    }
 }
return width;

Another way of doing that is having a correction factor while changing the time into the distance, but for that I shold have the differences of all the materials.

pulseIn just returns the length of a pulse on a pin. That has nothing to do with materials and can have no concept of materials. It is just time. You cannot change time just to suit different materials.
Instead if you want to calculate the distance depending on different materials you need the actual time of the pulse to then calculate the distance in different ways.
That is down to your sketch to do that calculation using the time provided by pulseIn and your own adjustment values.


text:
How can i stop a loop after 1 minute?
This is my first Arduino project, and I would like to stop my servo's loop after 1 minute. Can someone help me?
#include <Servo.h>
Servo myservo;

void setup()
{
  myservo.attach(5);
}

void loop()
{
  myservo.write(45);
  delay(1000);
  myservo.write(125);
  delay(1000);
}

Thanks!

You are asking the wrong question. The loop function runs forever. How many times do you want the servo to move between those values? If that is for example 30 times, then you can put a for-statement in the setup function and use a empty loop function.

what do you do when you want to boil eggs for one minute? .... do the same in the program

Thank you so much!!!! that was exactly what i needed!! i also tried before to run a servo and a stepper at the same time and that was exactly what happened the stepper was blocking the servo and i wasn't understanding why!! thank you so much for the explanation, it truly helped!!

Whose explanation are you thanking? The answer boxes are not for comments, I'll migrate your answer to a comment under your question. I'm glad one of us helped you. :)

As suggested by Jot in a comment, one way would be to simply do what you want (which takes roughly two seconds per iteration) in a loop, like this:
#include <Servo.h>
Servo myservo;

void setup()
{
  myservo.attach(5);

  for (int i = 0; i < 30; i++)
    {
    myservo.write(45);
    delay(1000);
    myservo.write(125);
    delay(1000);
    }
}

void loop()
{
}

The problem with that is it relies upon knowing how long your delays are, and assumes that the myservo.write() functions take no time. A better method is:
#include <Servo.h>
Servo myservo;

void setup()
{
  myservo.attach(5);

  unsigned long start = millis ();

  while (millis () - start <= 60000)  // for 60 seconds
    {
    myservo.write(45);
    delay(1000);
    myservo.write(125);
    delay(1000);
    }
}

void loop()
{
}

This uses the millis() function call to find out how much time has elapsed, and wait for 60000 milliseconds (60 seconds).

I've put the code into setup because that is where you put things you want done once.

To answer your question as asked, add this to loop():
if (millis() >= 60000) exit(0);

However, I would suggest you seriously consider Jot's comment: simply
stopping loop() from running is most of the time not what you may
want to do.

Another way to handle this is to use a variable endTime to tell the loop when to stop moving the servo:
unsigned long endTime;

void setup()
{
  myservo.attach(5);
  endTime = millis() + 60000;
}

void loop()
{
  if (millis() <= endTime) {
    myservo.write(45);
    delay(1000);
    myservo.write(125);
    delay(1000);
  } else {
    //code to run once the servo is done running
  }
}

This code will move the servo back and forth for about 1 minute, then stop. It's set up so you can do something else once the loop has completed.
Note that by using a variable endTime and leaving your servo code in the loop() function, you can have your program start doing something else once the motor motion is completed. You can also add code to set up a new value in EndTime, at which point the servo will start moving back and forth again.
Also note that using delay is bad practice. When you do that you bring the arduino to a full stop while the delay code is running. You can't be doing something else. Say, for example, you wanted to move 2 different servos at different time intervals.
Instead of using delays you should track the end time for each phase of your loop, and execute your code once that end time passes.

This code will move the servo for one minute every 49.7 days.

Yeah, I suppose that's true, if you Arduino plugged in that long. (I mostly work on 64 bit platforms now, where an unsigned long is 64 bits, long enough that the above code would only run once in my or my grandchildren's lifetime.) It would be pretty easy to add a bool to the code above to turn it off completely when not in use.

source: Stack Exchange

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

sort: votes


text:
Arduino to check if digital connected to analog
Is it possible to check if a Analog pin is touching a digital?
I have an Arduino Uno, and I want to have a small matrix, A0 A1 A2 A3 (all have rows of 6 buttons)
All the 6 buttons are connected to the digital pins
This is how I want it to work
Digital (1,2,3,4,5,6)
(A0)1,2,3,4,5,6
(A1)1,2,3,4,5,6
(A2)1,2,3,4,5,6
(A3)1,2,3,4,5,6

I've tried writing code but for each key pressed it gives the same value for each row i.e it's not detecting different sections.

https://playground.arduino.cc/code/keypad

please post your code so that we can check for errors

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


text:
Arduino hangs after some time
I am using Atmega328p with 5V power supply,
My Arduino getting hangs [or auto restarts] after some times.
I am using libraries:

Wire.h
CRC32.h
EEPROM.h
Arduino.h
TimerOne.h
RtcDS3231.h
SoftwareSerial.h
Adafruit_NeoPixel.h
avr/wdt.h

I have tried to search, some people are deny to use software serial library.

it's possibly some error in your code

This is my code, can you guide me...
https://github.com/savaliyadnk/arduinoswitch

don't use String. use C strings (zero terminated char array) https://majenko.co.uk/blog/evils-arduino-strings

That is only a minimal circuit in theory. Can you show us a photo? We like to see where the decoupling capacitors are and how close the crystal with the 22pF capacitors to the atmega328p is.

Do you have 100nF connected to aref and vcc? It should be to gnd. All gnd and all vcc should be connected to the power. All of them. You have no decoupling capacitors. They are not an optional extra according to this page: http://www.gammon.com.au/bootloader

Not sure if this will fix your problem, but this is a major error:
  char buf1[8], buf2[6];
  sprintf(buf1, "%08lu", myvote.mydate);
  sprintf(buf2, "%06lu", myvote.mytime);

Take a look at sprintf function reference

A terminating null character is automatically appended after the content.

So, the text buffers are too small. It should be at least:
char buf1[9], buf2[7];


text:
What is mean of 700,150 number?
 if ((leftsensor >= 700) && (rightsensor >= 700))
   forward();
       else if((leftsensor <= 150) && (rightsensor <= 150))
   backward();
   else if((leftsensor <= 150) && (rightsensor >= 700))
   turnright();
   else if((leftsensor >= 700) && (rightsensor <= 150))
   turnleft();

The mean of 700 and 150 is 425. Or are you asking what they represent? They are some arbitrary threshold value that some sensor reading is being compared against.

A analogRead() value is between 0 and 1023. By looking at only that code we can only see that 700 and 150 are thresholds for steering a vehicle; a line-following robot?

As mentioned the mean of 700 and 150 is 425. What does this have to do with your code? Please be more clear about your scenario

those are you "shoulder" readings, while values between them are basically "dead space" (in joystick terms)

I have somewhat large experience in understanding people that use "bad" english as their secondary language. That's why I assume that even though the question you asked was "What is mean of 700,150 number?" the question you wanted to ask is "What is meaning of numbers 700,150 in code below?"
This was already answered by @MaximilianGerhardt in the comments.
If we assume that leftsensoris an integer value coming from analogRead then it's possible values are between 0 and 1023. The programmed created two arbitrary thresholds of values 700 and 150. Those values were probably calculated experimentally to negate signal noise, sensor imperfections and interference.


text:
How to read Output data from SPI connector using Arduino Uno?
I am having main controller circuit board that give the data such as ("HAI", "HELLO") to 5 pin SPI Connector mounted on the same board. In that 5 pin SPI connector  I could  connect separate circuit board which has SPI based 5 SEVEN segment LED  to see the output for e.g. ("HAI", "HELLO").
Pin configuration for 5 pin SPI connector on main circuit board.

Pin 1 -  VCC
Pin 2 -  GND
Pin 3 - CS (chip selection)
Pin 4 - CLK (clock)
Pin 5 - D IN (Data).

Everything working fine and also I can see the output data on the SEVEN-segment display such as "HAI" and "HELLO" through my naked eye.
But I need the same data to display in my PC/Laptop console so I used Arduino uno controller setup.
So I did connecting wire from Arduino controller to 5 pin connector of main controller circuit board.
Connections below.
Arduino controller                 Main controller ckt board
(Digital pins)                      (5 Pin connector)
PIN 7 (D IN) --------------------------->   PIN 5 (D IN)
PIN 6 (CS)   --------------------------->   PIN 3 (CS)
PIN 5 (CLK)  --------------------------->   PIN 4  (CLK)

I connected USB cable to my PC and I installed arduino driver and also configured COM PORT (COM5 my-case).
I opened  Hyper-terminal console in that I chosen COM5 and baud rate 9600. But still I did not get the output ("HELLO", "HAI")
on the console because the Arduino controller does not have source code for reading the output string("HELLO", "HAI") from the 5-pin SPI connector on main ckt controller board.
What I need exactly?

I need a source code that for reading the output from 5 pin connector through SPI and should display on my console.

Can anyone share the full source code for do that above operation ?

first wire it to SPI pis of Uno. then use SPI library in slave mode. the device will send  not only the text. it is possible it will send only the segment addresses with states

Need to start with the correct pins.
With Uno, SCK is 13, MISO is 12, MOSI is 11, and typically 10 is used for slave select.
To read from a slave device, some setup is needed, then the command is run. Here's a very simple example:
byte ssPin = 10;
byte incomingByte;
byte addressToRead = 0x00; // or what is needed, if needed.

void setup(){
Serial.begin(9600);
pinMode (ssPin, OUTPUT);
digitalWrite (ssPin, HIGH); // most devices expect a LOW for slave select
// the code in behind SPI.transfer may do this already, I put it in anyway as
// sometimes I use different pins.  10 needs to be an output for the
// Atmega to be the SPI bus master

SPI.begin(); // uses default values: SCK of 4 MHz, MSBFIRST, Mode 0 for
//              initial signal levels
}

void loop(){
digitalWrite (ssPin, LOW); // select the device
SPI.transfer (addressToRead); // may be needed for your device
incomingByte = SPI.transfer(0); // read a byte from the slave
digitalWrite (ssPin, HIGH); // deselect the device

Serial.print(incomingByte); // may need some manipulation to make this
//                             a printable character - see
//                             www.asciitable.com
delay(500); // keep from flooding the PC screeen
}


text:
Atmega 32U4 doesn't show on device manager after fuse bits reset
I am finally ready to try setting fuse bits on my ATMega32u4-AU custom board (8Mhz Ceramic Resonators, 3.3V), however, after I set the fuse bits and plug my board to computer, the device manager appears nothing (seems there is no device been connected). I am not sure which step I did wrong, so I’d like to post the details, please kindly point out my mistake, thanks a lot!

I used Fuse High Byte: 1001 1001 (0x99) Fuse Low Byte: 0101 1110 (0x5E) Extended Fuse Byte: 1111 0011 (0XF3)
This is the command I entered into avrdude: avrdude –b 19200 –c usbasp –p m32u4 –v –e –U efuse:w:0XF3:m –U hfuse:w:0x99:m –U lfuse:w:0x5E:m
I am able to see the result from command
But after setting the fuse, when I read the fuse in avrdude, I dont know what the reason is but I got different efuse data

After all of these steps, I connected my board to windows 10 computer, the computer shows nothing...
Someone online told me that it could because the clock divider get changed. So, I added a step of setting lock bit to 0x2C through typing “avrdude –b 19200 –c usbasp –p m32u4 –v –e –U lock:w:0X2C:m” But it didn't fix the preblem.
Later, I was thinking maybe I set the low fuse wrong, because the bit0..3 (1110) in lfuse means "Low Power Crystal Oscillator"; So, I set bit0..3 to (1010) and CKDIV8 to 1, which means "Low Frequency Crystal Oscillator" and "unprogrammed divide clock".
All of these didn't fix the problem, please kindly point out which step I did wrong, your help would be greatly appreciated.

Do you have software installed on the chip that even tries to be a USB device? The chip isn't magically a USB device until you program it to be a USB device.

C3 and F3 are the same, as only the last 4 bits in the e-fuse are actually used, and those are both 3. I'd try re-programming the bootloader. Perhaps changing the fuses, erased the flash.

Thanks for answer. I don't have the software installed on the chip to make it be a USB device... So, which softeare do you recommend?


text:
How to detect lipo battery % charge left?
I am currently working with a few robotic projects where i use lipo batteries. Currently I am working with a 1500 mah 3s lipo.
With my current setup I am using a arduino uno and a power distribution board. I put my lipo charger in my power distribution board which has two connections where I put two cables that goes to the VLN and GND.
(If needed I can make a quick schematic to explain it better!)
How can I now see the current battery percentage of the lipo?
I came across a project that uses this codesnippet:
long previousMillis = 0;

long interval = 1000;

int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);

unsigned long currentMillis = millis();

if (currentMillis - previousMillis > interval) {
  previousMillis = currentMillis;
 if (voltage <= 3.5)
      Serial.println("Low Battery");
     else
      Serial.println(voltage, DEC);
}

This snippet works with the A0 and I do not have anything connected there so I assume not.
Appreciate every help! :)

Typically LIPOs have 3.7v at full charge. This code monitors the LIPO voltage and flags the battery as "low" if the voltage drops below 3.5v.

@Mazaryk 3.7V is the nominal voltage for regular lithium batteries. 4.20-4.35 Volt when fully charged. However  lithium-iron-phosphate batteries do have a full charge at around 3.7 V.

@Gerben, You are right. I meant to say "discharge". :)

LiPo batteries do not work well for percentage of charge remaining when using voltage as a reference. Lithium chemistry batteries hold a voltage quite close to level up to the point of near-exhaustion. That is to say, you can deplete such a battery by 80%, leaving only 20% capacity and have a few tenths of a volt reduction, depending on the configuration of your battery pack.
Unfortunately, should you continue to deplete the battery, damage may result. Some will say that damage WILL result.
The only certain way to determine a battery capacity is to use a smart charger and/or a smart discharger (often combined into one) to profile a battery.
For example, I have a 2000 mAh battery. After a few conditioning runs, either in use or on the smart dis/charger, the battery shows as having 1600 mAh capacity to 80% discharge.
Using a device to monitor the discharge rate, one can determine that if one uses 1550 mAh of the capacity, one is quite close to the risky cut-off point.
To continue discharging, there is risk involved in the lifespan of the battery.
LiPo batteries will have greater than 4 volts reading immediately off the charger and will "flatten" to optimum voltage in a short time and hold very close to that level, depending on the current load, until it virtually vanishes at the cut-off point.
One can approximate a safe voltage for the cut-off point, but one risks the chance of an inaccurate volt meter. Collecting ampere-hours as a reference for cut-off is the most accurate method and also allows more capacity with less chance of damage.

Characterize a few such batteries by putting them through a charge / discharge cycles so you can link their voltage with remaining capacity.

The data sheet for the battery might already contain a nice discharge curve.

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

authors: Дионисий Козлов

authors: Сергей Поздеев


text:
Why is the BLE device not starting on my Arduino Pro Mini?
I recently purchased a 5V arduino pro mini that I now wish to connect to a BLE device.
I firstly tried the BLE device with my Uno board and it worked very well! However when I now try to use it on my mini it does not start.
This is my wiring:
First I connect the pro mini to the uno in order to upload the code looking like this:

Arduino Mini Pro to Arduino Uno
RX --> TX
TX --> RX
VCC --> 5v
GND --> GND
RST --> RST

Then I wire the mini to my BLE device (https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout/hooking-everything-up):

Arduino Mini Pro to BLE nRF8001
13 --> SCK
12 --> MISO
11 --> MOSI
10 --> REQ
9 --> RST
2 --> RDY
GND --> GND
VCC --> VIN

When I connect this setup to the computer the arduino uno starts and also the pro mini (both has LED lights on). I upload a simple test code that worked when i tried it with the uno but the BLE device does not respond (it seems like it does not turn on) when i use it with the pro mini.
Any idea what might be wrong? I have my board put as: Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz).
Thanks a ton!! :)

This is my wiring: First I connect the pro mini to the uno in order to upload the code looking like this:

Arduino Mini Pro to Arduino Uno

RX --> TX
TX --> RX
VCC --> 5v
GND --> GND
RST --> RST

How would this work? The bootloader in the Uno and Mini Pro will both try to reply. You need a FTDI or a USB-to-UART module instead of the Uno. Alternatively, start by programming the Uno to act as a USB-to-UART converter using Serial and SoftwareSerial.
Cheers!

I saw the connection from this thread: http://www.instructables.com/id/SpeechVoice-Controlled-Arduino-Drone/?ALLSTEPS Check under "Step 1". I also found this thread that has similiar connection: http://www.instructables.com/id/Uploading-sketch-to-Arduino-Pro-Mini-using-Arduino/?ALLSTEPS

But maybe it will not work to use the Uno as a "code-uploader". I have this at home also: https://www.youtube.com/watch?v=59VHCXNxSvQ Check minute 1.56. I have the red one. Would that work with the Pro mini?

The second link is fine. The MCU on the Arduino Uno is removed and the board is used as a USB-to-UART. The first link is an SMD AVR MCU and the trick might be the 3.3V setting. The Mini Pro is using 5V.

Ah ok. I do not have a big MCU/Atmel on my current arduino (i got a chinese copy) and i assume it will be hard to remove it. Did you see the youtube-video, do you think that could work with the pro mini to upload code? It has GND, RXD, TXD and VDD pins

Use a simple software serial read/write though sketch on the Uno as I suggested. https://www.arduino.cc/en/Tutorial/SoftwareSerialExample

Yeah could do that but I would prefer to use the USB if it works. When I connect it to my pro mini both light up when i insert the usb to the computer.  Seem to have a little bit of a problem to upload code though

Looking at the schematics for the Uno it might be possible to force the MCU to disconnect by putting RST to GND. The issue is then to get the signal from the USB MCU to the Mini Pro. Alternatively a manual RST signal for the Mini Pro before upload. This depends on your Chinese copy. Would need the schematics or picture of the board to determine that.

Picture: http://imgur.com/a/cQj1w where you can see my Uno, Mini pro, FTDI module and also another FTDI module CALLED Crius. it says 3.3V and 5V on the back of it with the pins: GND, CTS, VCC, TXO, RXI, DTR

Use the blue FTDI module marked FTDI TOOL. It is made to plug into the Mini Pro directly! Check the pin marking. Why use the Uno? You have perfect tools for the job!

I actually just find it hidden in my box when I went to get a few more cables! Terrific :) Thanks a lot for all your help!

When it comes to board-settings, should I still use Arduino Pro Mini?

Yes, the Arduino IDE setting should be the target board. In this case the Pro Mini. Check frequency (8 or 16 MHz) and voltage (3.3V or 5V).

Actually you connect the Bluetooth module and connect it so that you can upload over Bluetooth. Google will help you find info about that :)

The ftdi tool indeed works very well! I just spent 2 hours finding the correct driver for it but finally got it working

Nice! Here are three links if you want to upload over the Bluetooth module; https://create.arduino.cc/projecthub/YoussefSabaa/arduino-bluetooth-programming-shield-wireless-upload-code-1a397c,  https://sites.google.com/site/wayneholder/inexpensively-program-your-arduino-via-bluetooth and simplest https://www.itead.cc/blog/upload-program-to-arduino-with-bt-shield

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


text:
How can I split a string into three parts after space and turn the values to doubles?
I am currently gathering info from a BLE device. I made a thread earlier where I successfully split a string consisting of 5 letters to their unique chars.
However from this BLE device i will also send some different information from time to time where I send 3 different values with a space after each one. So for example looking like this:
-0.1 0.51 0.07
So what I want to do now is to store this three numbers in different doubles and what I have done so far is this:
First i store the recieved message:
String recievedMessage;

recievedMessage += (char)BTLEserial.read();

Now I have to determine if the value sent is the 5 letters or if it is the numbers with a space between each value.
if (recievedMessage.length() > 5) //so if the recievedmessage is more than 5 words then it is the 3 values that is being sent.
{
char * charTheMessage = recievedMessage.c_str();
char *str;
str = strtok(charTheMessage, " ");

double one = str[0];
double two = str[1];
double three = str[2];

Serial.println (one);
Serial.println (two);
Serial.println (three);

}

if (recievedMessage.length() == 5)
{
 //http://arduino.stackexchange.com/questions/36227/how-can-i-split-a-string-into-multiple-parts/36237?noredirect=1#comment72313_36237
//Here I split the letters into 5 different values if the value sent is 5.
}

But this values do not come out right when I print them in the serial monitor. I have also read that strtok is not reliable when data is sent fast so is strtok the right way to go you think?

You're almost there. Strtok returns the first token in the string only. You then have to convert that to a double yourself. You then call strtok again with NULL as the source string to get the next token. And so on.
I have written a good strtok example on here already. Look around, you may find it.

I am out and about and using my phone right now so can't do a complex answer.

Here is one example: http://arduino.stackexchange.com/questions/31126/strtok-problem-while-parsing-string

Trying it right now! :) Will strncmp also work with spaces?

strncmp sees space as just another character

ok, let me try to see if i can work it out!

Ok. I get some more accurate results now (progress!) but in the while loop I only reach the "FIRST" if statement. Check post for updated code:

Nvm I fixed it! I just used the if-statement and removed the else if functions and inside the if statement i just added a simple int that increases in order to separate the three results


text:
SIM900a Mini Modem, IMEI 0, help with TX RX pins
I have Simcom SIM900a GSM (SIM900a Mini DEV Board v3.9.2) and I am interfacing it with Arduino UNO.
I have no idea how to connect SIM900a to Arduino UNO.
What I did now is:

I connect the following Pin from above image to:
5 to: GND (Digital GND near Pin 13)
6 to: 5V of Arduino
2 to: GND of Arduino near 5V
3 to: Digital Pin 0 of Arduino (RX)
4 to: Digital Pin 1 of Arduino (TX)
1 to: (No idea)
From Picture option 7, 8, 9 are not connected to anything.
Can you please guide me am I doing right?
I am getting hard time to find out what is TX and RX in my SIM900a module as it is not written there.
My SIM900a looks like this, this(Schematics given) and this.
When I upload the sketch:
File > Examples > GSM > TestModem:
to Arduino, I got this output from Serial Monitor:

Starting modem test...ERROR, no modem answer.
Checking IMEI...Modem's IMEI: 0
Reseting Modem... Modem is functioning properly: IMEI: 0

PS:
I saw this schematic here which is way different than what I am doing.
PSS:
Hints, am I supposed to provide external power supply of 5 V 2 A OR do I need some kind of converters (TTL to RS232 converter) ?

Finally I found solution to this problem:
My Pins connections were wrong, it should not be: 0 and 1 it should be 2 & 3:
2 - RX Arduino
3 - TX Arduino

also SoftwareSerial.h is not working with SIM900A
Pins:
All connections should be like this:
SIM900A - Arduino
=================
VCC     - VDC (+5V)
GND     - GND
5VR     - Connect to Arduino TX (Pin 3)
5VT     - Connect to Arduino RX (Pin 2)

As discussed here.
Very important:
Any program with header/library: #include <SoftwareSerial.h> is not working but #include <GSM.h> is working fine. As SoftwareSerial.h only work with GSM Shield and SIM900A isn't a shield.
Program/Sketch to Upload:
/*
SMS sender

created 25 Feb 2012
Originally written by Tom Igoe
But this is modified version
*/

// Include the GSM library
#include <GSM.h>

#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup(){
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial){
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("SMS Messages Sender");
// connection state
boolean notConnected = true;

// Start SIM900A GSM

while (notConnected){
    Serial.println("Status 1: Please wait a while, If it taking lot of time, \nmeans you have wrong pin connections.");
    // If your SIM has PIN, pass it as a parameter of begin() in quotes
    if (gsmAccess.begin(PINNUMBER) == GSM_READY){
    Serial.println("Status 2: GSM is ready.");
    notConnected = false;
}else{
    Serial.println("Status 3: Not connected");
    delay(1000);
  }
}
    Serial.println("Status 4: GSM initialized. " );

    // calling function to send message
    sendMessage();
}

void loop(){
    // empty loop
}

// method to send message to specific number just once.
void sendMessage(){
    Serial.print("Message is sending...: ");
    // send the message
    sms.beginSMS("03XXXXXXX "); // Replace XXXXXXX with your mobile number.
    sms.print("This is just some message"); // Message content, replace with your's.
    sms.endSMS();
    Serial.println("COMPLETE!\n");
    Serial.println("Message Sent...!\n");
}

Bam, It is working, and it successfully can send message.
Things to remember:

As everywhere being said you need to supply external power supply to SIM900A   it requires 5 Volts and 2 Amphs.

Connect GND of SIM900A to Arduino GND.

Connect VCC+ (above photo connection 2) to 5V pin of Arduino.

One Problem:
When I upload sketch of:

Example > GSM > TestModem:

to Arduino, I got this output from Serial Monitor:

Starting modem test...ERROR, no modem answer.
Checking IMEI...Modem's IMEI: 0
Reseting Modem... Modem is functioning properly: IMEI: 0

I cannot get IMEI from SIM900A but I can send message.

Your wiring is correct:
6 - VDC (+5V)
5 - GND
4 - RX (connect to Arduino TX - pin 1 for UNO)
3 - TX (connect to Arduino RX - pin 0 for UNO)

5VDC/2A power supply is must, otherwise module will be resetting when wireless radio is turned on. When using separate power supply, don't forget to connect Arduino GND and module GND.
The RX/TX on the module are depicted as 5VR/5VT (and 3VR/3VT for 3.3V pins).
The better way to get started / debug would be to use USB-to-serial converter: set the baudrate as 115200, connect and type AT and enter. Shall respond with AT (echo) and OK.
PS: The red wire (6) shall be on the left and black (5) on the right side, according to the board connector.

OMG Thanks! You are life saver. I will soon test this with external Power Supply but I have some questions: Q1: I have power supply which is 5v but I don't know about it's amps. How do I know it's amps as we can't calculate until we put a load on it. So how to do it what load I have to attach to power supply? Q2: For my practise purpose I am interested in USB-to-serial converter but I am not sure which one to buy? Can you please search here and let me know which one I should buy? (I will delete this link soon)

1: any power supply shall have description of its amperage (or wattage). If it is a module, check for main regulator ICs datasheet (for example 3A for LM2576). Power supply adapters for tablet / pads usually have 2A (for phones - 1A mostly). 2: Any converter with description "USB to TTL" will do, 1st red one looks OK (NOT the ones with DB-9 connector - those are USB-to-RS232 ).

Hello @FJanker, I tested my module with 5v and 1A but not working. Then I buyed 5v 2A now the SIM900A Power LED ON continuesly and Signal LED blink with certain period of time which mean I am okay. But when I connect: 5VT with RX and 5VR with TX of arduino, and GND with GND and VCC with 5V of Arduino, and I run program of TestModem still it is not working. Showing me Starting modem test...ERROR, no modem answer. Checking IMEI...Modem's IMEI: 0 Resetting modem...Modem is functoning properly  What should I do. Please help. I am likely to die becuase of tension.


text:
Due ADC specs: full power bandwidth
I'm trying to compute Johnson resistance noise in a simple resistor circuit. However, since all frequencies contribute equally, I am getting an answer of infinity.
It then dawned upon me that the Arduino ADC probably detect frequencies larger than some cut off given by something called the full power bandwidth. Does anyone know this spec for the Due?

Does Arduino.cc not have the specs you need?


text:
Don't know how to work IMU and NRF24 together
I'm having problem  on how can I use IMU and NRF24 together.
This is the code that i'm trying to use,
 /*
 Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.

 Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network
*
* TRANSMITTER NODE
* Every 2 seconds, send a payload to the receiver node.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <Wire.h>
#include "I2Cdev.h"
#include "RTIMUSettings.h"
#include "RTIMU.h"
#include "RTFusionRTQF.h"
#include "CalLib.h"

RTIMU *imu;                                           // the IMU object
RTFusionRTQF fusion;                                  // the fusion object
RTIMUSettings settings;                               // the settings object

//  DISPLAY_INTERVAL sets the rate at which results are displayed

#define DISPLAY_INTERVAL  300                         // interval between
pose displays

//  SERIAL_PORT_SPEED defines the speed to use for the debug serial port

#define  SERIAL_PORT_SPEED  11520
unsigned long lastDisplay1;
unsigned long lastRate1;
int sampleCount1;

 RF24 radio(7,8);                    // nRF24L01(+) radio attached using
 Getting Started board
 RF24Network network(radio);          // Network uses that radio
 const uint16_t this_node = 01;        // Address of our node in Octal
 format
 const uint16_t other_node = 00;       // Address of the other node in Octal
 format
 const unsigned long interval = 2000; //ms  // How often to send 'hello
 world to the other unit
 unsigned long last_sent;             // When did we last send?
 unsigned long packets_sent;          // How many have we sent already
 struct payload_t {                  // Structure of our payload
 unsigned long ms;
 unsigned long counter;
 };
 void setup(void)
 {
 int errcode;

 Serial.begin(SERIAL_PORT_SPEED);
 Wire.begin();
 imu = RTIMU::createIMU(&settings);                        // create the imu
 object

 Serial.print("ArduinoIMU starting using device "); Serial.println(imu-
 >IMUName());
 if ((errcode = imu->IMUInit()) < 0) {
 Serial.print("Failed to init IMU: "); Serial.println(errcode);
 }

 if (imu->getCalibrationValid())
    Serial.println("Using compass calibration");
 else
    Serial.println("No valid compass calibration data");

 lastDisplay = lastRate = millis();
 sampleCount = 0;

// Slerp power controls the fusion and can be between 0 and 1
// 0 means that only gyros are used, 1 means that only accels/compass are used
// In-between gives the fusion mix.

fusion.setSlerpPower(0.02);

// use of sensors in the fusion algorithm can be controlled here
// change any of these to false to disable that sensor

fusion.setGyroEnable(true);
fusion.setAccelEnable(true);
fusion.setCompassEnable(true);

Serial.println("RF24Network/examples/helloworld_tx/");

SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop() {

unsigned long now1 = millis();
unsigned long delta1;
int loopCount1 = 1;

while (imu->IMURead()) {                                // get the latest
data if ready yet
// this flushes remaining data in case we are falling behind
if (++loopCount1 >= 10)
        continue;
    fusion.newIMUData(imu->getGyro(), imu->getAccel(), imu->getCompass(),
imu->getTimestamp());
    sampleCount++;
    if ((delta1 = now1 - lastRate1) >= 1000) {
        Serial.print("Sample rate: "); Serial.print(sampleCount);
        if (imu->IMUGyroBiasValid())
            Serial.println(", gyro bias valid");
        else
            Serial.println(", calculating gyro bias");

        sampleCount = 0;
        lastRate1 = now1;
    }
    if ((now1 - lastDisplay1) >= DISPLAY_INTERVAL) {
        lastDisplay1 = now1;
     RTMath::display("Gyro:", (RTVector3&)imu->getGyro());                // gyro data
      RTMath::display("Accel:", (RTVector3&)imu->getAccel());              // accel data
      RTMath::display("Mag:", (RTVector3&)imu->getCompass());              // compass data
        RTMath::displayRollPitchYaw("Pose:", (RTVector3&)fusion.getFusionPose()); // fused output
       Serial.println();
    }
}

   network.update();                          // Check the network regularly

  unsigned long now = millis();              // If it's time to send a
  message, send it!
  if ( now - last_sent >= interval  )
  {
  last_sent = now;
  Serial.print("Sending...");
  payload_t payload = { millis(), packets_sent++ };
   RF24NetworkHeader header(/*to node*/ other_node);
   bool ok = network.write(header,&payload,sizeof(payload));
  if (ok)
  Serial.println("ok.");
  else
  Serial.println("failed.");
  }
  }

My question is what  should I put in this part
   [code]struct payload_t {                  // Structure of our payload
    unsigned long ms;
    unsigned long counter;
    };

so that the output for
 RTMath::display("Gyro:", (RTVector3&)imu->getGyro());                //
 gyro data
      RTMath::display("Accel:", (RTVector3&)imu->getAccel());
 // accel data
      RTMath::display("Mag:", (RTVector3&)imu->getCompass());
 // compass data
      RTMath::displayRollPitchYaw("Pose:",
 (RTVector3&)fusion.getFusionPose()); // fused output[/code]

will Transmit to the RX ..
What will I put in this part :
   Serial.print("Sending...");
   payload_t payload = { millis(), packets_sent++ };
   RF24NetworkHeader header(/*to node*/ other_node);
   bool ok = network.write(header,&payload,sizeof(payload));
   if (ok)
   Serial.println("ok.");
   else
   Serial.println("failed.");

Please help me guys. Thanks :)

My question is what should I put in this part

You need to take the data from IMU sensor and put it into the payload. Remember that NRF24L01 allows max 32 byte payload and the library uses some of that.
The RTVector3 is a C++ class with 3 floating point numbers. With AVR float/double that is 12 bytes. This means that you will have to send several messages.
enum {
   GYRO_TYPE = 0,
   ACCEL_TYPE = 1,
   COMPASS_TYPE =2
};

struct payload_t {
  int8_t type;
  float data[3];
};

This assumes that the sender and receiver have the same data representation. The type field is for the value type (GYRO, ACCEL, COMPASS).
Cheers!

I tried it but there is an error, I don't know what will I put in the payload. , please see the edited code above. thank you :)


text:
Can an Arduino (Leonardo) be recognized via Bluetooth as a mouse/keyboard?
I'm new to wireless communication on Arduinos and doing research for a project. I'm looking at the Arduino Leonardo (which is like the Uno) which via its micro USB port can be automatically recognized as a mouse/keyboard. But also looking at a regular Uno wiFi Rev2.
I want to achieve the same result, but wirelessly via Bluetooth. Because I need to connect it to a device that only recognizes Bluetooth mice/keyboards and nothing else. If I buy something like the HC-05 how would the chip report itself?
How is the Bluetooth stack handled with regards to identification and authentication? Does it somehow copy the USB mouse/keyboard setup?
PS: Can anyone tell me if the Wifi Arduinos (Uno WiFi rev2) also have Bluetooth embedded?

warning, there is nothing regular on Uno WiFi Rev 2. It is completely different from Uno

I meant to say Leonardo is not regular because it has a built in usb keyboard thingy on chip.

If I buy something like the HC-05 how would the chip report itself?

As an SPP. I.e., a serial port.

How is the bluetooth stack handled with regards to identification and authentication?

By the firmware on the HC-05

Does it somehow copy the usb mouse/keyboard setup?

No.
You need a USB device that can emulate a keyboard. That's not the HC-05. The host microcontroller has absolutely nothing to do with what capabilities the bluetooth interface has.

Ok so the HC-05 can't spoof itself to report itself as a specific thing (keyboard). And even if it did it would not have anything to do with the on-chip built in usb thingy the leonardo has. Cool. So I'll probably try to find a usb-to-bluetooth keyboard adapter, or research a more advanced way to spoof a keyboard via bluetooth with a regular arduino like the uno wifi rev 2.


text:
How can I use my sim808 as Both GPS and GSM module for this code
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

#include <SoftwareSerial.h>
SoftwareSerial gps(10,11); // RX, TX

//String str="";
char str[70];
String gpsString="";

char *test="$GPGGA";

String latitude="No Range      ";
String longitude="No Range     ";

int temp=0,i;
boolean gps_status=0;

void setup()
{
  lcd.begin(16,2);
  Serial.begin(9600);
  gps.begin(9600);

  lcd.print("Vehicle Tracking");
  lcd.setCursor(0,1);
  lcd.print("    System      ");
  delay(2000);
  gsm_init();
  lcd.clear();
  Serial.println("AT+CNMI=2,2,0,0,0");
  lcd.print("GPS Initializing");
  lcd.setCursor(0,1);
  lcd.print("  No GPS Range  ");
  get_gps();
  delay(2000);
  lcd.clear();
  lcd.print("GPS Range Found");
  lcd.setCursor(0,1);
  lcd.print("GPS is Ready");
  delay(2000);
  lcd.clear();
  lcd.print("System Ready");
  temp=0;
}

void loop()
{
  serialEvent();
  if(temp)
  {
    get_gps();
    tracking();
  }
}

void serialEvent()
{
  while(Serial.available())
  {
    if(Serial.find("Track Vehicle"))
    {
      temp=1;
      break;
    }
    else
    temp=0;
  }
}

void gpsEvent()
{
  gpsString="";
  while(1)
  {
   while (gps.available()>0)            //checking serial data from GPS
   {
    char inChar = (char)gps.read();
     gpsString+= inChar;                    //store data from GPS into gpsString
     i++;
     if (i < 7)
     {
      if(gpsString[i-1] != test[i-1])         //checking for $GPGGA sentence
      {
        i=0;
        gpsString="";
      }
     }
    if(inChar=='\r')
    {
     if(i>65)
     {
       gps_status=1;
       break;
     }
     else
     {
       i=0;
     }
    }
  }
   if(gps_status)
    break;
  }
}

void gsm_init()
{
  lcd.clear();
  lcd.print("Finding Module..");
  boolean at_flag=1;
  while(at_flag)
  {
    Serial.println("AT");
    while(Serial.available()>0)
    {
      if(Serial.find("OK"))
      at_flag=0;
    }

    delay(1000);
  }

  lcd.clear();
  lcd.print("Module Connected..");
  delay(1000);
  lcd.clear();
  lcd.print("Disabling ECHO");
  boolean echo_flag=1;
  while(echo_flag)
  {
    Serial.println("ATE0");
    while(Serial.available()>0)
    {
      if(Serial.find("OK"))
      echo_flag=0;
    }
    delay(1000);
  }

  lcd.clear();
  lcd.print("Echo OFF");
  delay(1000);
  lcd.clear();
  lcd.print("Finding Network..");
  boolean net_flag=1;
  while(net_flag)
  {
    Serial.println("AT+CPIN?");
    while(Serial.available()>0)
    {
      if(Serial.find("+CPIN: READY"))
      net_flag=0;
    }
    delay(1000);
  }
  lcd.clear();
  lcd.print("Network Found..");
  delay(1000);
  lcd.clear();
}

void get_gps()
{
   gps_status=0;
   int x=0;
   while(gps_status==0)
   {
    gpsEvent();
    int str_lenth=i;
    latitude="";
    longitude="";
    int comma=0;
    while(x<str_lenth)
    {
      if(gpsString[x]==',')
      comma++;
      if(comma==2)        //extract latitude from string
      latitude+=gpsString[x+1];
      else if(comma==4)        //extract longitude from string
      longitude+=gpsString[x+1];
      x++;
    }
    int l1=latitude.length();
    latitude[l1-1]=' ';
    l1=longitude.length();
    longitude[l1-1]=' ';
    lcd.clear();
    lcd.print("Lat:");
    lcd.print(latitude);
    lcd.setCursor(0,1);
    lcd.print("Long:");
    lcd.print(longitude);
    i=0;x=0;
    str_lenth=0;
    delay(2000);
   }
}

void init_sms()
{
  Serial.println("AT+CMGF=1");
  delay(400);
  Serial.println("AT+CMGS=\"+91**********\"");   // use your 10 digit cell no. here
  delay(400);
}

void send_data(String message)
{
  Serial.println(message);
  delay(200);
}

void send_sms()
{
  Serial.write(26);
}

void lcd_status()
{
  lcd.clear();
  lcd.print("Message Sent");
  delay(2000);
  lcd.clear();
  lcd.print("System Ready");
  return;
}

void tracking()
{
    init_sms();
    send_data("Vehicle Tracking Alert:");
    send_data("Your Vehicle Current Location is:");
    Serial.print("Latitude:");
    send_data(latitude);
    Serial.print("Longitude:");
    send_data(longitude);
    send_data("Please take some action soon..\nThankyou");
    send_sms();
    delay(2000);
    lcd_status();
}![enter image description here](https://i.sstatic.net/S5fc6.jpg)

The code is for two different modules a gsm and a GPS but I want to use the Sim 808 module with built in gps and gsm. What do I have to change in the code?

please add the question to the post above ...... also use the {} button to format the code


text:
Will a delay() function in a void SerialEvent() also stop the code that is running in the void loop() function?
Will a delay() function in a void SerialEvent() also stop the code that is running in the void loop() function?
This is about an Arduino Uno.

This is the main function of the Arduino core:
int main(void)
{
    init();

    initVariant();

#if defined(USBCON)
    USBDevice.attach();
#endif

    setup();

    for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
    }

    return 0;
}

serialEventRun() runs the serialEvent() function, if it is assigned,
so yes, a delay in serialEventRun will delay the loop.

In an Atmega328p, the Uno's processor, there is only 1 CPU; it can only do one thing at a time. If it is executing code in the SerialEvent() function, then by definition, it is not executing code in the loop() function or anywhere else.
There is a minor exception to this: interrupt service routines will run briefly when their respective interrupts occur. In fact, one way a delay() function can operate depends on timer updates that take place as interrupts. (The other way is by executing a loop whose execution time is accurately known, a specified number of times).
But interrupt service routines do one, very short, job, and return the CPU to whatever it was doing immediately before (delay() within the SerialEvent() function), so no other user code can be executed until the delay ends.


text:
Stop led from blinking when running
I don't get it. I'm new to Arduino, but not to programming. I don't understand why led pin 13 keeps blinking.
here is my code..
#include <Servo.h>

// X servo angle will stay in [min_x, max_x] range
// Y servo angle will stay in [min_y, max_y] range
// to be adjusted to the size of your living room

float min_x = 5;
float max_x = 50;
float min_y = 5;
float max_y = 35;
int min_freeze = 200;
int max_freeze = 3000;
float minimal_movement = 5;

// finding center of square for starting point
int random_delay;
float x_position = min_x + (max_x - min_x)/2;
float y_position = min_y + (max_y - min_y)/2;
float x_old_position = x_position;
float y_old_position = y_position;
float x_new_position;
float y_new_position;
float x_speed;
float y_speed;
int movement_time;

// Instantiating two servos
Servo x_servo;
Servo y_servo;
int pos = 0;

void setup() {
  y_servo.attach(6);  // attaches the y servo on pin 6 to the servo object
  x_servo.attach(9);  // attaches the x servo on pin 9 to the servo object
  pinMode (13, OUTPUT);
  digitalWrite (13, HIGH);  // switch on  the laser

  //Place the servos in the center at the beginning
  y_servo.write(y_position);
  x_servo.write(x_position);

}

void loop() {
  movement_time = random(10,40);
  random_delay = random(min_freeze, max_freeze);
  x_new_position = random(min_x+minimal_movement, max_x-minimal_movement);
  y_new_position = random(min_y+minimal_movement, max_y-minimal_movement);

  if( (y_new_position > y_old_position) && (abs(y_new_position - y_old_position) < 5 )) {
    y_new_position = y_new_position + minimal_movement;
  }  else if ( (y_new_position < y_old_position) && (abs(y_new_position - y_old_position) < 5 )) {
    y_new_position = y_new_position - minimal_movement;
  }

  if( (x_new_position > x_old_position) && (abs(x_new_position - x_old_position) < 5 )) {
    x_new_position = x_new_position + minimal_movement;
  }  else if ( (x_new_position < x_old_position) && (abs(x_new_position - x_old_position) < 5 )) {
    x_new_position = x_new_position - minimal_movement;
  }

  x_speed = (x_new_position - x_old_position)/movement_time;
  y_speed = (y_new_position - y_old_position)/movement_time;
  for (pos = 0; pos < movement_time; pos += 1) {
      x_position = x_position + x_speed;
      y_position = y_position + y_speed;
      x_servo.write(x_position);
      y_servo.write(y_position);
    delay(10);
  }
  x_old_position = x_new_position;
  y_old_position = y_new_position;
  delay(random_delay);

}

Nowhere in this sketch, the line "digitalWrite (13, LOW);" is contained, yet I am unable to keep the LED on solid without blinking when the Arduino is looping. I've other people do it, with this code, I don't get what I'm missing!
Windows 7 64bit, Arduino Uno board, Arduino 1.8.9 program

Welcome to the Arduino SO site. You should select your code and tap the code formatting button (It looks like open and close curly braces ({}). (I edited your question and did it already.)

You did not upload that code. That's still the initial blink sketch, coming together with the bootloader. My guess.  :)

Or maybe your sketch causes a reset (not sure what happens during an exception). Change the initial code to see what happens (like a small pattern of the LED to play, than you also know that your sketch is loaded like DataFiddler assumes (which is even more likely than mine).

Use the serial monitor. Send a message from the setup function so you know that the setup function is executed. Then send a message from the loop.

If you're running a motor you need to have a separate power supply for the motor. There's no way you can drive a servo motor from the Arduino 5V line.  You are much better off using a completely different power supply for your servo motor (just connect the ground lines.)

I did upload my code. I did correction in the program, and that is when I was getting my problem, trying to unload over the first code. When the Arduino is connected to my USB and running what ever program I upload, my computer USB became unstable. Every time the led blink, the computer would unrecognized and re-recognize, which in return made me unable to overwrite the code on the Arduino. Are you guy's getting this too, my computer always beeps when I plug and unplug something, and it was continuously doing that. Re-uploading is a nightmare. I don't know how you guy's do it so easily!

I tried your sketch on an Arduino Uno, with no servos connected, and the LED on pin 13 did not blink.
DataFiddler makes a good point in their comment. To be sure you are actually uploading the sketch, try uploading the Blink sketch that comes with the IDE. Change the delays from 1000ms to 200ms then upload it. The difference in flash rates should confirm or deny the ability to successful upload sketches.
You don't say which servos you are using, so I'll assume they are SG90. I'm not sure if the data sheet for every SG90 servo is the same, but if you look at this one, SG90 Specifications, you'll see the "stall current" can be between 570mA and 730mA, each. If you are powering them from the Uno, it can't supply that much current. Another limiting factor is the computer's USB maximum current output, (if you are powering the Uno with a USB port). FWIW, my computer can only provide 500mA per USB.
I would suggest powering the servos with a separate power supply, then see what happens.

If you power your Arduino from the USB port the Arduino current-limits the draw from the USB to 500mA even if the computer's USB port is capable of more.

That is exactly what I found out. I was like why is it not working like it does in the video, then I decided to plug it in the outlet to see how bad it was, and that is when I notice that it was performing just like the video. Thanks for your help.


text:
Ideal power supply for ESP8266
What is the ideal power supply for this module? What do you use that works ok?
Will the AMS1117 work?

Yes, that will work. However, ignore the entire description.
That is NOT a buck regulator - it is a low-dropout linear regulator.  Thus it will waste power as heat - the more current you draw the hotter it will get.
The '1117' range of regulators are pretty much ubiquitous. I use them in a wide range of products and situations where power consumption isn't critical (i.e., not battery based products).
For lower power requirements you want to get a real buck regulator. Something more like this: http://www.ebay.co.uk/itm/301842020065
Note that it's an adjustable module, and you will need to first use a multimeter to adjust the output to 3.3V before you connect it up.
Because they are adjustable they are a great thing to keep around since you can use them for all sorts of different situations.

This looks better. Will the element i ordered require additional capacitors? I'll order a couple of these too.

No, the 1117 board has the capacitors on it already.

My bad. I should have read better.


text:
Get the rotation on Genuino 101
How can I get the exact rotation of the Genuino 101? I would like to create a plumb rule.
I tried the example app with processing, Arduino/Genuino 101 CurieIMU Orientation Visualiser, but it didn't get the correct rotation. Sometimes the object on the screen has a different rotation from the board itself.


text:
Arduino Ping sensor with NewPing library
I was trying out the NewPing library (the main example sketch) and when I compile it and check the serial monitor, it seems like it works for about 10 seconds, then instead of giving distance values it just writes out random characters. The only thing I can think of is that my sensor is bad. Any suggestions before I get another Ping sensor? I'm unsure if the same thing will happen.

The main example sketch has this:
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.

Your serial monitor is set to 9600 baud (bottom RH corner). Change that to match the setting in the sketch.


text:
Get strings from Serial.read()
I want to read strings from Serial.read() to send them later.
To get the data from the Serial monitor I'm doing this:
String stringOne  = "";
int  incomingByte;

if (Serial.available() > 0) {

  while(Serial.available() > 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }

  Serial.println(stringOne);
  stringOne = "";

The issue is that when I type:
'a'

I got:
'97'

for
    'abc'
I got
'979899'

so on and so forth.
What should I do in order to get the same string I type?

Read this: https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/

You're adding the ASCII value of each char to your string, hence you get numbers. See the various String constructors at:
https://www.arduino.cc/en/Tutorial/StringConstructors
Either cast the read byte to a char:
stringOne = String(stringOne + String((char)incomingByte));

or consider receiving characters as chars, instead of ints:
char incomingByte;

There is a perfectly valid one-method call which does all of this hassle easier and more efficiently: https://www.arduino.cc/en/Serial/ReadStringUntil
Note that you'll sooner or later anyhow have to add a framing prototcol. For example, you're sending down text commands to Arduino, and each command is separated by a new line character. ReadStringUntil will handle that very nicely.

Instead of using:
while(Serial.available() > 0)
  {
     incomingByte= Serial.read();
     stringOne = String(stringOne + String(incomingByte));
  }

Use the following to cast them to character:
while(Serial.available() > 0)
  {
     char incomingByte= Serial.read();
     stringOne.concat(incomingByte));
  }
Serial.println(stringOne);
stringOne="";


text:
I am planning to do a periodic table with Arduino's help but I have a few questions
I'm doing that for my school project, but I have few questions before I purchase the components.
First of all, let me explain how it will work:
There will be 4x20 LCD, an Arduino and probably two potentiometers (due to the potentiometer's sensitivity). When the user turns the potentiometers, the program adds the first potentiometer's value to the other potentiometer's value, because of sensitivity issues. Then the program checks which element corresponds to the two potentiometers' values.
After that, the program shows that element's information in the LCD (like its name, symbol, neutron number, proton number, valence electrons, ...).
Questions:

There are around 118 elements in the periodic table. I'm not an expert with programming, but this means there will be 118 if ... else if ... statements. I can shorten the inside of the if statement by function, but there will be still 118 if statements. I'm afraid it will be over the memory (sketch size limit) limit of the Arduino. How can I shorten the code?
Should I buy a Mega or will a Uno be enough?
Will there be any problems if I connect a 5V Arduino pin to both potentiometers and 4x20 backlight? If not, how can I fix this? I don't want to use any other power source except Arduino.

Learn how to use arrays and PROGMEM. It's all on the Arduino Playground if you google it.

Look into switch-case instead of ifs

You should be able to store about 100 to 150 bytes per element on an Uno, as a PROGMEM array. That is more than a full page of your LCD. And you may want to use a rotary encoder instead of your two pots.

@Gerben: For this usage case, an array seems more appropriate, by far, than a long switch-case.

@EdgarBonet 10 turn 10kohm pot should do it too in my opinion. Can you give me a hint about where i should use arrays? and does the progmem store the array's data in normal memory (32kb) instead of ram?

The clue is in the word "PROGMEM"...

You define a struct that holds all the data of an element, then an array of 118 such structs can hold all the data you need. Your program then browses through the array to extract and print the data of the element chosen by the user. I can try to write a basic example showing how you could organize the data, but I will not have time before ~ 24h.

Expanding an answer from my comment on your question:
First thing is to define a struct that holds all the data you want to
store and display for one element:
struct Element {
    char symbol[3];
    char name[16];
    float mass;
    char electronic_state[9];
    // etc...
};

Do not store the atomic number, as it will be deduced from the index on
the array you will build. Each string in this struct (symbol, name...)
should be big enough to store the longest possible string, including the
final NULL terminator. The compiler will help you here: if you do not
allocate enough room, it will later say something like “error:
initializer-string for array of chars is too long”.
It is obviously somewhat inefficient to allocate each string the maximum
possible length. I suggest you do this for the sake of simplicity, and
because I do not think you should be short on flash, even on an Uno. If
you really end up being short on flash, then I suggest you seriously
consider jwpat7's answer. It is somewhat complicated, but likely to be
significantly more efficient than mine in terms of flash usage.
Second step is to write down the periodic table as a PROGMEM array:
const Element periodic_table[] PROGMEM = {
    // symbol  name    mass      electronic state
    {"H",  "Hydrogen", 1.008,    "1s1"     },
    {"He", "Helium",   4.002602, "1s2"     },
    {"Li", "Lithium",  6.94,     "[He] 2s1"},
    // etc...
};
const size_t table_length = sizeof periodic_table / sizeof *periodic_table;

Then your program will only have to browse through this table in order
to get the needed information. The only tricky part here is that you
will have to copy the data to RAM before using it, for example with
something like:
Element elt;  // element in RAM
memcpy_P(&elt, &periodic_table[i], sizeof elt);

I do not have an LCD, so I wrote a test program that simply dumps the
table through the serial port:
void setup()
{
    Serial.begin(9600);
}

void loop()
{
    Serial.println(F("Z  Symbol  Name  Atomic mass  El. state"));
    Serial.println(F("---------------------------------------"));
    for (size_t i = 0; i < table_length; i++) {
        Element elt;  // element in RAM
        memcpy_P(&elt, &periodic_table[i], sizeof elt);
        Serial.print(i+1);  // Z = i+1
        Serial.print(F("    "));
        Serial.print(elt.symbol);
        Serial.print(F("     "));
        Serial.print(elt.name);
        Serial.print(F("  "));
        Serial.print(elt.mass);
        Serial.print(F("  "));
        Serial.println(elt.electronic_state);
    }
    Serial.println();
    delay(1000);
}

This program only takes 4480 bytes of flash. This means I could expand
the table to 118 elements and over 200 bytes of data per element before
running out of flash on an Uno.

Rather than manually putting all of the periodic-table data into a program in just the right form (which would be quite tedious), you could use a program on your software development computer to read periodic-table data files and create the corresponding C-program data structures.
The python program shown below gives an example of that approach.  (It contains a data table in a list of tuples, ie doesn't read data; but data like that in the tuples can be read from a file, or with a bit of programming, from a spreadsheet of periodic-table data.)
The python program opens file datatables.data.c for output, then it writes C statements into that file, which subsequently can be added into a sketch, datatables.ino, as shown later.
Python program, densconmelt.py:
#!/usr/bin/python
# From data as shown in slide 19 of 39 at
# http://www.slideshare.net/bravetiger1964/lecture-11-metals-and-its-alloys-their-crystalline-structure-and-properties

# Physical Properties of several Metals and Alloys.
#   Metal or Alloy
#     Density (kg/m3)
#       Thermal conductivity W/(m*K) (t=20 C)
#         Melting point (Tm) (C)
adtm = [
    ('Aluminum', '2712', '204', '659'),
    ('Aluminum alloys', '7700-8700', '120-180', '462-671'),
    ('Brass-casting', '8400-8700',  '',  '990-1025'),
    ('Red Brass',     '8746', '159', '1027'),
    ('Yellow Brass',  '8470', '115', '930'),
    ('Bronze - lead', '7700-8700', '',  '850-1000'),
    ('Copper', '8930', '385', '1083'),
    ('Gold', '19320',  '318', '1063'),
    ('Pure iron',     '6800-7800', '72', '1530'),
    ('Cast Iron',     '7850', '', 'Gray 1370, Malleable 1360, White 1370'),
    ('Wrought Iron',  '7750', '58', '1450'),
    ('Lead',  '11340', '35.3', '327'),
    ('Nickel', '8800', '89', '1453'),
    ('Silver', '10490', '406', '961'),
    ('Solder 50/50 Pb/Sn', '8885', '', ''),
    ('Non-alloyed and low-alloy steel', '7850', '53.6', '1480'),
    ('Stainless Steel', '7480-8000', '12.11-45.0', '1430-1500'),
    ('Tin',  '7280', '63', '232'),
    ('Zinc', '7135', '115', '419')
    ]

locs = []
# To track current offset into datatext, and longest single string part
used = longy = 0
with open('datatables.data.c', 'w') as fo:
    fo.write('#ifdef ADDTABLE  // Disallows separate compile\n')
    fo.write('const char datatext[] PROGMEM = \n  ')
    for i in adtm:
        #a, d, t, m = i
        #print '{:20} {:12} {:12} {:12}'.format(a, d, t, m)
        for x in i:
            locs.append(used)
            used += len(x)+1
            longy = max(longy, len(x)+1)
            fo.write('"{}\\0" '.format(x))
        fo.write('\n  ')
    fo.write(';\nconst int offsets[] = {')
    for o in locs:
        fo.write(' {},'.format(o))
    fo.write(' {}{};\n'.format(used, '}'))
    fo.write('enum {} LONGSTR={}, ITEMS={}{};\n'.format('{', longy, len(adtm), '}'))
    fo.write('char buffy[LONGSTR];\n')
    fo.write('#endif\n')

Note, the out-commented lines
        #a, d, t, m = i
        #print '{:20} {:12} {:12} {:12}'.format(a, d, t, m)

would be an appropriate place to modify the python program so it prints out how the lines will look when displayed on the 4x20 LCD.  Rather than repeatedly downloading files to your Uno or Mega just to fix lines that are a little too long, or misaligned, etc., you could make the python program show the display appearance in the same loop where it generates data structures to be included in the Arduino sketch.
Note, if you aren't familiar with the with construct, see the With Statement section of pythonforbeginners.com's Reading and Writing Files in Python page.
What the Python program generates:
Some lines from the file generated by densconmelt.py are shown below, interspersed with comments about what those lines do.  Later, the whole of the file datatables.data.c is shown.
#ifdef ADDTABLE  // Disallows separate compile

That line is a preprocessor statement to keep datatables.data.c from being compiled alone.  During compilations, the Arduino IDE will copy datatables.ino and datatables.data.c into a temporary work directory and will compile each of them.  However, the body of datatables.data.c won't compile correctly alone (outside the sketch), so is guarded from causing compile errors by surrounding it with #ifdef ... #endif lines.
const char datatext[] PROGMEM =

That line tells the C compiler to store the value of datatext[] into program memory.  It also says the value and content of datatext are constant, and datatext is an array of characters.
  "Aluminum\0" "2712\0" "204\0" "659\0"
  "Aluminum alloys\0" "7700-8700\0" "120-180\0" "462-671\0"
  "Brass-casting\0" "8400-8700\0" "\0" "990-1025\0"
...
  "Tin\0" "7280\0" "63\0" "232\0"
  "Zinc\0" "7135\0" "115\0" "419\0"
  ;

Those lines each give the name of a metal or alloy, its density, its thermal conductivity, and its melting point.  Values are strings instead of numbers, so ranges and missing values can be handled.  Note that by rules of C, strings with no operators between them concatenate together.  For example, the line "Tin\0" "7280\0" "63\0" "232\0" is equivalent to the line "Tin\07280\063\0232\0".  Note, each \0 is a null character at the end of a substring.  If space were short, one could leave out all the \0s and compute string lengths as differences of adjacent entries in offsets[].
const int offsets[] = { 0, 9, 14, ... 524, 528, 533, 538, 542, 546};

That line tells where each substring begins, within the big string  datatext.  This method of storing offsets and substrings takes 12 bytes per item, ie 4·2 bytes for 4 int values plus 4 bytes for null characters.  There are half a dozen ways to reduce the overhead to 5 to 10 bytes per item, but the most effective simple change would be to put offsets[] in PROGMEM.  In addition, one might change some fields from strings to integers or floats, which would not need null separators or offset values if placed at fixed offsets at the front of an item's record.
enum { LONGSTR=38, ITEMS=19};
char buffy[LONGSTR];
#endif

Those lines create two constants, LONGSTR and ITEMS, telling the length of the longest substring and the number of items; allocate a buffer, as long as the longest substring; and close the guarding #ifdef ... #endif.
datatables.data.c, shown whole:
#ifdef ADDTABLE  // Disallows separate compile
const char datatext[] PROGMEM =
  "Aluminum\0" "2712\0" "204\0" "659\0"
  "Aluminum alloys\0" "7700-8700\0" "120-180\0" "462-671\0"
  "Brass-casting\0" "8400-8700\0" "\0" "990-1025\0"
  "Red Brass\0" "8746\0" "159\0" "1027\0"
  "Yellow Brass\0" "8470\0" "115\0" "930\0"
  "Bronze - lead\0" "7700-8700\0" "\0" "850-1000\0"
  "Copper\0" "8930\0" "385\0" "1083\0"
  "Gold\0" "19320\0" "318\0" "1063\0"
  "Pure iron\0" "6800-7800\0" "72\0" "1530\0"
  "Cast Iron\0" "7850\0" "\0" "Gray 1370, Malleable 1360, White 1370\0"
  "Wrought Iron\0" "7750\0" "58\0" "1450\0"
  "Lead\0" "11340\0" "35.3\0" "327\0"
  "Nickel\0" "8800\0" "89\0" "1453\0"
  "Silver\0" "10490\0" "406\0" "961\0"
  "Solder 50/50 Pb/Sn\0" "8885\0" "\0" "\0"
  "Non-alloyed and low-alloy steel\0" "7850\0" "53.6\0" "1480\0"
  "Stainless Steel\0" "7480-8000\0" "12.11-45.0\0" "1430-1500\0"
  "Tin\0" "7280\0" "63\0" "232\0"
  "Zinc\0" "7135\0" "115\0" "419\0"
  ;
const int offsets[] = { 0, 9, 14, 18, 22, 38, 48, 56, 64, 78, 88, 89, 98, 108, 113, 117, 122, 135, 140, 144, 148, 162, 172, 173, 182, 189, 194, 198, 203, 208, 214, 218, 223, 233, 243, 246, 251, 261, 266, 267, 305, 318, 323, 326, 331, 336, 342, 347, 351, 358, 363, 366, 371, 378, 384, 388, 392, 411, 416, 417, 418, 450, 455, 460, 465, 481, 491, 502, 512, 516, 521, 524, 528, 533, 538, 542, 546};
enum { LONGSTR=38, ITEMS=19};
char buffy[LONGSTR];
#endif

Sketch to get item data from program memory and display it:
We've used densconmelt.py to generate datatables.data.c as above, and now will show a sketch that gets an item's data out of program memory and displays it, whenever the sketch receives an item number via Serial input.
// Sketch that accepts a number via serial input, and responds with
// two lines of data via serial output.  The reply-data consists of an
// Alloy name on the first line, and Density, Thermal conductivity,
// and Melting point on the next line.

// See http://arduiniana.org/libraries/streaming/ for Streaming library
#include <Streaming.h>
// This sets up datatext in PROGMEM; offsets[]; buffy; LONGSTR; ITEMS
#define ADDTABLE
#include "./datatables.data.c"

void setup() {
  Serial.begin(115200);         // init serial port
}

void loop() {
  Serial << "Please enter item number from 1 to " << _DEC(ITEMS) << ": ";
  int item = 0;
  while (1) {
    while (!Serial.available()) {}; // Wait for a character
    int c = Serial.read();
    if (c == '\n') break;
    item = 10*item + c - '0';
  }
  if (item < 1 || item > ITEMS) {
    Serial << item << endl << item << " is out of range -- try again.\n";
    return;
  }
  // Display specified item's title on first line
  strcpy_P(buffy, datatext + offsets[item*4-4]);
  Serial << item << endl << "Item #" << item << ", " << buffy << endl;
  // Show other data items on next line
  strcpy_P(buffy, datatext + offsets[item*4-3]);
  Serial << "Density " << buffy;
  strcpy_P(buffy, datatext + offsets[item*4-2]);
  Serial << "   Thermal cond. " << buffy;
  strcpy_P(buffy, datatext + offsets[item*4-1]);
  Serial << "   Melt@ " << buffy << " C" << endl << endl;
}

Note, for a description of strcpy_P() arguments, see nongnu.org's avr/pgmspace.h : Program Space Utilities page.
See arduino.cc's PROGMEM page for a cursory overview of PROGMEM.
See avrfreaks.net's GCC and the PROGMEM Attribute page for detailed coverage of PROGMEM, and see Nick Gammon's Putting constant data into program memory (PROGMEM) page as well.
Example of program output, as in Serial Monitor box:
Following is an example of program output as shown in the Serial Monitor box after I typed several numbers into the input line and pressed enter after each.   (Note, at the bottom of the Serial Monitor box, set Line Ending to Newline and data rate to 115200 bps.)
Please enter item number from 1 to 19: 18
Item #18, Tin
Density 7280   Thermal cond. 63   Melt@ 232 C

Please enter item number from 1 to 19: 19
Item #19, Zinc
Density 7135   Thermal cond. 115   Melt@ 419 C

Please enter item number from 1 to 19: 20
20 is out of range -- try again.
Please enter item number from 1 to 19: -2220
-2220 is out of range -- try again.
Please enter item number from 1 to 19: 2
Item #2, Aluminum alloys
Density 7700-8700   Thermal cond. 120-180   Melt@ 462-671 C

Please enter item number from 1 to 19: 0
0 is out of range -- try again.
Please enter item number from 1 to 19: 5
Item #5, Yellow Brass
Density 8470   Thermal cond. 115   Melt@ 930 C

Please enter item number from 1 to 19:

The sketch echoes the user-input item number twice, so it appears at the end of each input solicitation as well as in line labels like “Item #5, Yellow Brass”.

That's seems complicated. I got the idea but i don't know anything about python syntaxs, statements..., and i can't carry an external device except arduino. just the arduino and electrical components. Thx for the idea though

@ÇayÖncesi, the sketch uses Serial just for illustration – you would substitute a rotary encoder or a pot for input, and an LCD for output.  Even if you don't use a development-system preprocessor (with a code-generator written in python, C, or whatever language you prefer) you can organize your Arduino code in a manner similar to that illustrated.

You probably don't need a Mega for this, but think about it as a long term investment if you want to keep messing around with the Arduino/move on to bigger projects.
Unfortunately, typing all the code out will be quite tedious. But you can make separate arrays for strings of all the element names:
https://stackoverflow.com/questions/1088622/how-do-i-create-an-array-of-strings-in-c
And you can make corresponding arrays for all of the numerical data.
Then you take the signal, do some math to figure out how you can use the signal to obtain an integer from 1-118, write that into an integer (say i), and then write name[i], symbol[i], neutnum[i], and so on to the LED screen.
The hardest part will be doing math so that the transition between two elements in terms of turning the potentiometer feels natural.
Note that if your math somehow generates 200, then name[200] will most likely write random values from memory to your LED screen. I think. If your LED screen is displaying nonsense, then that is what you should look at/debug first.

thx for the answer, i will probably buy a incremental rotary encoder. But if i cant set up the R.E. i will go with pots. Arrays didn't come to my mind before, but now i understand that arrays will work better. I will buy mega, i found a cheap one (Non-Clone). Thx again

i think you might have to buy a mega(probably more expensive!)
i also fear someone putting countless nights into coding (preferably on pc for me, because 1: sketch is only available as an ancient version on raspberrypi. & 2: easier transfer of code.)

i will buy mega, for this project and for future

Could you please explain why Mega would be a better choice?


text:
Where do I put the cables from my soldered l293d onto the arduino uno/arduino pro mini? (Drone)
I am trying to create a drone but I am struggeling a bit with the components and the schematic. I have 4 small drone motors from hubsan x107 and i have soldered their wires on a l293d driver like this below:

As you can see i have also soldered jumper cables on the l293d as well and I now look to put them on the arduino uno or a arduino mini pro (i have both at home) but I am not sure where to put these cables in order to make this work. I have typed them out as you can see on the picture and named them: Jumper cable 1, 2, 3, 4, 5, 6, 7 and 8.
This is the hardware I use:
Motor: http://www.banggood.com/Hubsan-H107C-X4-RC-Quadcopter-Spare-Parts-Motor-H107-a23-p-87563.html
Arduino uno
L293D
Cables
Would a setup like this work if I put the jumper cables on the correct pins on the arduino? And if so where on the arduino do i need to connect each wire?
Thanks a lot!!

I did not down vote you.  But will try to explain why it likely happened.  Your question is way too broad - actually to the point it  can not be answered.  All Arduino project are based on software / firmware.  And if there is none in the question, then there really can be no project.

Appreciate the feedback! Updated the post with the motor i use. Other then that It is a simple arduino uno board i work with along with the L293D driver that I also linked an image about. And of course cables

Hint: Most people who write code (drivers?) for the Arduino leave documentation explaining how to use their drivers.  This is to say, you are still leaving out a key piece of information in your question:  What driver are you using?

L293D driver? Well i only use x4 motors, the L393D and a arduino uno so I guess that is my driver haha :P

You are missing a huge piece.  There's bare metal programming.  Which is very difficult. But the Arduino paradigm abstracts you from that.  So there is at least the PWM drivers that come with the Arduino software package.  So you need to connect up to the pins that the Arduino will support with the built in PWM Arduino driver. But to control 4 motors for flying is going to take a lot more than that.  What are you using?  Are you writing your own software?

st2000, I partially agree, I think it's a valid question if you ask how to wire up the circuit. It doesn't need any code for that yet. But I agree: "would this setup work" is too broad, there are many points that may fail.

simulate this circuit – Schematic created using CircuitLab
The battery needs to be the right voltage for your motors. There are no specifications on the page you linked to at all, so your job now is to find out what your motors are and what voltage they run from.

The datasheet has an interesting addition to the ground prins: "Device ground and heat sink pin. Connect to printed-circuit-board ground plane with multiple solid vias."

@Paul Yeah, I was thinking of mentioning that. Not sure if the OP has a driver on a breakout (in which case it doesn't matter) or if he has directly wired jumpers to the chip pins - in which case he may want to solder on some lumps of metal as well to act as a heat sink...

Also, I'm curious if you could toggle the enable pin to get "active breaking" then it may be worth to not directly wire them to vcc.

@Paul That may be vaguely possible, but I wouldn't want to do that through an Arduino IO pin.

@Paul Actually that might be ok. I think the EN would be isolated from the back EMF from the motor.

Hmm, the outputs can be "high", " low" and "high impedance". According to the "function table" in the TI datasheet. But I was wondering if high impedance would cause breaking.

About back EMF, the functional block diagram does show diodes outside the chip itself, but the description says: "high voltage outputs for inductive load driving", so that's indeed not very clear. So when using this part, rather check with TI or just take the neccesary precautions (reverse diode).

@Paul Or even better, invest in a proper Arduino shield instead of dead-bugging it.

Agreed, but I was thinking of making an "all in one" robotics board that could be used as an educational tool. So I was wondering if it could be made breaking, but I guess that's a whole other question altogether (and I also think I won't have the time for this in naar future :p). I'll stop here to avoid further discussion that's more aimed on my question as on the person who posted this, though it can be interesting if he needs breaking on his quadcopter.

@Paul Braking is supposed to be done using just two motors per driver (1+2 and 3+4) with the input pins controlling the direction and the EN pins controlling the speed.


text:
How to print (or store) gps lat, lng value (TinyGPS++) with Bluetooth BLE nRF8001?
I have a u-blox gps module and I use TinyGPS (http://arduiniana.org/libraries/tinygpsplus/) to get out the lat + lng.
If i write...
Serial.println(gps.location.lat(), 6);

...out in the log I get the correct latvalue.
Right now I however work with a BLE (https://www.adafruit.com/product/1697) and when I try to print it like this:
BTLEserial.print (gps.location.lat()`, 6);

I get a error: no matching function for call to 'Adafruit_BLE_UART::print(double, int)'
If I do this instead, the code runs...
BTLEserial.print ((gps.location.lat(),6));

But I do not get the correct lat, instead I get this value 6.00000000
I have tried to store the lat like this:
double myLat;

myLat = (gps.location.lat(), 6);
BTLEserial.print (myLat);

But with that myLat also has a value of 6.00000000 which is not correct.
I tried this as well:
char sValueOne[16], sValueTwo[16];
char sBuffer[33];

strcpy(sBuffer,dtostrf(((gps.location.lat(),6)), 15, 8, sValueOne));
strcat(sBuffer,",");
strcat(sBuffer,dtostrf(((gps.location.lng(),6)), 15, 8, sValueTwo));

BTLEserial.write((uint8_t *)sBuffer, strlen(sBuffer));

But with that I still get 6.00000000. I am starting to run out of ideas now to make this work. I have tried to send it both directly and store it but nothing works successfully.
So how can I adjust the code to be able to print (or store) gps lat, lng value (TinyGPS++) with Bluetooth BLE nRF8001?
Appreciate every help and tips!

6.000000 is the value of ((gps.location.lat(),6)) where 6 is the last item in the list. C/C++ is a strange language. Remove all the extra () and things will look better.

If i do BTLEserial.print (gps.location.lng(),6); i get a error: no matching function for call to 'Adafruit_BLE_UART::print(double, int)'

Add links to the libraries you are using.

myLat = (gps.location.lat(), 6); gives the value 6.0000 as explained above. It is not a list with the two values or a double with 6 digits.

For gps i use TinyGPS++, this: http://arduiniana.org/libraries/tinygpsplus/ and for my BLE i use this where you can see sample code also: https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout/nrf-uart-in-detail

Yea exactly. And i want the correct lat/lng value so i am not sure on how to proceed to successfully connect that to my ble device when I write/print data

The Arduino Stream/Print classes may sometime need some extra attention.
BTLEserial.println(gps.location.lat()`, 6);

The member function is available in the class Print but gets "hidden". You can help the compiler to find it with a prefix:
BTLEserial.Print::println(gps.location.lat()`, 6);

Cheers!

Hey! Thanks for this answer. Will try it in an hour

Hi! I get the correct value. However, it seems like it sends one number at a time. So when I recieve this on the app the value gets chopped up. So for example if the latitude is: 32.123456, it comes like this to the app: 3, new row, 2, new row etc.

I do not use println btw, instead print

That is a new question! Acknowledge the answer and ask a new one. I can help you with that :)

Ok Mikael! I will create a new thread regarding that issue. Thanks a lot for your example above to get the first part of the problem fixed. Will accept your answer and of course also upvote it!

Created a new post here: http://arduino.stackexchange.com/questions/33115/how-can-i-adjust-my-code-so-that-the-value-that-i-print-with-my-ble-device-does if you want to check it out!

Yapp, answered that :)


text:
Switch a 12V 3.3A component from an Arduino
I need turn off and turn on component from an Arduino UNO.

How can I do that? I am thinking about some transistor (IRF 530N) but I am not sure about it.
Please give me a beginner advice how to implement such a switch.
EDIT: Is this realy good for my problem?

Maybe a relay would be easier?

@RogerRowland is this relay good for me? https://ae01.alicdn.com/kf/HTB1Fz85OVXXXXaXXVXXq6xXFXXXz/C18-2016-1pc-1-Channel-12V-Latching-Relay-Module-with-Touch-Bistable-Switch-MCU-Control.jpg

A relay, as pictured, is a good choice. It provides complete galvanic isolation and switches the power properly.
Another option is to use a MOSFET that can handle enough current (an N-channel switching the ground as a low side switch, or a P-channel switching the power which is itself switched by an N-channel, as a high side switch).

Upvoted, but the OP should be aware that a flyback diode across the relay coil may be needed, especially if they use a relay that isn't in a ready-made module.

You only need that if you are wiring it yourself, in which case you would be following a tutorial. With a module like the one pictured it is all splayed and there is no need for more components.

A simpler relay board than that shown might be better.  The one shown in question is constantly powered by 12 VDC on the DC+, DC- lines.  It is toggled by pressing the button or by a contact-closure on the pins of the white connector.  Amazon and ebay links: https://www.amazon.com/Wrisky-Channel-Latching-Bistable-Control/dp/B01IOTKAFS http://www.ebay.com/itm/1-Channel-12V-Latching-Relay-Module-with-Touch-Bistable-Switch-MCU-Control-/301820150781

Yeah, on closer inspection that one looks odd. You want one of the simpler ones. Sainsmart make some good ones.

I've just bought a few STP16NF06L fets for this very purpose, N channel MOSFET.
The key part of that part number is the L at the end. This indicates low (or Logic) gate threshold, which means it will switch on fully at 5v gate drive, unlike most fets which are sort of conducting at 5v but need 10v to reach their specification (like an IRF530N).
The 16 and the 06 are 16 amps and 60 volts respectively.
You can get about 25 of them for the same price as a UNO, depending on supplier, in the UK here for instance

I think you mean STP16NF06L About one third the price of a UNO clone.

@Jasen No, see the link in the answer

you wrote '60' in your text but the part number is '06'.

@Jasen, why so I did! Thanks. I get cross-eyed with long part numbers, especially when the voltage part drops the trailing 0.


text:
Using an LM339 IC as a motor driver
I have an LM339 IC from Radioshack that I am hoping to use as a motor driver.
I read many resources on how the L239D can be used as one.  I don't have enough circuit experience to truly know the difference between the two and googling shows many wiki pages I couldn't fully understand.
Can the LM339 be used as a motor driver?
I did a quick comparison of the two circuits here LM339  and L239D
But I am still unsure.  I don't want to fry my board so I am asking first.

I looks as if it's doable.  http://forums.parallax.com/discussion/112585/lm339-h-bridge

Yes I think its doable too . This is an interesting question it reminds me of all the less obvious applications of the 55 timer. I guess the answer to your question is basically yes you could use it to drive a small motor (uses less than or same as 20ma and less or same as than 1.5v.

For example, It would be a variation of a battery comparator circuit with the LED replaced by a small motor with flyback diode, and it would be set to trigger at arduino 5v. Note that directly connecting such a motor to the arduino output pint would damage the Arduino (e.g. it would not output the high current properly once it was damaged with such a small motor). I think it would need more than one LM339 (though maybe its possible with one LM339) arranged in a clever way to protect the arduino and drive the motor.You may also need to add a few cheap parts too for the circuit.

@qwerty10 thanks for your answer!  It's a lot of trouble.  I went ahead and ordered the L239D.  I am writing up the code while I wait on delivery.

The LM339 is a comparator, not a motor driver. The L239D is a dual H-bridge motor driver.
They are completely different things. One is used for comparing two voltages (up to 4 times, it's a "quad"), the other is used for driving motors.
The LM339 can output an absolute maximum of 20mA. That's half what the Arduino itself can output on an IO pin!
You could use the LM339 as part of the control circuitry to control a H-bridge, but it cannot itself drive a motor in any way, shape, or form.

Not to mention the 16mA drive capability is only for the LOW level. The HIGH level current is rated in nA (which is more likely leakage current). Outputs for the Comparator OP AMPs are typically open-collector and they also needs external pull-up.


text:
How to power an Arduino Uno with 3 1.5V batteries?
I have an Arduino Uno (a SainSmart model, actually). I intend to power it with three 1.5V batteries. I measured them and they yield 4.67V in total. The Arduino requires 5V.
The question is, if the arduino will work this way.
I'm not powering complicated microcontroller components here. These components are used:

A buzzer
An LED
A unit of 4 seven segment displays
A couple of buttons as input elements

If the volume or brightness of these components is slightly decreased, it doesn't matter at all. But I would like to know if it will work in the first place.
And also...
Where exactly do I plug the power source in? The power jack, the USB jack, pins, somewhere else?

The schematic looks like this, just to illustrate it. I'm not a good drawer, but you'll get the idea...

According to the datasheet of the ATmega 328P (figure 29-1, page 303), you need at least 3.78 V to run the Arduino at 16 MHz. This is 1.26 V per battery. Many 1.5 V batteries will drop below that level way before being exhausted. You can use the clock prescaler (c.f. chapter 9) to throttle down the clock to 8 MHz (minimum = 2.4 V), at which frequency you can use the full capacity of your batteries. But your timing functions will be off by a factor 2.

The Arduino doesn't require 5V.
The Atmel chip on the board requires somewhere between 1.8V and 5.5V, the Arduino just happens to have chosen 5V as a good common widely used voltage to run at.
If you provide a voltage within that range to the +5V pin the board will operate.  There's a couple of caveats though:

Anything below about 4V will mean the 3.3V regulator won't be working right, so the 3.3V pin won't be functioning properly
At lower voltages the Atmel chip can't operate reliably at higher frequencies, which is why 3.3V Arduino boards operate at 8MHz instead of 16Mhz.

So 3 x AA batteries is a perfect power source for running the Arduino, direct into the 5V pin.  Just make sure that you don't power it any other way at the same time or you'll be pumping 5V into your batteries.  You may want to add a Schottky diode in series with your battery + (between battery + and the 5V pin) to stop that ever causing a problem.  Choose one with a very low forward voltage drop though, otherwise you could end up dropping too much of your precious voltage over the diode.
By the way, when you're powering it from USB the 5V could be anywhere between 4.75V and 5.25V.

So the 5V output pin is a 5V input pin at the same time?

@bytecode77 The 5V pin doesn't have a "direction". It's just a connection to the 5V power rail.  You can use power from it, or you can give power to it, depending on what power you have where.

Good. Very nice answer by the way. Lots of facts, information beyond the asked question. +1!

For battery-operated Arduino Uno's I recommend thinking bigger (in terms of power, not physical size).
I power several by using 3x 18650 batteries in series, (providing about 14 Volts, connected to a 4x USB 5 Volt module.
The Unos are connected to power by a standard USB cable (into the programming port), and then you also have 3 other 5V USB charging or power ports available.
Or you can get a small converter unit that provides just one 5V USB.
Either way, bringing the power to the UNO is as simple as using the programming cable that comes with the board.
Or you can use any other converter and use wires to bring in Vin and GND.
You don't need to use 3 of the 18650s.  2 will do fine.  Or 4 in series/parallel for longer battery life.  No converter would be needed but again you would need wires to bring the voltage into the Unos.
18650s are very common, and are inexpensive.  They pack a whole lot more mAh than any AA battery you will find.
One warning about buying 18650s:  There are Chinese companies that advertise 9,800 mA batteries.  Don't believe it.  3,000 is about the max any reputable manufacturer will claim.

As per @Majenko's answer, yes, this will work fine.
Some caveats: the Atmel chip at the center of the Arduino has brown-out detection - if it drops below a certain voltage, the chip will shut down. This voltage is selectable: 4.3v, 2.7v, 1.8v, or off. The factory default for the chip is "off", I found a reference that the Uno sets this at 2.7V.
Also, if you are powering anything else with your battery, e.g. a motor, the voltage is will drop - if it drops below the brownout, the arduino will shut down (usually also shutting down the external device, causing the voltage to rise again, causing it to power up again). An LED (with a correct resistor) should be fine.

2.7V as the threshold sounds fair. And my components draw constant and very low current (I think).

Just something to remember if your project seems to be randomly resetting.

While I have your attention: How long do you think I can operate an LED, 4 seven segment displays and a buzzer (buzzer has a duty cycle or 7,5%) with 3 1.5 AA batteries?

@bytecode77 That depends if you invest some time in learning how to use sleep mode or not.  I am in the process of designing a PIC32 based system with LCD screen and all sorts that can run for a month off a small PP3 9V battery.

You mean that the Atmel chip doesn't consume energy when it doesn't do anything? As far as I saw it, delay() does nothing more than a blocking for-loop. But that's a different question, I will also look into that. Does the Arduino drain much current when running?

40-50mA while running. If you enable sleep you can reduce that significantly.

@Majenko "delay" draws about 50mA (same as doing anything else). You can, however, put the Arduino to sleep. If you want to save power, read Nick Gammon's most excellent treatise on the matter at http://www.gammon.com.au/power. Having said that, one LED uses 20mA (40% of the Arduino running at full power), I'd imagine 7 segments use that per-segment (check the data sheet!). There are tricks to reduce this - PWM being the usual one for LED and LED segments. I'm guessing you're not going to run the speaker continuously. How much the speaker draws depends on the speaker, and how much you use it.

Why are you telling me? Tell bytecode. By the way most LEDs are plenty bright enough at 1mA. Just because the upper limit its usually around 20mA doesn't mean you have to run them at that.

You can power the Arduino via the 5V pin - but you need make sure you disconnect it when you are connected via USB - ie. don't power both the 5V pin and via the USB.
Any even better way is to power it from the USB socket - I use those emergency Phone battery packs, but you could cut up a usb cable and use that - this is a much better socket fit to use than the 5v pin and more energy efficient than passing a higher voltage through the 9V supply.

The requirements of my project are tight and therefore batteries are the only options. But still useful information to keep in mind, thanks.

@user23096 - are you suggesting you could use the USB power socket  and still use batteries by wiring a AA batteries to a USB cable that is cut off at one end and the other end plugged into the board?  (I am a noob - forgive the stupid questions)

authors: Μάνος Σταθόπουλος