text:
Programming Micro controllers using Arduino ISP
Can I burn my Arduino Code into this:
http://www.microchip.com/wwwproducts/en/ATSAM3A4C
or something similar by just using just the Arduino ISP?

Arduino ISP is meant to program AVR microcontrollers. AFAIK, almost every AVR can be programmed this way, but other microcontroller families (ARM, PIC...) will most probably not work.

Page does nog exist (404).
Also, to run actual Arduino code on it, you'll most likely have to port the Arduino library, if this hasn't been done before.
You may opt for something as easy as a teensy 3.2, they probably meet your requirements and work well in combination with Arduino.
Or fetch one of the newer Arduino models that have comparable microcontrollers
If you still want an M3 (without development board?) you'll be entering a somewhat advanced usecase, in which you probably don't even want to rely on or use Arduino. There are far better IDE's.

Can you go to that website please.

I want to use that chip using the Arduino ISP

Ah okay, is that chip mounted on a board/PCB? Or are you simply looking for something like the due https://www.arduino.cc/en/Main/arduinoBoardDue which has a cortex m3

On a adapter board.

Hmm, the datasheet doesn't mention ICSP,  I don't think it's compatible, since ARM based boards are mich different.

So with what kind of boards do you think I can use.

Can we do something like this

Read the section about bootloader ROM on this chip.

I don't know about that chip I think this one also can be done as some of the other chips can be programmed using the Arduino ISP  I think it can be even done for this one. This one uses an AVR ISP Programmer while we are using the Arduino one but as they have similar working It is maybe possible. For example this one


text:
Modbus RTU slave library
I want to use an Arduino Genuino Zero as a Modbus slave. I tried to search on google, and found a library. When I try using the library, I get a timeout error.
Can anyone tell me how to solve that error? Did anyone manage to get the Arduino Modbus RTU slave library working?

Please provide additional details. What is the master device? Check whether baud rate, parity bit, data bit are set properly. And if possible provide the git repository of the library you are using.

http://www.electronhacks.com/2014/04/arduino-modbus-plc-rtu/

i find library from this

as master i am using simulator and simulator's name is modbus poll

so i edited code your as below
    #define mySerial Serial1
byte test_data[8] = {0x01,0x03,0x00,0x64,0x00,0x02,0x85,0xD4};

int data_count = 5;

void setup() {

mySerial.begin(9600);
Serial.begin(9600);
delay(1000);

}
int count = 0;
void loop() {

  if(count%10 == 0) {
    Serial.println();
    send_data();
  }

  count++;

  while(mySerial.available()>0)
  {
    byte b=mySerial.read();
    delay(1);
    Serial.print(b,HEX);
    Serial.print(" ");
  }
  //Serial.println(count);
  while(Serial.available())
  {

    byte a=Serial.read();
    delay(1);
    mySerial.print(a);

  }

  delay(1000);

}

void send_data() {
  Serial.println("send data");

  delay(1);
  for(char i=0;i<8;i++){
    mySerial.write(test_data[i]);
    delay(1);
    Serial.print(test_data[i],HEX);
    Serial.print(" ");
  }

  Serial.println();

  delay(1);

beside in slave library, which i have uploaded. i replace 'Serial' with 'Serial1' as i am using genuino zero.

but still i am not getting any response

Hey do you have any actual Modbus device?

you can use modscan32 software to retrieve data from slave device also. The software acts as a master device and you have slave device.

i have not any actual modbus device

yes, i have used modbus flow software which is working like master

but i am getting timeout error. so i asked question to check that my slave code is correct or not...!

Then you might conclude as so.

do you hav any working slave library??

no, I tested with my device as modbus master.

You can check out https://github.com/andresarmento/modbus-arduino/blob/master/README.md

He has used it as Modbus slave

connection is working fine. i am not getting any error. i used their lamp example to read coil. in that example, they set status of coil 1. but i am getting response "zero"

I am unable to simulate and see the result right now; I hope if the library functions properly this might be a communication issue. I can add a one step debug for you to check and see what is happening.
Your device is acting as a Modbus RTU slave, So take another Arduino, make it act it like a master device, and see what response is coming from the slave device.
Here is a glimpse of code I used to make arduino as a master and see the response coming in Serial terminal.
    #include <SoftwareSerial.h>
    #define rxPin 2
    #define txPin 3

    #define RS485_pin 10
    //SoftwareSerial mySerial(rxPin, txPin);
    #define mySerial Serial1

    byte test_data[8] = {0x01,0x03,0x00,0x64,0x00,0x02,0x85,0xD4};

    int data_count = 5;
    byte rcvdata[15];
    int param_value_int[7];

    void setup() {
      // put your setup code here, to run once:
    //mySerial.begin(19200,SERIAL_8E1);
    mySerial.begin(9600);
    Serial.begin(9600);
    delay(1000);
    pinMode(RS485_pin, OUTPUT);
    digitalWrite(RS485_pin,LOW);
    delay(100);
    }
    int count = 0;
    void loop() {

      if(count%10 == 0) {
        Serial.println();
        send_data();
      }

      count++;

      while(mySerial.available()>0)
      {
        byte b=mySerial.read();
        delay(1);
        Serial.print(b,HEX);
        Serial.print(" ");
      }
      //Serial.println(count);
      while(Serial.available())
      {
        digitalWrite(RS485_pin,HIGH);
        byte a=Serial.read();
        delay(1);
        mySerial.print(a);
        digitalWrite(RS485_pin,LOW);
       // Serial.print(a);
      }

      delay(1000);
      //while(1);
    }

    void send_data() {
      Serial.println("send data");

      digitalWrite(RS485_pin,HIGH);
      delay(1);
      for(char i=0;i<8;i++){
        mySerial.write(test_data[i]);
        delay(1);
        Serial.print(test_data[i],HEX);
        Serial.print(" ");
      }

      Serial.println();
      digitalWrite(RS485_pin,LOW);
      delay(1);
    }

Here you can use Software Serial or normal Serial1 or Serial2 on devices like Mega. Make sure if it is RS485 based you have to toggle the RS485 read-write pin each time to enable and disable one feature at a time as RS 485 uses half-duplex communication.
In this case test_data[] uses Function code FC03 Read holding register. You can make your custom data. I am assuming you are familiar with all the types available.Still there is a great site [   link ] to look up to if you don't know the basics. The last two bytes are checksum. And there is an online checksum calculator available if you need also
 https://www.lammertbies.nl/comm/info/crc-calculation.html
In this way you can at least debug and share the result, so that we can help more.

Comments are not for extended discussion; this conversation has been moved to chat.

This isn't a forum. Comments on the question are for clarification of the question, not for experimenting with different ways of solving the problem.

source: Stack Exchange

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

sort: votes


text:
Sketch Memory and EEPROM
Since I'm running out of sketch memory, I've decided to use the 512 bytes of EEPROM memory by using EEPROM.put(addr,variable). But every time I use this my sketch memory use in gradually increasing. What am I missing in writing data to EEPROM? Why is the sketch memory use increasing? I'm using Arduino Pro Mini.

The same answer than to your previous question

@gre_gor  NO  , im asking why is the sketch memory increasing when i use EEPROM.put call .@Mikael Patel has delivered an appropiate answer see that :)

What am i Missing in writing data to EEPROM ? Why is the Sketch memory getting increased ?

Reading and writing to EEPROM will increase program memory size. They are function calls. One way to reduce code is to read/write blocks instead of single bytes. Post some code and we can help you rewrite to something smaller. There are plenty of tricks.

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


text:
How to find if AC Appliance is on or off using ACS712 current Sensor
I am trying to get the status of appliance using current sensor. My Circuit looks like below image. I don't want to measure current. I just want to know whether appliance is on or off.

I am getting following readings when power turned on and off, I don't see any difference, I am not able to figure out whether the bulb is on or off.

Please help me to know the status of appliance/bulb.
PS. Please find my code below:
/*
Measuring AC Current Using ACS712
www.circuits4you.com
*/
const int sensorIn = A0;
int mVperAmp = 185; // Use 100 for 20A Module and 66 for 30A Module

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;

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

void loop(){

 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707;  //root 2 is 0.707
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");
}

float getVPP()
{
  float result;
  int readValue;             // value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;       // store min value here

   uint32_t start_time = millis();
   while((millis()-start_time) < 1000)  // sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue)
       {
            /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue)
       {
           /*record the minimum sensor value*/
           minValue = readValue;
       }
   }

   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;

   return result;
 }

Show your code.

Hi @EnricBlanco thanks for prompt response,Please find the code above.

Is your ACS712 module made to be used with the mains voltage ? Most are not. The ACS712 modules are sensitive for magnetic fields from transformers and wires. They are also noisy. If you, for example, have a 5A ACS712 module and want to measure 0.1A, the measurement could be lost in the noise. The sketch collects the minimum and maximum peak, therefor the sketch collects also the noise peaks. A current transformer does not need direct contact and is a lot safer.

another issue is that AC has no current at the zero-cross, so you need some sort of timing to get RMS

The code looks like it would produce rather larger values than you are seeing, if it gets correct inputs from the sensor.  For that reason, you probably should carefully check your wiring.  Also, with a DVM, measure the sensor output voltage with the light on and with it off, to verify sensor operation.  If you measure ok sensor voltages but don't get good readings, your analog input pin may have a problem; you could try other analog input pins.
Note, when debugging an issue like this, it does not make sense to run a few numbers through five levels of processing before printing anything out.  You should at least add serial prints in getVPP(), and just before returning the result, print out result, maxValue, and minValue.
Note, fix the erroneous comment “//root 2 is 0.707”; the square root of 2 is about 1.414213562, while 1/√2 = (√2)/2 is about 0.707106781.

230v/100W = 0,44A so it should be a clear difference between off current and on current.


text:
AES 128 CBC mode Help
Firstly i printed input[16] then encrypted it and printed the cipher and finally decrypted and printed input[16] but why my result is not matching after decryption ???????
I tried with different baud rate and also different input output array but not working.
Library Used: https://rweather.github.io/arduinolibs/classCBC.html
#include <CBC.h>
#include<AES.h>
CBC<AES128> cbc;

 void setup() {
 // put your setup code here, to run once:
 Serial.begin(9600);

 uint8_t key[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
 uint8_t iv[16] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
uint8_t input[16] = {0,1,2,3,0,0,0,0,0,1,1,1,2,2,3,3};
size_t len = 16;

cbc.setKey(key, 16);
cbc.setIV(iv, 16);

for(int i=0; i<16; i++)
Serial.print(input[i]);
Serial.println("");

cbc.encrypt(input, input, len);
delay(1000);

Serial.print("input:");
for(int i=0; i<16; i++)
Serial.print(input[i]);
Serial.println("");

cbc.decrypt(input, input, len);
delay(1000);

Serial.print("input:");
for(int i=0; i<16; i++)
Serial.print(input[i]);
Serial.println("");

cbc.clear();
}

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

}

Create a separate output array. Currently the output variable is the same as the input. Depending on the algorithm this can be problematic.


text:
Using N mosfet to switch ESC to BLDC phases
I have an ESC that powers 36v 3 phase BLDC motor. The ESC has limited functionality and can power motor only in one direction. If I switch manually two of the ESC to Motor phase connections, than the motor direction will change. Now, I want to do the same i.e. switching phase to phase connections with 4 power mosfets.
As in scheme, the blue ESC phase will be connected to Mosfet source and the drain will be connected to Motors yellow phase. The next mosfet will connect to ESC yellow at source and motor blue at drain.  Two other mosfets will connect blue to blue and yellow to yellow.
I won't  do the switching while motor is on so I assume it should be safe.
How can I connect MOSFET's gate to Arduino ?
I need no pwm just ON/OFF.

you want a "mosfet driver", opto-isolated if possible. i make my own with 3 red LEDs in series used as a photovolatic source driven by a white LED at 3.3v, which results in ~5v output. then the red cathode is connected to source, and the annode to gate. that way, there's no electrical connection to the MCU and Vgs never gets far from Vd... A small solar cell can work as well, light it with the MCU.

the Mosfet I am using is logical level so the gate voltage is about the same as  arduino output

well if you can share the ground with the MCU it's not an issue; but if you have to power it inline, you need to watch the max VGS

This is not going to be practical given that you basically need to switch AC power, you would far, far, far better off getting a bidirectional ESC or seeing if it is one of those which can have an unofficial aftermarket open source firmware installed.  Additionally, this is an electronics question that has nothing really to do with Arduino.

if it's AC, you need two mosfets back to back to allow current in both polarities.

@dandavis and a non-trivial drive structure.  The AC signals the poster wants to switch are each already coming from a MOSFET half-bridge sourced from an actual DC rail; what should be changed is the software controlling those - doing it afterwards is awkward enough to eliminate any gain over using a suitable bidirectional ESC to start with.

This is covered fairly well in an EDN.com “MOSFET pair makes simple SPDT switch” article.  You would use two of the SPDT circuits to make a DPDT.  Attach switch commons to yellow and blue, and attach the “switch points” of one circuit to motor yellow and blue, and those of the other vice versa.  Attach both control pins to one Arduino IO pin.  The picture below comes from the referenced article, which shows the circuit in use for a primary-power vs secondary-power application.   See the article for details.

Sorry I can't still understand the control part. In most switch schemes I have seen the MOSFET is used on ground wire, and the mosfet source is connected to arduino ground. But in case the source/drain is V+ how can  arduino & mosfets have common ground?

@Naho, I don't know.  The capacitor may be related to having a common reference.  But l guess I don't know enough about the ESC wiring to know whether grounds can be common.  You might have to use optoisolators as someone suggested.

This will not work, the requirement is effectively for an AC switch.  Driving two of them in complement is the trivially easy part.


text:
Trying to make arduino heart beat counter but couldn't understand code
I am trying to make an Arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the given code .. specifically these few lines of code:
The full code is given below:
int sensorValue = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor
int count = 0;
unsigned long time1 = 0;  // store the initial time
unsigned long time2;    // store the current time
void setup() {
    // declare the ledPin as an OUTPUT:
    pinMode(sensorPin, INPUT);
    Serial.begin(9600);
}

void loop() {
    // read the value from the sensor:
    if (count == 0)
    {
        time1 = millis();
    }
    time2 = millis();
    sensorValue = analogRead(sensorPin);
    if (sensorValue > 156)
    {
        increment();
    }
    if (time2 >= time1 + 10000)
    {
        counter();
    }

}

void increment()
{
    count++;
    while (sensorValue > 156)
    {
        Serial.print("Sensor value is greater than .75V\n");
    }
}
void counter()
{
    count = count * 6;
    Serial.print("Heart beat is ");
    Serial.print(count);
    Serial.print(" per min\n");
    time1 = 0;
    time2 = 0;
    count = 0;
}

Lines of code I'm not able to understand :
if (count == 0)
{
    time1 = millis();
}
time2 = millis();
sensorValue = analogRead(sensorPin);
if (sensorValue > 156)
{
    increment();
}
if (time2 >= time1 + 10000)
{
    counter();
}

PS: the given code is in void loop(). in the beginning of the loop.
if u are not able to understand the code i'm leaving a link to the page:this is the link
i would be highly obliged if anyone could really help me soon. Thank u in advance :-)

Just copy paste the code. Don't post screenshot of it.

What exactly don't you udnerstand in this code. Note that this code is using functions (increment(), counter()) that you did not post, hence it will be difficult to answer. As already commented, don't post pictures of code as this would make it more difficult to copy paste into an answer. Finally, provide the exact link where you found this source code.

jfpoilpret i made some revisions in the code now can you help me

I've reformatted you code to make it easier to read.
Looking just at the lines you don't understand.
Line 1 stores the start time of this loop in the variable time1 and stores the current time in the variable time2  these are going to be almost identical until the first heart beat is seen (which will increment count).
Line 6 sensorValue = analogRead(sensorPin); reads the value from the sensor, it the reading is greater than some predetermined threshold (156) then it increment() the counter and waits until the value goes below 156.
Line 11 checks to see if 10 seconds (10,000 mS) have elapsed since the loop started.  If they have then you get your reading via the function counter()
Does that make sense?
It would be a lot easier to understand if the original author had put comments in, but most people writing examples assume there code is so easy to understand they don't need to, don't fall into that trap when you become a great programmer! :)


text:
Arduino -> Processing conversion: creating mux channels
As the title alludes to, I'm in the process of converting an Arduino sketch to a Processing sketch. So far, mostly pretty straightforward.
I'm running into an issue with creating an array of ints for the channels for two muxers. Below is the code that I currently have working for the Arduino sketch:
int writeMux(int channel){
  int controlPin[] = {s0, s1, s2, s3, s4, s5, s6, s7};

  int muxChannel[20][8]={
    //Mux 1
    {0,0,0,0,0,0,0,0}, //channel 0
    {1,0,0,0,0,0,0,0}, //channel 1
    {0,1,0,0,0,0,0,0}, //channel 2
    {1,1,0,0,0,0,0,0}, //channel 3
    {0,0,1,0,0,0,0,0}, //channel 4
    {1,0,1,0,0,0,0,0}, //channel 5
    {0,1,1,0,0,0,0,0}, //channel 6
    {1,1,1,0,0,0,0,0}, //channel 7
    {0,0,0,1,0,0,0,0}, //channel 8
    {1,0,0,1,0,0,0,0}, //channel 9

    //Max 2
    {1,1,1,1,0,0,0,0}, //channel 0
    {1,1,1,1,1,0,0,0}, //channel 1
    {1,1,1,1,0,1,0,0}, //channel 2
    {1,1,1,1,1,1,0,0}, //channel 3
    {1,1,1,1,0,0,1,0}, //channel 4
    {1,1,1,1,1,0,1,0}, //channel 5
    {1,1,1,1,0,1,1,0}, //channel 6
    {1,1,1,1,1,1,1,0}, //channel 7
    {1,1,1,1,0,0,0,1}, //channel 8
    {1,1,1,1,1,0,0,1}, //channel 9
  };

  //loop through the 4 sig
  for(int i = 0; i < 8; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //write the value at the SIG pin
  analogWrite(SIG_pin, testValue);

  //return the value
  return 0;
}

Below is the slightly varied version that I'm using for my Processing-equivelent sketch.
int readMux(int channel){
  int controlPin[] = {s0, s1, s2, s3};

  int muxChannel[20][8]={
    //Mux 1
    {0,0,0,0,0,0,0,0}, //channel 0
    {1,0,0,0,0,0,0,0}, //channel 1
    {0,1,0,0,0,0,0,0}, //channel 2
    {1,1,0,0,0,0,0,0}, //channel 3
    {0,0,1,0,0,0,0,0}, //channel 4
    {1,0,1,0,0,0,0,0}, //channel 5
    {0,1,1,0,0,0,0,0}, //channel 6
    {1,1,1,0,0,0,0,0}, //channel 7
    {0,0,0,1,0,0,0,0}, //channel 8
    {1,0,0,1,0,0,0,0}, //channel 9

    //Max 2
    {1,1,1,1,0,0,0,0}, //channel 0
    {1,1,1,1,1,0,0,0}, //channel 1
    {1,1,1,1,0,1,0,0}, //channel 2
    {1,1,1,1,1,1,0,0}, //channel 3
    {1,1,1,1,0,0,1,0}, //channel 4
    {1,1,1,1,1,0,1,0}, //channel 5
    {1,1,1,1,0,1,1,0}, //channel 6
    {1,1,1,1,1,1,1,0}, //channel 7
    {1,1,1,1,0,0,0,1}, //channel 8
    {1,1,1,1,1,0,0,1}, //channel 9
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //write the value at the SIG pin
  arduino.analogWrite(SIG_pin, testValue);

  int val = 0;
  return val;
}

I'm currently getting an error of unexpected token: int error at the following line:
  int muxChannel[20][8]={

And, an error of The type of expression must be an array type but it resolved to int at this line:
digitalWrite(controlPin[i], muxChannel[channel][i]);

Thank you!

You don't need to be a Java expert, your code is C.

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html


text:
Power suply for MicroSD card breakout board
I'm developing a project and I need to connect to my Arduino Mini with a SD card breakout board. The problem is that I can't plug it directly to the Arduino since it is already powering some sensors and a BITalino, and I was told that it would, for some reason, be better to connect an external battery to the SD board.
My question is if i can supply this  MICROSD CARD BREAKOUT BOARD+ with a 3.7V battery, instead of a 5V.
Thank you!
Description:

Onboard 5V->3V regulator provides 150mA for power-hungry cards
3V level shifting means you can use this with ease on either 3V or 5V systems

I don't see why you can't use the same power supply. Using a separate battery seems silly to me.

SD cards don't use much juice, you could probably run them of off GPIO pins pulled low/high

My question is if i can suply this MICROSD CARD BREAKOUT BOARD+ with a
  3.7V battery, instead of a 5V.

Yes you can supply MICRO SD Card Breakout with 3.7 volt battery as it has onboard voltage regulator which will provide required voltage to the board.

I was told that it would, for some reason, be better to connect an
  external battery to the SD board.

Because every sensor will take 3V - 5V as per its requirement. So some time Arduino can not be able to provide 3.3 - 3.5 volt to SD Card board and there could be no data logging or some wrong data logging to SD card. Thus it is advised to do such.

Yes you can give power supply to MICROSD CARD BREAKOUT BOARD from a 3.7V battery It has Onboard LP98x Voltage regulator winch provide 3.3V regulated power supply.
Take reference from here Schematic of MICROSD CARD BREAKOUT BOARD

You just need to bypass the Pro Mini regulator in order to avoid loading it too much, because the uSD Card board already has one.
Instead of connecting the uSD Card breakout board to the VCC pin, connect it to the RAW pin. Provided that your power source (3.7V battery? wall adapter?) can source enough current for the Pro Mini plus the uSD card board (something that's very likely), everything will be fine. No need to add any extra power source.
The regulators in those boards have very similar dropout characteristics (300-400mV).

The "some reason [it would] be better to connect an external battery to the SD board" is that you need to make sure that the controller chip and SD card are getting enough power that it can write reliably.
To figure out whether and what kind of external power you need you start with the specifications. The first clue is in the general product description to which you linked; it says that it has an "Onboard 5v->3v regulator" that "provides 150mA for power-hungry cards." This is a good start, but you'll see below that we'll need further information from a link on the tutorial page.
Linear power regulators give a fixed voltage output (in this case, 3 V) from a higher voltage input. To work properly they need an input voltage a bit higher than their output voltage; the minimum difference between the two is called the dropout voltage. From the schematic we can see that the board is using an LP298x regulator. A datasheet for a (hopefully typical) part from that series indicates that dropout voltage is 300 mV or 0.3 V. 3.7 V is considerably higher than 3 V + 0.3 V, so you're very likely to be ok in that respect with your external battery. (We also note here that the input voltage can range up to 16 V; we'll use this information later.)
The other thing you need to look at is whether you can supply enough current to the board and card that, under all reasonable circumstances, they can function properly. From the original description you know the board uses a 150 mA regulator which means that the designers expect that you'd never need more than that. (And if you do, the card isn't going to get it anyway.)
For simplicity it's easiest just go go with being able to provide 150 mA or more on the regulator's input, regardless of voltage. (In theory you can supply less power on input if you're giving it a higher voltage, because P = EI, but it's not generally worth the time and effort to go there for a hobbyist project.)
Batteries have a discharge rates known as C rates, and unless you know what you're doing (I don't :-)) your best bet is to stay well within the standard discharge rate as specified by the manufacturer. Adafruit sells a typical 3.7v 1200mAh Lithium Ion Polymer Battery; looking at its datasheet we see that the standard discharge current is 0.5 C5 A, which is 0.5 * 1200 mAh / 1 h = 600 mA, plenty more than you need. So if you're using that battery you'd be safe. (I started out by looking at the 500 mAh battery which has a  0.2 C5 A = 100 mA standard discharge rate; my guess is that that's fine because the maximum discharge rate is 1 C5 A, but this has implications on battery capacity and the like so I'd ask someone first.)
But it would be nice to use your existing power supply for the card rather than use a separate battery, I'm sure. Your best bet for that is the suggestion from  Enric Blanco: use an external power supply that can deliver enough current to both the Arduino Pro regulator and the SD Card breakout board regulator that they'll both be happy.
Sadly, Adafruit's Ardiuno Mini product page gives no indication of current requirements. However, a quick look at the v5 schematic we can see that it's using an LP2985AIM5-5.0 regulator and a web search turns up a product page for this that says it's rated at 150 mA.
Add the 150 mA for the Arduino Mini to the 150 mA for the SD card board and you can figure that any external power supply that is giving more than 300 mA at the minimum 7 V input voltage specified for the Arduino Mini should be just fine. The 7 V should also be ok for the SD card board regulator since, even if it's a slightly different model from our spec. sheet, it's unlikely to have a maximum voltage hugely below the 16 V for that part. But you could check the exact part your board is using if you're worried.


text:
Will an ATmega2560 board be faster than a Uno for hard real-time data logging?
I am designing a hard real-time data logger. The Uno is a bit marginal in processing speed.
a) Would it be faster if I changed to an ATmega2560?
b) On the datasheet, ATMEGA2560 has 135 instructions; it is 4 instructions more than the ATmega328p.
What are the extra 4 instructions for?
Are they involved in floating point maths?
c) How to select compiler option for fastest code at the expense of bigger code size, longer compilation time, etc.?
The system is:

Receive data from wireless transceiver chip via hardware SPI port.
A good portion of the time is spent on data calculation using floating point maths.
Output processed data on serial port (then to PC via the Arduino board USB to Serial chip).
Code and RAM size is not an issue, Uno has plenty space left.

The Uno is actually faster than the Mega, especially if there is a high frequency of function calls and return. Easiest way to check this is to simply read the number of clock cycles for typical instruction sequences.

If you need speed replace the floating point math with fixed point. And to reduce latency pipeline input/output with the processing.

If you are concerned about performance, don't use an ATmega-based Arduino at all.  Today's ARM parts, from many vendors (even Atmel themselves) are many times faster, no more expensive, work better on low battery voltages, and several have Arduino ports.

If it's connected to a PC, then you could just offload the calculation to the PC. But I'd first do some measurements and see if there is even a problem, and where this problem lays. Could you for example speed up the SPI clock. Doing optimizations without measurements is just silly, as you don't know if they worked, or if they made things even worst.

@Chris Stratton, could you please list some example parts, if it is not against the 'rules' for this forum. (Can I ask this under forum rules) Is STM323F1xx a good choice? assume able to use its (non Arduino) development package and IDE STM32CubeMX.

No, it will not be any faster. The extra instructions are to access the extra flash memory of the 2560. Instructions like EIJMP - Extended indirect jump, EICALL - Extended indirect call, etc.
The compiler option -O3 optimises the most, but there are other options you can enable, such as -funroll-loops which will cause major code bloat but speed things up.  Read the GCC manual pages to boggle at all the millions of optimisation options.
Or... use a faster chip, like an ARM or PIC32.

Use the newest Arduino IDE, because some time ago the 'lto' option was added which is a major optimization for both speed and size.
It is possible to test a few compiler options with the #pragma. Try for example these at the top of the sketch:
#pragma GCC optimize("-O3")
#pragma GCC optimize("-ffast-math")

The 'fast-math' is dangerous, be careful with it.
The Arduino Zero and Arduino Due are faster but not a lot faster, because they are not fast with analogRead() and with floating point calculations.
A common mistake is that someone asks for a faster Arduino board, but uses a sketch and libraries with a lot of delay() in it. That won't be any faster with an other Arduino board. Have a good look at your code and at the source code of the used libraries.
Have you tried increasing the baudrate for outgoing data ? If that baudrate is slow, the whole sketch is slowed down because the Serial functions will wait until they can write the data into the Serial buffer. The fastest "baudrate" can be achieved with the Leonardo, Micro and Pro Micro boards. They transmit the data directly onto the USB bus without using the baudrate.

In the platform.txt file found in ~/Arduino15/packages/arduino/hardware/avr/1.6.17 or similar, you can change the three instances of -Os with -Ofast. The size of the code can increase dramatically though.

They have very nearly the same instruction set and the same execution speed, so there will be no increase there. If your project spends a significant amount of time in floating-point arithmetic, replacing it with fixed point arithmetic will give you a noticeable speed up. If a few calculations are executed repeatedly (which is typical), you can get most of the advantage by rewriting only that part.
In a nutshell, fixed point arithmetic is what the computer does already, but with an assumed binary point (just like a decimal point) always to the right of the least significant bit. Fixed point arithmetic uses the built-in arithmetic, but you assume the binary point to be wherever you need it, keep track of it during multiplies and divides, and make sure you keep the intermediate results from overflowing.
Search for Fixed Point Arithmetic and you'll find out a whole lot more.


text:
Interfacing with TC5564APL-15 paralell static ram
I've found a Z80 processor and a TC5564APL-15 8K static ram chips, and I want to test the RAM chip, because it's really old and I'm not sure that it's not damaged. I do not have any experience with Z80's and RAM chip's, I'm not even sure that I didn't damage it while desoldering. I found THIS forum link, where a guy wanted to use a different RAM chip, but the code looked OK and I've took it. I did some modifications:

I only own one 74HC595, so I used that, I've connected the remaining address lines to 5V via 200Ohm resistors
I did not use any capacitors.
I've changed some connections.

Here's the modified code:
https://pastebin.com/9nfTQY8X
(Sorry for PB)
So it SHOULD print "0 0 0 8 / 0 0 0 8" to the serial, but it prints "0 0 0 8 / 8 8 8 8". The reason is unknown. Every other number works, I only found that specific bit not working correctly.
I'm not sure. Can my RAM chip be broken, or the circuit causes the problems?

Add a capacitor (0.1 uF at least) to the RAM chip.

I'm voting to close this question as off-topic because it's about Z80 and old memory chips; no Arduino involved.

The "modified code" on PasteBin has been deleted so there is definitely no way to answer this question as it stands.


text:
Getting Bluetooth addresses of connected devices via Arduino Uno?
I want to find all the Bluetooth addresses of connected devices using  an HC-05/HC-06 Bluetooth module and an Arduino. I can't find any code related to this. Basically I need the addresses to put in an array. Is it possible to do this with an HC-05 or 06?

This question isn't really about Arduino, and the goal expressed in your responses to answers of having someone supply the entire unspecified solution isn't really compatible with the specific-question model of the Stack Exchange sites.  Your city has several hackerspaces and similar creative communities, perhaps you would find it interesting to visit one of their open days and get a sense of how people create things like this, for themselves or as work projects.  Alternatively, to get help on this and related sites, questions need to be about a specific, singular on-topic goal.

The HC-05 has an AT command, AT+BIND?, that will tell you which slave device it is connected with currently. Since you can connect to one device only at the same time, your array is going to be a very short one.
AT+INQ will provide you with a list of nearby devices, to which it can connect.

can you please send me the entire code as i m new to arduino. It will be very helpful. Thank you.

@OliviaJohnson Anyone can send you the entire code and do the job for you, if you accept to hire them for this task. StackExchange is not a site for that: you need to demonstrate what you have tried so far.

You just have to send the above Bluetooth command via serial port to your Bluetooth module using print command.
For example yourserial.print("AT+BIND?"); OR yourserial.print("AT+INQ"); if you are using SoftwareSerial. Otherwise just use Serial.print("AT+BIND?"); OR Serial.print("AT+INQ"); when using Rx/Tx pins. That will do the job.

thanks. but can u also tell me which sensor should i use for this project

and also please provide the entire code


text:
Error trying to compile an example from newly added Arduino menu library
I added the ArduinoMenu library https://github.com/neu-rah/ArduinoMenu and when I try to compile one of the examples, I get following error.

Using library LiquidCrystal at version 1.0.5 in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560.

How can I fix this?

We need the full error output, not just the last couple lines that happened to be visible. If you were observant you would have seen that there is a scroll bar on the right side of the black console window at the bottom of the Arduino IDE window that indicates you can scroll up to see more text. Spend some time reading those errors and doing research to see if you can figure out what's wrong on your own. After that if you still can't solve the problem click the button on the right side of the orange bar after an error "Copy error messages" then edit your question to include the full error.

I think you have to add your library in the library folder. Below is the path of that folder. It will help you.
C:\Program Files (x86)\Arduino\libraries

You should never install a library to the Arduino IDE installation folder because it will be lost if you update to a new version of the IDE. If you're doing a manual library installation you should always install them to the libraries subfolder of the sketchbook folder. The location of the sketchbook folder can be found at File > Preferences > Sketchbook location.

@per1234 Yes, you're right. But everyone uses this method and it's working fine.

@per1234... This is the simplest way to add library by just copy and paste.

there are better places for libraries. the install folder is for core, and customizing it is asking for trouble

@Hasan if by "everyone" you mean unfortunate beginners who found some bad advice on the internet. And no, it's not working fine, as I already explained.

@karanrp it's no more simple than installing to the sketchbook folder and much less so when you update and find all your 3rd party and custom libraries have disappeared.

please install from arduino ide library manager

Can you compile the LCD example for that board?
just to make sure you have LiquidCrystal library ok.
Then tell us what was the example? There are hardware specific examples.
Also try to compile the serial menu example, just to make sure that ArduinoMenu library is ok for your board.


text:
How to restart a counter in a program using a push button in a LDR Tripwire setup
So, trying to configure this code so that when I push the button, the person counter will go to zero and just as it goes, the counter will increase when the LDR will get tripped and again when the button is pressed, the counter will go to 0.
#include <LiquidCrystal.h>

int laser=8;
int pushbutton=12;
int flag=0;
int myCounter = 0;
LiquidCrystal lcd(7,6,5,4,3);

void setup()
{
    pinMode(laser,OUTPUT); pinMode(pushbutton,INPUT);
    lcd.begin(16, 2);
    lcd.print("Person Counter:"); lcd.setCursor(0,1);
    lcd.print(0);
}

void loop()
{
    lcd.setCursor(0, 1);
    digitalWrite(laser,HIGH);

    if(analogRead(A0) < 600) //A0= LDR
    {
        flag = 1;
    }

    if(analogRead(A0) > 600 && flag == 1)
    {
        myCounter++;
        delay(200);
        lcd.print(myCounter);
        delay(20);
        flag=0;
    }
}

Try out this code. I made some modification and also comment out that things.
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3);

int laser = 8;
int pushbutton = 12;
int flag = 0;
int myCounter = 0;

void setup()
{
  pinMode(laser,OUTPUT);
  pinMode(pushbutton,INPUT_PULLUP); // Provide pull-up

  lcd.begin(16, 2);
  lcd.print("Person Counter:");
  lcd.setCursor(0,1);
  lcd.print(0);
}

void loop()
{
  lcd.setCursor(0, 1);
  digitalWrite(laser,HIGH);

  if(analogRead(A0) < 600) //A0= LDR
  {
    flag = 1;
  }

  if(analogRead(A0) > 600 && flag == 1)
  {
    myCounter++;
    delay(200);
    lcd.print(myCounter);
    delay(20);
    flag = 0;
  }

  if(digitalRead(pushbutton) == LOW) // When button pressed
  {
    myCounter = 0; // Set counter to 0
  }
}

Glad to help you.


text:
Can I share the VCC (5V) on my Arduino Pro mini with multiple modules?
Right now I am onto a new project where I am building an obstacle avoiding landrobot.
I use an arduino pro mini as my board and I have a few hc-sr04 sensors here at home. The problem I have right now is that many pins is occupied with other modules, motors and bluetooth.
So right now on my Pro Mini the VCC is occupied by my BLE device and I was wondering if there is a possibility to solder a few wires together so that my BLE device share the same VCC with 4 other hc-sr04 modules? I do this regularly with the GND where I solder multiple wires together and share the GND across different modules which works fine.
I have soldered a wire looking like this:

The idea is to power the arduino itself through the "RAW" pin. I have a power distribution board that connects to my battery/motor and the VIN pin of the PDB goes to the "RAW".
I try to avoid a breadboard to decrease the size as much as possible so if it were to be possible then that would be the optimal solution for this project.
Something I am also wondering is if it is possible to use these hc-sr04 on both the analog pins and also the digital pins. I do not have enough space to fit all the sensor cables on the digital pins but if I use the analog pins also then they all would fit. Is this possible? Each HC-sr04 has two cables that needs to be inserted (Trig and echo) and right now I have 3, 4 free and all the analog pins 0, 1, 2, 3, 4, 5 which is enough to fit them all.

You can indeed use analog pins as digital pins.

if your Vin=Vcc, then you can go up the supply's limit, if not, then limit it to the capabilities of your voltage regulator.

I use the "VCC" pin on the arduino pro mini to power the BLE and that is the pin i was thinking about sharing. I do not have a VIN on my arduino pro mini i think

This is how I will setup the entire project: I use a power distribution board that connects to my 4s lipo battery/motor. The GND of the power distribution goes to the GND and the VIN goes to the "RAW" of the arduino pro mini.

RAW is connected to the input to the regulator, whereas VCC is connected to its output. As a thumb of rule, you should connect your power source (battery, AC/DC adapter, whatever...) to RAW and then supply power through VCC to all the remaining modules (as long as maximum current output and power dissipation in the regulator are respected).

You mention motors. These typically consume a lot of power in comparison to the electronics in a project and it's not unusual to power them separately, as in this answer. That's where I would start, and then look at using on-board regulators on other boards, where available, as discussed in the answers to this question.

Yes, you can do that as long as the total current draw of the modules you attach to VCC doesn't exceed the on-board regulator maximum current output.
The Arduino Pro Mini has a MIC5205 regulator capable of delivering up to 150 mA, which is quite low if you plan to attach many modules to its output. So you should look through your modules datasheets and find out the total current draw, including the Pro Mini board itself, and check that against the 150 mA limit.
According to the HC-SR04 datasheet, each module draws 15 mA. The Arduino Pro Mini itself draws about about 20 mA. The BLE module peak current consumption is 12.5 mA at active RX and 11 mA at active TX, so lets say 25 mA peak current draw for the BLE module.
Everything adds up to a worst case 105 mA peak current draw, within the maximum 150 mA limit. So it should be fine, but I would avoid connecting much more modules to that VCC rail.

ADDED according to your additional question:
If you run out of digital I/O pins, you can use the analog pins as digital pins if needed.
Additional note (thanks go to @jwpat7 for pointing this out in the comments):
However, this is true only of A0–A5 on most Uno and Nano Micro Arduinos, and not true of A6, A7 (except on -PB MCU models like ATmega168PB and ATmega328PB, where A6, A7 can be used as digital pins).

Alright! I added a bit more info also if you missed it (in case it changes anything in your resonse).I use a power distribution board that connects to my lipo battery/motor. The GND of the power distribution goes to the GND and the VIN goes to the "RAW" of the arduino pro mini. So my lipo 4s will power the arduino pro mini itself

If i try it out, can it harm/damage the arduino pro mini/the other modules?

Avoid using the data pins as supply rails for your modules, at any cost. It may work but it's a bad idea.

what is a data pin? is that the "raw"?

@EnricBlanco: why is it a bad idea if it works?

@dandavis Because 1) it will increase power dissipation in the ATmega, 2) the supply current will be limited to 20 mA per pin, and 3) the output voltage of the pin isn't regulated and will drop with increasing load.

So just to confirm. This is the schematic (but I use a pro mini instead of uno) https://i.stack.imgur.com/tpb43.png so on Uno it is named "VIN" but on Arduino Pro Mini it is named "RAW" and that is where I insert it. Then I hook the BLE and all the hc-sr04 VCC/VIN to the VCC of the arduino pro mini that should land at 105mA peak as you mentioned above. Should work fine right?

Sorry, but I don't understand your diagram. What are the 4 ESC modules? How do the motors relate (connection-wise) to the arduino and its modules (including those ESCs), and how are the motors powered? Are you aware that switching high currents on/off (something that happens often when motors are involved) can induce high voltage spikes in shared power supply rails that can easiky fry regulators unless properly decoupled? Please understand that is unrealistic for you to expect that we can debug your entire project in the comments of a limited scope answer of a Q&A site.

I'm happy to keep helping, but it would be better to ask new focused and scope-limited questions as you come across new challenges and or doubts, instead of updating this post. That would be a better fit to the Q&A nature of this site, and will probably get you better overall answers and help.

Ok! I insert the lipo battery to the power distribution board and that powers both motors and the arduino. I succesfully make it work with a arduino uno so it should work with a arduino pro mini also i assume! :) Anyway aprpeciate your help a ton

If the Uno tolerated it then the Pro Mini should be fine as well.

I see a lot of demos powering LEDs (~2-15ma) from GPIO, and a lot of modules (ADCs, DHTs, etc) use less than 1ma; "at all cost" is too broad imho; follow the datasheets and you're fine.

@dandavis Fair enough. I agree that powering a LED from a GPIO should be fine because it's fairly tolerant to voltage as long as more than the forward voltage can be supplied and current is limited by a resistor. But I'll be very hesitant of connecting the power rail of any IC to a GPIO pin for a lot of reasons from noise to load effects. Of course, YMMV.

“If you run out of digital I/O pins, you can use the analog pins as digital pins if needed”,  is true only of A0–A5 on most Uno and Nano Micro Arduinos, and not true of A6, A7 [except on -PB MCU models like ATmega168PB and ATmega328PB, where A6, A7 can be used as digital pins]

@jwpat7 Thank you, I'll correct  that.

I connected everything now and powered up the arduino through USB and it seems to work well! :) The BLE is starting up and i seem to get results from all the hc-sr04 sensors. I will test it further tonight. Now it will be interesting to see if I can power up the arduino itself through the RAW via a lipo/power distribution setup!

To be frank you can use even your analog pins as digital pins as the analog pins are also digital pins but they are more enhanced
If you use a common Vcc you may not have enough power left for your board and when you share your ground it doesn't matter a lot as it is the -ve lead of your power  source and you may use an external power source

Ok. So sharing VCC can be problematic then but can work? If it doesnt work I assume breadboard is the only option left

I think it will not work

Of course! This one: https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout/hooking-everything-up

I think it will not work as you have tied too many things to a Mini board You may use an external battery or power source

This is how I will setup the entire project: I use a power distribution board that connects to my lipo battery/motor. The GND of the power distribution goes to the GND and the VIN goes to the "RAW" of the arduino pro mini. On the "VCC" i have the BLE currently and that is where I also plan to put the hc-sr04 sensors

So the idea is that the lipo battery will power the arduino through the "RAW" pin

Yes you can but I prefer to use a lm805 ic

Sagnik Peadhan, regarding “you can use even your analog pins as digital pins as the analog pins are also digital pins”, see my comment to Enric Blanco's answer


text:
Shield Compatible third party motor driver
I recently purchased an Arduino UNO along with some other hardware. At the time of purchase, I didn't know about Arduino's motor shield and so I purchased a two channel stepper motor driver (2A per channel) that was said to be "Shield Compatible". I recently received my hardware and have been following the introductory tutorials since I'm completely new to the Arduino platform. Things are going well but I didn't receive any documentation with the motor driver. There is a datasheet provided on the vendor's website but it is beyond my current level of competency.
My question: since the driver is said to be "Shield Compatible", does this mean that I can assume that I can interface with it the same way as an authentic Arduino shield. In other words, can I follow the motor shield tutorial on Arduino's website without any risk of damaging hardware and expect the driver I purchased to function properly.
The product that I purchased can be seen here: http://www.robotshop.com/ca/en/dual-bipolar-stepper-motor-controller-arduino.html

You should do you own research as the path followed here did not result in the identically pictured nor identically model numbered item.
You indicated you are using a certain Arduino motor driver board.  On that page there is an "made by" or "by" reference to an OEM.  On the OEM's web page there is a "Dual Bipolar Stepper Motor Shield for Arduino" but the part number and the picture do not (exactly) match your original link.  Regardless, there is what they are calling a "WIKI page" for this (slightly) different motor shield.  I scanned this page and the example code.  I don't see where any device driver is mentioned.  And I don't think the code will compile by its self.
In general, I suggest people who are starting out with Arduino's to stick with well known hardware and software.  Even then I have had problems with newly released hardware.  Also check if drivers and SDKs have been updated each time you start a project.
Another approach you might entertain is to follow a path starting with the chip used on your shield.  It appears to use two DRV8825.  (But I cannot be sure as pictures and model numbers do not (exactly) match.) Here is a discussion on the a well known Arduino web site where people are talking about boards with this chip on it.

Thanks. After a lot more reading, I connected the driver board onto my Arduino, powered it with an external supply and ran the code on the WIKI page that you linked to and everything is working fine.

Good to hear you had success!


text:
How do I connect Arduino to RS232 via USB?
I have a device that takes commands in the form of RS232 communication. I've connected the Arduino's USB port, through an adapter, to the device's 9-pin serial port, but no communication has happened.
The full chain of adapters is a printer cable (which would connect the Arduino to a computer), a female-to-female usb adapter, and a Sabrent USB to serial adapter.
I made sure the communication wasn't happening using the code while (!Serial) and blinked an LED in a certain pattern.
Is there something I'm missing? How do you get the devices to communicate?

This sounds a lot like an April fools joke.

That is rather inconvenient. In this case, though, Arduino is just not my strong suit.

This is effectively not workable.  USB is not a peer-to-peer standard, but a host/device one.  Both your Arduino and the USB-serial converter are intended to be devices, so they cannot communicate.  While it would be possible to use another microcontroller acting as a host to bridge to serial that would be pointless, as the actually central problem of RS232 vs. logic level serial would still need to be solved.
Instead, what you want is an inverting serial level shifter - essentially a board with an IC like a MAX232 or one its many successors.  You would either connect this to arbitrary digital pins of the Arduino and use a Software Serial instance, or decide that it is okay to block usage of the USB port by a computer while this is being operated, in which case you could connect it to the D0 & D1 pins used by the on-board USB interface (there are typically resistors in between the chips on the board to support this overriding).
Ironically, in a way what you want is one of the original Arduino boards that had a serial level shifter and 9-pin connector in place of the USB chip and USB connector of modern boards.  But then, you probably want something with an ATMega328p rather than the earlier, more primitive ATmega chips used on the original boards.  If you can still find a board of the original design, upgrading the chip may be an option, or it may be that your task is simple enough not to require it.
There have been many other non-Arduino embedded controller boards released with native RS232 ports as well, especially those dating from around a decade ago might give a good combination of fairly modern capability with not yet having abandoned RS232 in favor of USB.

Any network of USB devices involves a single host talking to many slave devices. The typical connection to program an Arduino board is, on the USB side:
PC (USB Host) <-> USB Cable <-> Arduino (USB Device)

On the Arduino board you have the serial side of this communication:
USB Serial Adapter <-> TTL serial lines <-> Microcontroller (RX/TX on D0/D1 pins)

The microcontroller itself has no idea that any USB communication is involved. The USB serial adapter functions as a device only, not a host, so plugging it into another USB device (though a cable with device connectors on both ends, rather than the usual host connector on one end) will not do anything.
(There are some Arduino boards, such as the Leonardo and the Micro, that use an ATmega32U4 microcontroller with a USB device interface built in. These work in substantially the same way as above except with the without the serial adapter and TTL serial link. The built-in USB interface also cannot be used as a USB host.)
Arduino USB Host Shield
If you really want to use USB communication, SparkFun sells as USB Host Shield that you can add to a standard Arduino Uno or similar device. The library for it apparently supports USB serial, though you'd want to confirm that before buying the shield. This would leave the Arduino's USB/Serial interface used for programming free to remain hooked up when using the USB host shield, making development easier.
Direct Serial Connection
A better method (IMHO) is to drop the USB stuff altogether and, as Chris Stratton describes in his answer, have the Arduino talk TTL serial directly to a level shifter (e.g., this breakout board or this shield) that is connected to your RS-232 device. I would go with communications on non-programming pins (i.e., not digital pins 0 or 1) using the SoftwareSerial library or the AltSoftSerial library. (You don't mention the speed of the link, but software serial is generally ok up to 57,600 bps and, depending on the device and what else you're doing, even 115,2000 bps.) This will let you use the serial link to the computer for debugging while running your application.
If you need to work at higher speeds or you just prefer to use a UART (hardware serial), you have two options:

Use the USART on digital pins 0 and 1, and be unable to talk to the computer while you're using it to communicate with your RS-232 device.
Use an Arduino board with more UARTs or USARTs on it, such as the Mega.


text:
ESP8266 not sending temperature data to text message
i am trying to use a ESP8266 module to send temperature data using twilio and send it to my phone via text message. However it does not send the sensor data but the text i placed. Is it possible if i can get it to send sensor data instead? If so how can i do this?
strcat(data,"From=");
    strcat(data,PHONE_FROM);
    strcat(data,"&");

    strcat(data,"To=");
    strcat(data,PHONE_TO);
    strcat(data,"&");

    strcat(data,"sid=");
    strcat(data,TWILIO_ACCOUNT_SID);
    strcat(data,"&");

    strcat(data,"token=");
    strcat(data,TWILIO_TOKEN);
    strcat(data,"&");

    strcat(data,"Body=");
    const char TEXT_MESSAGE_BODY []  = "temperature", temperature;
    strcat(data,TEXT_MESSAGE_BODY);

    wifi.httpPost("iot-https-relay.appspot.com","/twilio/Messages.json",data);

temperature should be getting sensor raw data and paste it after the "temperature" but it is not working.

Do you know that you can get values from the sensor correctly?

Not 100% sure what you are trying to do with the line:
const char TEXT_MESSAGE_BODY []  = "temperature", temperature;

This will not assign the value in temperature to TEXT_MESSAGE_BODY, it will create a variable of type char called temperature.
You will need to get your temperature value into a string (array of char) using sprintf() or similar to convert from the base type (float, double?).
Replace const TEXT_MESSAGE_BODY [] ... etc with :
strcat(data,"temperature");

char temperature_s[20];
sprintf(temperature_s, "%f", rawTemperature);
strcat(data,temperature_s);

Above assumes rawTemperature is a float holding the value read from the sensor, but the same idea applies for other data types..  There is no checking for buffer overflow etc, but you get the idea.


text:
Arduino auto power of circuit possible issue with higher voltage agains output pin?
I've use the following circuit to be able to shutting the my Arduino down after some time of it not being used:

I'm now concerned that while you press the button to turn on the Arduino, the 9V from the battery can flow directly to the PIN X (one of the digital pins of the Arduino configured as output). After the Arduino is started the PIN X will be set to high, to keep the Arduino running when the button is released.
Is this a problem which I need to solve? And if yes how. The finished project is intended for a child, so I assume that the on button can be hold for a long time just as it is funny to press on the button. The circuit itself is running fine.
As a possible solution I thought to add a diode between the junction after the R1 and the PIN X. Would this be an ok solution?
The circuit is not my own invention I've found it here: http://educ8s.tv/auto-power-off-arduino-simple-circuit/

adding a diode would stop the 9v from hitting the pin. the uno also has internal resisters that act as a gate de-flap.

Having 9 volts reaching pin X through R1 is indeed a problem, one that could destroy transistors in the pin's IO structure.  The problem is mentioned in some comments following the video, but no solution is mentioned there.  Presumably users of the circuit usually get away with ignoring the problem because it is one of short duration:  A few milliseconds after the MCU starts up, it sets pin X to +5 V, which then leads to 4 V at 40 μA being dropped harmlessly across R1.  (Note, R1 is 100KΩ rather than 100Ω, per video and its notes.)
One approach to guard against the problem is to place a 5.3–5.7 V zener diode from ground to pin X.
Another way is to use a better and more capable on-off circuit, a Pololu Pushbutton Power Switch #2808.  This costs about $4, and is rated for operation from 2.2 V to 20 V at up to 6 A.  The board is about 15x18 mm and has a small pushbutton on it, but you can parallel a momentary switch of your own if you like.  The pushbutton toggles power on or off.  The board also has control inputs called On, Off, and Ctrl, with the first two turning the board on or off.
A big advantage of the #2808 switch is its current draw is small (less than 0.1 μA) when switched off.  The circuit illustrated in the link has close to 0.5 mA draw when off, which is enough to run a battery down in a few weeks.

That electronic power switch board looks like an interesting idea; hopefully it solves not only the input voltage problem, but the more permanent leakage path self turn on one.

Thanks for the response, I've seen the Pololu Solution when I was searching for circuit to solve this issue. I've did not order it as the shipping cost was around 20$ to my country and I have the the risk of additional import taxes on top of it. And this for a 4$ component :-( And the lokal distributor does not carry that part. This was the reason I've wen't with the other "solution".
Not the best decision in hindsight :-(

ok, had another look on the page, and found a distributor in Germany which also sends to my country. Ordered now the board and also a stepup voltage  regulator to solve the other issue with powering the arduino board by battery.

@Chris, that's good.  Note, the #2808 is ok with low voltages (2.2 V to 20 V) and the #2809 with medium voltages  (4.5 V to 40 V).  Power-on indicator LED is red on #2808, and I think draws some 200 μA/V when the unit is on (eg 1–1.2 mA at +5V), and is green on #2809, drawing ca. 100-120 μA/V when the unit is on.  You can remove the LED if that power loss is a problem.

Yes I will remove the led, need to to the same on the uno as well.

No.  It is not possible for a modern IC such as an MCU having I/O protection diodes to enable/disable its own power using a single external N-Channel or P-Channel device.  The reason is that the path broken by the single switch ends up being partially completed through I/O pin's internal protection diode and your pulldown resistor, and depending on the voltage drop that results across that, partial turn on the FET itself.  This is enough to have the processor at least partially on - perhaps not enough to operate, but enough to keep consuming battery, and in some cases also enough to make clean startup on manual operation of the power switch unworkable.
To make this work, you need two stages of switching - two fets are a possibility.
However another easy one is to use one of the USB power switches chips intended to be included in the rarely seen "full" USB hubs that have software control of the downstream ports' power.  These are hardly ever fitted in the hubs sold, but they exist as a part, are easy to apply, typically have low leakage, and are often specified to operate correctly both substantially below and somewhat above the 5v they would see in a USB application.  Most importantly, they are multi-stage solutions in a single package - typically they function as high side switches, but they are enabled by an input going high, and as result, they do not suffer the parasitic partial turn on issue via the MCU's protection diodes in the way that a high side switch enabled by an input going low would.  I believe the RT9701 that I used in the past to do this with an ESP8266 is officially discontinued, but still available and likely replaced by newer similar parts.
Given your input voltage, another thing to consider would be using a regulator with an active-high enable input.  But realize that a linear regulator is an inherently wasteful device, and a lot of the compact switchers don't have very high input voltage allowance.

Just out of curiosity do you know a place where there would be a circuit of such a dual FET solution? I would like to learn how it works correctly.
The RT9701 look interesting, but I'm not yet ready to solder smd components. And I was only able to find it in smd configuration.


text:
Press on pressure sensor, then wait 5 seconds, turn on LED
I'm having some trouble wrapping my head around timers in Arduino. I've got a FSR Pressure Sensor and I want it to turn on my NeoPixel LED after pressing on it for 5 seconds. Any help is much appreciated!
My goal:
FSRReading > 1022 then wait 5 seconds, turn on NeoPixel
FSRReading < 1022, then reset timer, turn off NeoPixel
This is what I currently have for my code, I can detect and act on sensor readings, but no timer:
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUMPIXELS 16
#include "Timer.h"

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int fsrPin = 9; // FSR is connected to analog 0
int fsrReading; // the analog reading from the FSR resistor divider int LEDbrightness;
int LEDbrightness;
Timer t;

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

void loop(void) {
fsrReading = analogRead(fsrPin);
Serial.println(fsrReading);
Serial.print("Analog reading = ");

// we'll need to change the range from the analog reading (0-1023) down to the range // used by analogWrite (0-255) with map!
LEDbrightness = map(fsrReading, 0, 1023, 0, 255);

if (fsrReading < 10) {
Serial.println(" - No pressure"); } else if (fsrReading < 200) {
Serial.println(" - Light touch"); } else if (fsrReading < 500) {
Serial.println(" - Light squeeze"); } else if (fsrReading < 800) {
Serial.println(" - Medium squeeze"); } else {
Serial.println(" - Big squeeze"); }
delay(50);

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

  // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
  if (fsrReading>1022){
  pixels.setPixelColor(i, pixels.Color(0,255,0));
  } else if (fsrReading<1022) {
  pixels.setPixelColor(i, pixels.Color(0,0,0));
  }

  pixels.show(); // This sends the updated pixel color to the hardware.
 }
 }

The basic concept for tracking timing in the loop() is as follows:
1) when your event occurs, you store the current time in a variable:
unsigned long lastReading = 0;
uint8_t waiting = false;

if ( !waiting && fsrReading > 1022 ) {
  lastReading = millis();
  waiting = true;
}

2) you compare the lastReading variable against the current time and when enough time has passed, you can perform you timed action. ie:
int timeToWait = 5000; // 5 seconds

// are we waiting? and has enough time passed?
if ( waiting && millis() - lastReading > timeToWait ) {
   waiting = false; // reset

   // Light up lights
   ...
}

Note: this specific implementation only requires the sensor to rise above 1022 once, then wait 5 seconds before executing the timed action. If you want the sensor reading to be maintained above 1022 for the entire duration then you would add a check for a release with something like:
if ( fsrReading < 1022 ) {
  waiting = false; // reset because reading fell below 1022
}

hey thanks for your answer! could you explain a bit more about the purpose of the lastReading boolean? In what case would it become true? or is it suppose to stay false?

Error in the above:  long lastReading should be  unsigned long lastReading.  Also, 0 is an ok value for millis() so lastReading should not be used as a flag as well as a value.

@jwpat7. Right updated. And yes, 0 is a valid value for millis(), so if this sketch is expected to run ~50 days or more then a separate flag would be a good idea.

@jmswng lastReading is used to store the time of the last sensor reading. It is set to false to indicate we are not counting. When we are counting, it's value is the time when counting started. This 'trick' takes advantage of the fact that any non-zero number evaluates to true. However, jwpat7 pointed out that doing it this way could introduce unintended side effects. I'll update the code to use a dedicated flag. That should make it more clear.

@Mazaryk, ok, +1

My goal: FSRReading > 1022 then wait 5 seconds, turn on NeoPixel FSRReading < 1022, then reset timer, turn off NeoPixel

something like this will do.
  static uint32_t pressed_time; //last time the pressure sensor is pressed
  static uint8_t pressed_state=0; //the previous state. '1'->pressed, '0'->not pressed

  if (pressed()) {
    if (!pressed_state)) { //first time the pressure sensor is pressed
      pressed_state = 1;  //pressure sensor has been pressed
      pressed_time = millis(); //take time now
    }
  } else {                //no longer pressed
    pressed_state = 0;  //reset pressed state
    turnOffled();       //turn the led off
  }

  if ((millis() > pressed_time + LED_DLY) && pressed_state) turnOnled();

untested code, use at your own risk
edit:
the above code in action, with a minor modification to return the desired led state (active high):
    //turn on / off the led pins
    if (led_ctrl()) digitalWrite(LED_PIN, HIGH);    //turn on the led, active high
    else digitalWrite(LED_PIN, LOW);        //turn off the led
}

Note:
1. pressed() is active low;
2. the led is programmed to turn on 100ms after the button goes low.
hope it helps.

You should edit this to clarify relation of fsrReading to pressed()

Thanks for the answer, but what's 'LED_DLY'?


text:
Detecting the light source location using multiple photoresistors
I am not an expert yet, so please forgive any possibly wrong terminology that I may have used.
I am planning to place 6 light sensors in 1 meter (or maybe more) distance from one another, like this (sorry about the bad schematic, I am not an expert, but I hope it makes sense):

simulate this circuit – Schematic created using CircuitLab
I am going to place them in a relatively dark room. My goal is, when I am pointing a flash light towards them to be able to tell which sensor is measuring the highest values (where the light is coming from), and for how long (in milliseconds).
I know how to do the connections and measure values. My questions are two:

Which is the most efficient way to detect which of the 4 sensors is recording the higher values? I am assuming I have to compare the values that they are recording. However, I think that if in each loop I sort the captured values, the process might become heavy. I guess I could minimise the comparisons, since for example if LDR1's value is higher than LDR2 and LDR3, I can assume that the light source is cannot be pointing towards LDR6 for example. However, I am thinking that maybe there could be an even more efficient way to detect that (not necessarily in software).
Since the room will not be completely dark, the analog pins will record some values even when I am not pointing the flash light towards them. Is there a way to filter that out? I have come across calibration (https://www.arduino.cc/en/tutorial/calibration), but I am not sure whether this is the optimal solution. Please take into account that the light source might not be very strong (but its light will definitely be brighter than the room light).

The answer from Curt Sampson provides several good design considerations, plus the quite-reasonable suggestion that you run some experiments to characterize your LDRs and their placements.
Note that if you want to know which sensor has the highest reading, a simple find-maximum-value loop will do that, without any sorting:
int maxR = reading[1], maxS=1;
for (byte i=2; i <= nSensors; ++i) {
  if (reading[i] > maxR) {
    maxR = reading[i];
    maxS = i;
  }
}
// Now we know sensor maxS has max reading, maxR

The code above follows the 1–6 numbering scheme given in the question, and assumes that reading[i] stands for the reading from sensor i.
Code below, however, numbers the sensors and their readings from 0 to 5 instead of from 1 to 6, to allow simpler conditions in for loops.  From a programming standpoint, it makes sense to call the first sensor 0 if its data is stored in cell 0.

Finding x, y direction of the light
Assumptions behind the following code are that higher readings indicate more light, and that if necessary some background-lighting calibration has been done, and that background lighting has already been subtracted from readings data.  We also assume that maximum readings are less than (2¹⁵)/N, where N is number of sensors.
The point of the following code is to set two variables, x and y, that represent the relative location of a light source.  For example, if x and y are both positive, the light is above and to the right of the top right LDR.  If  x is negative and  y is near zero, the light is to the left of the middle-left LDR.  If knowing the signs of x and y is adequate for your purpose, then there's no need to do more arithmetic than shown.  On the other hand, if you want to compute some sort of angle, you can use atan2(y, x) to compute the direction of the light, in radians.
int reading[nSensors];
const int xdir[] = { -1, 1, -1, 1, -1,  1}; // x-direction sensor weights
const int ydir[] = {  1, 1,  0, 0, -1, -1}; // y-direction sensor weights
int x=0, y=0;
for (byte i=0; i < nSensors; ++i) {
  x += xdir[i] * reading[i];
  y += ydir[i] * reading[i];
}

Edit 1: Tracking the time a light is on
Issues with light-timing include what levels to start or stop timing at; necessary resolution (milliseconds? minutes?); necessary range (eg, is what happened a minute ago relevant); and when to reset accumulated time data.  It may be simplest to track the on times of all the sensors at the same time, then select one of the times or combine some times.  Do you want the largest time, the newest time, the newest large time, or the time corresponding to the largest light?
For example, the code below tracks light levels that remain high long enough to register, in smoothed averages, as above some threshold.  At intervals, current indications are rotated into bit maps that track the last 16 on-off levels for each LDR, and counts of number-of-ons are updated too.
// Initialization ...
uint16_t expAvg[nSensors]={0};  // Exponential averages over time
uint16_t bitMaps[nSensors]={0}; // Track each sensor's last 16 on-off levels
byte onCounts[nSensors]={0};    // Number of recent times sensor avg > threshold
unsigned long prevMilli=millis();
const int markInterval=50;   // ms interval for recording light levels
const int onThreshold=547*16; // Some light-is-on threshold

// In each pass of loop() ...
for (byte i=0; i < nSensors; ++i)
  expAvg[i] = reading[i] + 15*expAvg[i]; // exponential averaging with 1:16 weight

// In loop(), at intervals ...
if (millis()-prevMilli >=  markInterval) {
  prevMilli = millis();
  for (byte i=0; i < nSensors; ++i) {
    onCounts[i] += (expAvg[i] > onThreshold) - (!(bitMaps[i] & 0x8000));
    bitMaps[i] = (bitMaps[i]<<1) | (expAvg[i] > onThreshold);
  }
}

This will most likely do it! I really like the second solution. However, in order to calibrate it, is the method that I posted in my question likely to work? I need to measure for how long the flash light was on (in milliseconds), so I guess I will need either some calibration or a high pass filter.

@jackgu1988, see edit - although I guess I didn't address the ms on but instead fraction of on time in last .8 seconds (with constants shown)

This will probably do it! Thank you very much. For the moment I am waiting for a couple more sensors to be delivered. I'll report back when I test it.

There's only one ADC (analog to digital converter) on the ATmega328P; the analog input pins are multiplexed so that you choose which particular pin you want to sample. (See Section 28 of the datasheet for details.)
Taking a sample takes time; how long depends on how you do it. The analogRead() function is documented to take about 100 microseconds. Reading your six sensors is thus going to take at least 600 microseconds.
The sample returned is a 10-bit integer and so easily fits into two bytes, or even one byte if you drop the low two bits (which is reasonable for some applications, and probably yours, because they're likely to be more sample error than data anyway). Whether you do that or not, however, you're left with a very tiny amount of data to sort from one set of reads: just six values.
The Arduino runs the ATmega328P at 16 MHz, and most instructions run in single clock, giving you performance approaching 16 instructions per microsecond.
We could work out, based on the type of sort you use, the number of comparisons and swaps you're likely to make in the average and worst cases, but there's no point to that on such a tiny data set because the total time your routine takes is almost certainly going to be dominated by other overhead. So I'm just going to say that the sort will be something on the order of a hundred clock cycles.
That means your sort would add around 6 or 7 microseconds to your 600 microsecond total read time you've got so far, or 1%; you don't have to worry about it at all.
You'll actually spend a lot more time doing other sorts of processing. But it's a pretty fast CPU, as we've seen above, so there's a good chance if you're careful that your loop will still be dominated by the sampling time of the ADC for each of the sensors.
My suggestion is to go ahead and write the thing but record actual timings in your loop for the sampling and the processing. After you've played around with it for a bit you'll have a better idea of the particular costs for each for your particular application and then you can worry about whether or not you need optimization. I suspect you won't.
Regarding the "filtering," that's going to be an integral part of your processing algorithm because the "room light" values can be vastly different from time to time depending on the current lighting in the room. I don't think you want to "filter" anything out, but instead compare the values of all of the photoresistors; at a first guess, similar values from all of them would mean that there's no flashlight and some giving you significantly higher values would indicate that there is one. But my second guess is that a) you'll want your sensors a lot further apart than 1 meter (perhaps in the corners of the room) and b) it's not going to be so simple; you're likely to see fairly different values from the sensors even in a quiescent room. This is where you get to play and experiment to find out how this really works!
It also occurs to me that putting the photoresistors several meters away from the ADC is going to involve a lot of wire, which adds resistance, capacitance and noise, all of which are going to interfere with your measurements. There's not a lot you can do about this; you can play a bit with measuring known-value resistors at the ends of the wires to see how bad the problem is, but if it's terrible you'd probably need to use a separate Arduino for each sensor and have them communicating back to a central place for analysis.

Thank you! This information is very helpful. I was also thinking that maybe I can wire the resistors in a way that I can minimise the amount of checks. For example, having 3 instead of 6 analog inputs (each input representing 2 sensors) and depending on the returned values to be able to tell which sensor is receiving more light.

You could try to come up with clever ways to wire the photoresistors in serial and/or parallel to reduce the number of samples you need to take, but that's a pretty darn tricky thing to do. I would probably first start with adding more sensors and, if the loop is too slow due to the length of time it takes to sample all of them, figure out an algorithm to sample only some of the sensors and leave others alone based on what's been sampled recently. But first I'd get something really basic working.


text:
Cannot get HC-12 to function with Arduino Pro Micro clone
[first time usage]
I'm checking this config out with a simple sketch derived from one @ https://www.allaboutcircuits.com/projects/understanding-and-implementing-the-hc-12-wireless-transceiver-module/.
The sketch acknowledges a command from the Serial Monitor and responds accordingly along with an "OK".  I have used this sketch countless times before with numerous HC-12 and UNO, and this particular HC-12 functions properly when connected to such.
For the Pro Micro, the command is echoed back instead, which, in my experience, indicates that the HC-12 is not receiving/responding.
The Pro Micro test config is very basic: Pro Micro, HC-12, USB connection, 5 direct jumper connections for vcc, gnd, pins 4-6. Vcc output reads 4.2 volts.
I specify:
const byte HC12RxdPin = 4; // "RXD" Pin on HC12
const byte HC12TxdPin = 5; // "TXD" Pin on HC12
const byte HC12SetPin = 6; // "SET" Pin on HC12

SoftwareSerial HC12(HC12TxdPin, HC12RxdPin)

I have also tested with an IN4007 in the power connect for the HC-12, but results are the same.
I've swapped HC-12s, and checked out the requisite pins by using another sketch that toggles an led on each.
The Arduino IDE is 1.8.2, and I am specifying a Leonardo board.  This is the suggestion I found whilst researching.
I have seen a few projects using the HC-12 with the Pro Micro and other small boards, but noticed no special considerations for such.
Have you any suggestions or solutions [even better]?

http://arduino.stackexchange.com/questions/1471/arduino-pro-micro-get-data-out-of-tx-pin?rq=1

mico Thanks to the reference cited, I think I finally comprehend the situation.  Reading was easy, comprehension more difficult.
Based upon the reference, I removed the HC-12 specifications, then specified Serial1 for the reads, writes and available check.
I then changed connections, such that the HC-12 RXD pin connects to the Pro Micro TXD pin, and the HC-12 TXD pin connects to the Pro Micro RXD pin.
This works for my the sketch I was using as well as other test cases of mine.

Have you seen the Q&A on providing adequate power?  The HC-12 needs more than 100 mA to work, into the Vin, for all types of Arduino..  It will not work at all if the power is only coming from a USB port.  Have you tried this?  https://arduino.stackexchange.com/questions/33668/how-can-i-provide-enough-power-on-an-uno-to-use-the-hc-12-wireless-module

Solution to problem is as follows:
 For the Arduino Pro Micro [as for the Leonardo], Serial1 must be used instead of a SoftwareSerial specification, e.g.,
SoftwareSerial HC12(HC12TxdPin, HC12RxdPin).

Code is to be modified by changing HC12.available() to Serial1.available().  The same holds true for the reads and writes.
Pins are to be wired such that the HC-12 RXD pin connects to the Pro Micro TXD pin, and the HC-12 TXD pin connects to the Pro Micro RXD pin.
My thanks to @mico for providing the reference that explains it all.


text:
Substitute for FTDI board?
I am thinking forward to buy a set of Arduino pro mini. I have a very low budget and I can't think of buying a FTDI board. Is there any substitute for the FTDI board that is compatible with these arduino pro mini.

You could get an USBasp from eBay for around 2$, it can even program microcontrollers that don't have a bootloader (which may save you some), but they don't work for USB communication

Could you explain why you want to buy/use the Pro Mini in particular, and what else (if anything) you'll be using with it?

Actually, I had an Arduino Nano which I have burned So I thought of getting the Pro Mini as they are more smaller and cheap So I thought of buying them

if your computer has a serial port, you just need some solid-core wires..

@dandavis How can I do that ?

on a DB9 serial, 2-rx, 3-tx, 7 to gnd.

All prices in USD w/ free shipping.
FT232RL breakout board:

Aliexpress: $1.55
eBay: $1.81

They are probably counterfeit. A Windows driver update (AKA "FTDIgate") at one point "bricked" them but I'm not sure that's an issue anymore. Even if it is it's Windows only and easy enough to work around. I've used these for years on Windows and they work fine for me.
If that's still beyond your budget there are a few other common options. I haven't used these breakout boards but I do have quite a few boards that use the CH340G and they work perfectly once you install the driver. There's a decent chance some of these will also be counterfeit. Some didn't break out the DTR/CTS pin for auto reset but if you're on such a low budget maybe it's worth it to you to press the reset button on every upload to save a few cents. They may not have the standard FTDI header pinout and if so would require you to use jumpers to connect them to the Pro Mini rather than plugging directly into the header.
PL2303 breakout board:

Aliexpress: $0.50
eBay: $0.74

These don't appear to break out the DTR or CTS pins so they won't do auto-reset.
CH340G breakout board:

Aliexpress: $0.72
eBay: $0.93

These don't appear to break out the DTR or CTS pins so they won't do auto-reset.
CP2102 breakout board:

Aliexpress $1.00
eBay: $1.31

I live in India and I need DTR or CTS pins but In the worst scenarios I will adjust.

These are all shipped from China so the shipping should be free to India also. I verified that shipping on the Aliexpress FTDI FT232RL board is free to India. The nice thing about the Pro Mini is you can use one USB-serial board for all your Pro Minis so you really only need to buy one, though it's always nice to have a spare in case of magic smoke.

But the shipping takes one month

Yes, I have waited even longer than that here in the US for some of my orders but sometimes much shorter. I seem to get slower shipping from Aliexpress than eBay. You didn't say anything about needing it quickly in your question. Do some research for a supplier in India for the fastest delivery time.

Basically, you need any way to talk to the serial interface (on digital pins 0 and 1) on the Pro Mini. Remember that for programming you'll also need to be able to manipulate the reset line on the target board, usually done via DTR.
If you already have an Arduino board with USB, you could write a small sketch that uses that as the interface. Using the SoftwareSerial library or the AltSoftSerial library you could have the USB Arduino talk to the Pro Mini via a couple of data pins and relay the data back and forth. Depending on the Arduino you use and how you program it, it may or may not be able to keep up with 115,200 bps, but rates at or below 57,600 bps should be fine. You'll also need to handle the DTR and CTS signals for programming; this can be done with a couple more data pins.
In general what you're trying to do (whether you go with my solution or another one) is not a beginner project. If you're not familiar enough with Arduino systems to answer the question you posed, I'd strongly suggest buying an Uno, Nano or other board with integrated USB rather than trying to play with the Pro (which is called that for a reason).
If the cost of a single Arduino board is an issue, make sure you're looking around for the cheapest sources. You can find "non-brand" versions of many boards, such as this "Nano" for considerably lower prices than you'll see from the name-brand vendors. They're lower quality and you're not supporting the Arduino ecosystem, but they help when you have a very limited budget.

I have an Arduino Nano which is actually burned!


text:
2D cross correlation code for small images
I am working on a arduino Uno project* to detect eye pupil movement and I am thinking of using a serial low-res jpeg camera. I am thinking of implementing a cross-correlation function to detect when the pupil is turned towards the camera.
I am looking, so far unsuccessfully, for a c source code that performs a 2D cross-correlation without using FFT (Fourier Transform). I think such code might have good enough performance even on an Arduino Uno board when running on a low-res image, something like a 32x32 pixels image.
I'd appreciate if you could direct me to such a piece of code or alternatively tell me that this can't be done on an Arduino board due to CPU\RAM limitations.
Current Device is using an IR range finder to detect IR reflected from the retina when looking directly into the device.
P.S.

The project is intended to provide ALS patients the capability to use eye-motion to call for help, using a low-cost device.

32×32 is 1024 pixels. Assuming one byte per pixel, you would need 2 KiB only to store the two images you want to cross-correlate. And that's the total amount of RAM of an Arduino Uno, so you would have no RAM left for doing anything!

A Raspberry Pi is probably better suited to this task, IMHO.

I'm voting to close this question as off-topic because it's a pure programming question with no relationship to Ardunio


text:
How to control a Nema 17 stepper motor with an arduino? (too much current / heat)
I am trying to control a Nema 17 motor with a L298n dual bridge and an Arduino Mega.
My wiring is from this Instructable:
http://www.instructables.com/id/Control-DC-and-stepper-motors-with-L298N-Dual-Moto/?ALLSTEPS
When I connect it to my laboratory power supply the current limitation blinks. Normally when there is too much current needed the LED is all the time on and not blinking.
So I increase the current limit and the motor just starts moving on 3.1A @ 12V (doesn't move if less current) and in the description of the motor on amazon
they say "Rated Current/Phase:1.2A" so I am wondering what did I do wrong here?
From my understanding "Rated Current/Phase:1.2A" means that I should run this motor (it's a bipolar stepper motor with 2 phases) not higher than 2.4A?
These are the informations from amazon about this motor:
Specifications:

Led screw diameter: 8mm
Lead screw length: 300mm
Step angle :1.8 degree
Nut material: Brass
Holding Torque: 400mN*m
Thrust(full step): 12.5kg
Rated Current/Phase:1.2A
Rate Voltage: 3.3v
Rated Resistance/Phase:2.2±10%ohm

What would be a good voltage to run this motor? I thought 12V is a good idea with.
The motor L298n gets really hot when I run it at 3.2A or more so I think my setup will destroy the dual bridge and / or the motor.
I really appreciate help on this! :-)

one thing i can think of is that your PSU is too fast/good. Motors often need "infinite" amps to start moving, then they drop-off quickly. If your supply limits those high-voltage startup impulses, it might not be able to get off the ground. Read https://learn.adafruit.com/all-about-stepper-motors/matching-the-driver-to-the-stepper for info about avg current. I suspect your high heat is because the motor is not turning when consuming power.

Do you think my motor will get destroyed or can I use it with high amp?

i think the motor is more likely to get damage if there's not enough current, not from having too much. current limiting causes the volts to drop, and the motor need a certain voltage to turn. if it can turn, heat will build-up on the coils. if it does turn, it consumes less power and can self-cool.

I was running the motor for a while (few minutes) and the motor driver was getting hotter and hotter and already smelled a bit. The current was jumping from 3.2A (was the current limitation) to 2.6A and again to 3.2A from time to time. My sketch loaded on the arduino is just a non stop stepping, will my current decrease if I put in some delays?

you could be over stepping, or smearing microsteps, but it's hard to say without knowing virtually everything about your code, gear, internal wiring, etc. instant amps can jump around a lot and mislead humans and meters, don't use current limiting. excess heat is more important, and you might need to adjust your driving hardware/software in order to avoid that. if the extra heat is happening under no-load, i strongly suspect some software timing issues are in play.

I replaced my L298 with a easy driver A3967 and it works perfectly with just 0.2A. Maybe the L298 was broken or something. I still can't  understand that.

if it's not being controlled correctly, that explains the heat for sure, good to hear.

What voltage are you running it at? The motor is rated for 3.3V so you should probably be running it at 3.3V.

The stepper motor does not directly control or limit its own current.  When using the L298n for stepper control, the motor current control is performed by a PWM signal to the L298n ENABLE pin.  If you have ENABLE high (100% duty), current will be a factor of only the DC resistance of the stepper winding and the power supply voltage.  Here you are trying to drive a 1.2A@3.3V-rated stepper from 12V, so naturally the current will be ~3 times greater.
To adjust the motor current to a safe range for the driver, use analogWrite() from a PWM-capable pin on the Arduino connected to the ENABLE pin on the L298n, and set it to something less than 255 (50% is usually a good starting point).  Even then, the instantaneous current draw on the L298n will likely be stressing it outside of its operating envelope.
EDIT: I reviewed the info at the link, and this is the relevant area of the code:
// set speed to 200 out of possible range 0~255
analogWrite(enA, 200);
// set speed to 200 out of possible range 0~255
analogWrite(enB, 200);

Here is where the code is setting PWM of the two ENABLE pins to 200 (~80% duty cycle).  Drop this to 50 (~20% duty cycle) and you would likely resolve your overcurrent issue.  Reading further still, even the author gives you your first hint at what is happening:

This is not a speed value, instead power is applied for 200/255 of an
  amount of time at once.


text:
Benchmarking String.toInt() vs Checking individual characters gives unexpected result
I'm trying to check whether the input string contains all digits or not. I achieved this using 2 different algos. One is to convert the string to integer using String.toInt() and then checking if its value lies between the integer of length of the input string.
e.g. If input string is "123". The corresponding integer must lie between 100-999.
Second, I wrote a function that iterates over each character of the string and checks if its ASCII values lies between 48-57. If not, it returns false.
When I bench marked these two algos, I found that when the string contains only digits, the 2nd algo is about 9 times faster than the 1st one. But when the string contains even a single non-digit character, the 1st algo takes ~1ms, but the 2nd algo always takes ~5ms. Why is this? I've not been able to figure this out.
The code:
unsigned long start;
unsigned long middle;
unsigned long end;

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

  // send an intro:
  Serial.println("String toInt():");
  Serial.println();
}

void loop() {
  // Read serial input:
  if (Serial.available()) {
    String r = Serial.readString();

    start = micros();
    unsigned long rInt = r.toInt();
    int rLen = r.length();

    if ((rInt >= floor(pow(10, rLen))) || (rInt < floor(pow(10, rLen-1)))) {
      Serial.println("Please enter valid integer value!");
    } else {
      Serial.println(rInt+1);
    }

    middle = micros();

    bool isInt = doesContainInteger(r);
    if (isInt) {
      Serial.println(r);
    } else {
      Serial.println("Please enter valid integer value!");
    }

    end = micros();

    Serial.println(middle-start);
    Serial.println(end-middle);
  }
}

bool doesContainInteger(String s)
{
  int sLen = s.length();
  for (int i=0; i<sLen; i++) {
    char sChar = s.charAt(i);
    if (sChar<48 || sChar>57) {
      return false;
    }
  }
  return true;
}

Instead of "Please enter valid integer value!", just print "Invalid int". You will get somewhat less unrealistic timings.

You were right! I replaced "Please enter valid integer value!" with "!", and it took just 80us to print.

Including the serial output in your calculation timing is just plain stupid. Your timing should start before your test routine and finish immediately afterwards.

Oh, and pow() is a horrendously slow routine. Avoid it at all costs.

@Majenko Thanks. Your feedback is always valuable!

1 ms means easy calculation.
2 ms means more time spent in calculation.
5 ms means far more time in message printing to Serial buffer.
I calculated the error message passes serial line in 20-30 msec, so that is why I think there has to be a little bit faster buffer in between there.

As pointed out by Majenko in his (slightly annoyed) comment, you need to change your timing code to time only the calculations you want benchmark, not the I/O or other irrelevant code. For checking the conversion using toInt(), for example, try:
// time our conversion
unsigned long start = micros();
unsigned long rInt = r.toInt();
bool invalid = rInt == 0;
unsigned long end = micros();

// print the result
if (invalid) {
    Serial.print("in");
}
Serial.print("valid conversion took ");
Serial.print(end - start);
Serial.print(" microseconds.");

Note that your assumption that a three-character input that's a valid integer will be between 100 and 999 is wrong; "003" and "-17" are both three-character inputs that should be correctly converted.
According to the toInt() documentation, 0 is returned on failure to convert, so I check for that in the code above. But since one can't tell the difference between a successful conversion of "0" and unsuccessful conversion of "abc" or some other non-integer, you really should be sure before you call toInt() that you've got a valid integer int the string.