text:
Can I short this code?
int r = 12;
int g = 11;
int b = 10;
int sw = 4;
int x;
int c = 0;

void setup() {
    pinMode(r, OUTPUT);
    pinMode(g, OUTPUT);
    pinMode(b, OUTPUT);
    pinMode(sw, INPUT);
    pinMode(13, OUTPUT);
}

void loop() {
    x = digitalRead(sw);
  if(x==HIGH) {
    delay(250);
    c++;
    if(c==1) {
        digitalWrite(r, HIGH);
        digitalWrite(g, LOW);
        digitalWrite(b, LOW);
       {
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
      }

    }
    else if(c==2) {
        digitalWrite(r, LOW);
        digitalWrite(g, HIGH);
        digitalWrite(b, LOW);
             {
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
      }
    }
        else if(c==3) {
        digitalWrite(r, LOW);
        digitalWrite(g, LOW);
        digitalWrite(b, HIGH);
             {
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
      }
    }
        else if(c==4) {
        digitalWrite(r, HIGH);
        digitalWrite(g, HIGH);
        digitalWrite(b, LOW);
             {
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
      }
    }
            else if(c==5) {
        digitalWrite(r, LOW);
        digitalWrite(g, HIGH);
        digitalWrite(b, HIGH);
             {
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
      }

    }
            else if(c==6) {
        digitalWrite(r, HIGH);
        digitalWrite(g, LOW);
        digitalWrite(b, HIGH);
             {
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        digitalWrite(13,HIGH);
        delay (250);
        digitalWrite(13, LOW);
        delay (250);
        c=0;
      }

    }

  }
}

What is the purpose of putting the last 3/4 or so of the statements in each if() block into a separate block? Certainly you could considerably shorten your code by putting those statements into a separate function that takes as its argument the number of times to toggle pin 13.

I suggest you use the auto-indent tool in the IDE. Your indentation is all over the place. And as JRobert said, learn about writing functions. Whenever you copy/paste the same code into multiple places like that, you should be writing a function instead. Are you flashing pin 13 the number of times that c is? How about making that into a loop?

int r = 12, g = 11,b = 10, sw = 4, x, c = 0;

void setup() {
    pinMode(r, OUTPUT);
    pinMode(g, OUTPUT);
    pinMode(b, OUTPUT);
    pinMode(sw, INPUT);
    pinMode(13, OUTPUT);
}

void loop() {
  x = digitalRead(sw);
  if(x==HIGH) {
    delay(250);
    c++;
    if(c==1)      setRGBandBlink13(HIGH,LOW,LOW,1);
    else if(c==2) setRGBandBlink13(LOW,HIGH,LOW,2);
    else if(c==3) setRGBandBlink13(LOW,LOW,HIGH,3);
    else if(c==4) setRGBandBlink13(HIGH,HIGH,LOW,4);
    else if(c==5) setRGBandBlink13(LOW,HIGH,HIGH,5);
    else if(c==6){
      setRGBandBlink13(HIGH,LOW,HIGH,6);
      c=0;
    }

  }
}

void setRGBandBlink13(bool newR,bool newG,bool newB,int times){
  setRGB( newR, newG, newB);
  blinkPin13(times);
}

void setRGB(bool newR,bool newG,bool newB){
  digitalWrite(r, newR);
  digitalWrite(g, newG);
  digitalWrite(b, newB);
}

void blinkPin13(int times){
  for(int i=0;i<times;i++){
    digitalWrite(13,HIGH);
    delay (250);
    digitalWrite(13, LOW);
    delay (250);
  }
}

This Sketch is way shorter and way better to maintain.
Note that 1/3 (26 out of 78) of the lines are comments.
Note:
Your RGB is able to display 8 states, but only 7 can be reached.
binc - c - RGB
 000 - 0 -
 001 - 1 - R
 010 - 2 -  G
 011 - 3 - RG
 100 - 4 -   B
 101 - 5 - R B
 110 - 6 -  GB
 111 - 7 - RGB - NEVER REACHED
int r = 12;
int g = 11;
int b = 10;
int sw = 4;
int c = 0;
int maxC = 6;
int minC = 0;

void setup() {
    pinMode(r, OUTPUT);
    pinMode(g, OUTPUT);
    pinMode(b, OUTPUT);
    pinMode(sw, INPUT);
    pinMode(13, OUTPUT);
}

// for  (pulses)-times
// set  (targetPin) HIGH
// wait (msDelay)
// set  (targetPin) LOW
// wait (msDelay)
void pulse( int targetPin, int msDelay, int pulses ){
    // count to pulses
    // for each count, set targetPin HIGH and LOW
    // wait msDelay between each state change
    for ( int i = 0; i <= pulses, i++ ){
        digitalWrite( targetPin, HIGH );
        delay( msDelay );
        digitalWrite( targetPin, LOW );
        delay( msDelay );
    }
}

// int rgbBinary will set RGB according to its binary value.
// R ~= BIT_1
// G ~= BIT_2
// B ~= BIT_4
void setRGB( int rgbBinary ){
    // set each LED OFF
    // This is by far more performant than
    // checking which should keep its state.
    digitalWrite( r, LOW );
    digitalWrite( g, LOW );
    digitalWrite( b, LOW );

    // if rgbBinary contains BIT value 1, set R to HIGH
    if ( rgbBinary & 1 ) {
        digitalWrite( r, HIGH) ;
    }
    // if rgbBinary contains BIT value 2, set R to HIGH
    if ( rgbBinary & 2 ) {
        digitalWrite( g, HIGH );
    }
    // if rgbBinary contains BIT value 4, set R to HIGH
    if ( rgbBinary & 4 ) {
        digitalWrite( b, HIGH );
    }
}

void loop() {
    // INPUT on SW ?
  if ( digitalRead( sw ) == HIGH) {
    // wait 250ms
    delay( 250 );
    // incement c
    c++;
    // increment RGB status
    setRGB( c );
    // pulse OUTPUT 13 (c)-times
    // starting by HIGH
    // delay 250ms between each HIGH/LOW
    pulse( 13, 250, c );
    // reset (c) on maxC
    if ( c == maxC ){
        c = minC;
    }
  }
}

I don't have an appropriate circuit handy for testing, but I've condensed the code a bit and renamed some things to be more readable. Hopefully the result is the same! Importantly, I've changed your c to step and it is now zero-based, so "step 1" is 0 and "step 6" is 5, etc.
const int rPin = 12;
const int gPin = 11;
const int bPin = 10;
const int swPin = 4;
const int pin13 = 13; // Needs a better name!
const int msDelay = 250;

int step = 0;

// By pure luck, your patterns overlap, so they can be condensed like so.
const byte patterns[13] = {
    // 0         1          2          3          4           5
    HIGH, LOW, LOW, HIGH, LOW, LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH
};

void setup()
{
    pinMode(rPin, OUTPUT);
    pinMode(gPin, OUTPUT);
    pinMode(bPin, OUTPUT);
    pinMode(swPin, INPUT);
    pinMode(pin13, OUTPUT);
}

void loop()
{
    if (digitalRead(swPin) == HIGH)
    {
        delay(msDelay);

        // Write red/green/blue pattern
        int index = step * 2;
        digitalWrite(rPin, patterns[index]);
        digitalWrite(gPin, patterns[index + 1]);
        digitalWrite(bPin, patterns[index + 2]);

        // Blink once for each step (0 through 5)
        for (int i = 0; i <= step; ++i)
        {
            digitalWrite(pin13, HIGH);
            delay(msDelay);
            digitalWrite(pin13, LOW);
            delay(msDelay);
        }

        // Increment or reset step
        step = (step < 5) ? step + 1 : 0;
    }
}

Make all those ints in a single line.
int r = 12, g = 11,b = 10, sw = 4, x, c = 0;

While valid C, it is really bad coding style to do that. Declare each variable in its own line.

In this manner, compiler will trim code anyway. Declaring vars in a single row will decrease readability by a lot but won't trim the actual binary in the end. Nothing gained by that.

You could argue that putting everything in one line (int r=12;int g=11; int b=10; int sw=4; int x; int c=0;) would also "shorten" the code. But it barely decreases the amount of functional code. I also highly doubt that @USF meant to shorten this part of the code.


text:
I need to build a char array from two integers
My C is rusty, so please forgive this simple problem.
This line works:
Tft.drawString("Test",200,200,2,WHITE);
But, this has compile errors:
String yStr = "Test";
Tft.drawString(yStr,200,200,2,WHITE);

The function in the library:
void drawString(char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);

The error is "no known conversion for argument 1 from 'String' to 'char*'".
Conclusion - I need a character array. Here's what I am trying to accomplish.
I have two integers that I would like to display on my Tft screen. For example, 225 and 250 to be displayed as "225,250".
I haven't figured out a way to build the char array for the drawString() function.
Assistance would be appreciated.

Thanks for the quick reply Ignacio.
I tried that, but the compiler still doesn't like it.
Here's how I built the string:
string stringXY ;
stringXY += xStr;
stringXY += ",";
stringXY += yStr;
Tft.drawString(stringXY.c_str(),200,200,2,RED);

Error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
I am apparently using c_str() wrong?

The pure c method using a char array rather than a string is to use sprintf: char tmpBuffer[64]; sprintf(tmpBuffer,"%d,%d",xVal,yVal);

Put it in a String and then use the c_str() method to get the associated char*.

Thanks for the quick reply Ignacio.
I tried that, but the compiler still doesn't like it.
Here's how I built the string:
String stringXY ;
stringXY += xStr;
stringXY += ",";
stringXY += yStr;
Tft.drawString(stringXY.c_str(),200,200,2,RED);
error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
I am apparently using c_str() wrong?

No, that's a bug in the TFT library. There's no reason that argument should be modified, so it should be tagged const.

Many thanks to Ignacio.
I changed the function in the library to:
void drawString(const char *string,unsigned int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);
This fixed the problem and gave me more confidence in my vague understanding of C.

Another option in your situation is to not use String at all (which is preferrable for reasons I won't explain here) and exclusively use plain old C strings and their associated functions:
// Define a string buffer to hold the result, ensure it is long enough
// to hold "N1,N2". An additional char must be added to terminate the string with 0
char result[15+1];
unsigned int N1 = ...;
unsigned int N2 = ...;
// Format output as desired
sprintf(result, "%u,%u", N1, N2);
// Now you can use result with drawString
Tft.drawString(result, 200, 200, 2, RED);

sprintf is a very powerful formatting function that offers you plenty of options.
Note that I took it for granted that your numbers are unsigned int; if these were normal integer (possibly negative), you should replace "%u,%u" with "%d,%d".

What is the (approximate) overhead of sprintf in terms of global/static RAM allocation, dynamic allocation, and program size (flash memory)

source: Stack Exchange

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

sort: votes


text:
Using buttons with Arrays
I am trying to write a simple program that will cycle through an array using push buttons. My current version of the program uses if statements and prints lines.
My goal is to have contact information for 4 people stored in an array. I can either have an array of strings per person or make different arrays of strings for the different type of information (ie names, phone numbers).
I would like one push button to cycle through the data in one direction and another push button to cycle through the data in the other direction. This is my code so far using the if statements. I modified the code from a traffic light tutorial hence you will see some of the variables named after colors.
//------------------------------- Declare variables
int ledPinOne = 2;
int ledPinTwo = 3;
int ledPinThree = 4;
int ledPinFour = 5;
int buttonPin = 6;
int state = 0;
char user_name_array[32];
char econ_one_name_array[32];
char econ_two_array[32];
char econ_three_name_array[32];

//------------------------------- Setup
void setup() {
  Serial.begin(9600);
  //------------------------------ Sets pins for I/O
  pinMode(ledPinOne, OUTPUT);
  pinMode(ledPinTwo, OUTPUT);
  pinMode(ledPinThree, OUTPUT);
  pinMode(ledPinFour, OUTPUT);
  pinMode(buttonPin, INPUT);
  Serial.println("ID");
  Serial.println(user_name_array);
}

//------------------------------- Main Program
void loop() {
  if (digitalRead(buttonPin)) {
    if (state == 0) {
      Serial.println("Athlete");
      Serial.println("John Smith");
      Serial.println("No allergies, no medications");
      Serial.println("  ");
      setLights(HIGH, LOW, LOW, LOW);
      state = 1;
    } else if (state == 1) {
      Serial.println("Emergency Contact - Sister");
      Serial.println("Eliza Smith");
      Serial.println("Cell - 333.888.777");
      Serial.println("  ");
      setLights(LOW, HIGH, LOW, LOW);
      state = 2;

    } else if (state == 2) {
      Serial.println("Emergency Contact - Hermosita");
      Serial.println("Jackie Smith");
      Serial.println("Cell - 777.888.7777");
      Serial.println("  ");
      setLights(LOW, LOW, HIGH, LOW);
      state = 3;
    } else if (state == 3) {
      Serial.println("Emergency Contact - Father");
      Serial.println("Michael Smith");
      Serial.println("Cell - 888.777.777");
      Serial.println("  ");
      setLights(LOW, LOW, LOW, HIGH);
      state = 0;
    }
    delay(1000);
  }
}

void setLights(int red, int yellow, int green, int blue) {
  digitalWrite(ledPinOne, red);
  digitalWrite(ledPinTwo, yellow);
  digitalWrite(ledPinThree, green);
  digitalWrite(ledPinFour, blue);
}

I also have a 4-LED setup. When the button is pushed one of the LEDs turns on and then when the button is pushed again it turns off and turns the second one on and so forth.
Thank you in advance for any help.
EDIT:
This question was asked again in a more detailed way and has more answers here:
Using a button to cycle an array

You should try and ask 1 question at a time.  That way when other people search with a similar question they can find yours and its answers.

Let's just deal with character strings.
The truth of the matter is that Arduino programming uses the language C.  C is very common and you can search for help in many places.
There are several ways to deal with strings in C.  In this example we are using an array of pointers to strings:
// let's make our own array of strings
char *states[] = {
    "California", "Oregon",
    "Washington", "Texas"
};
int num_states = 4;

for(i = 0; i < num_states; i++) {
    printf("state %d: %s\n", i, states[i]);
}

The output of this code looks like:
state 0: California
state 1: Oregon
state 2: Washington
state 3: Texas

I grabbed this example from here.
added later...
The method "printf" is normally not used in Arduino land.  So that "for" loop would look more like:
for(i = 0; i < num_states; i++)
{
 Serial.println("state ");
 Serial.println(i)
 Serial.println(states[i]);
}

Ahem... printf DOES exists in Arduino land, just include <stdio.h>

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


text:
Test level shifter with Arduino and some data
Below is a reference to a logical level bi-directional converter (aka level shifter) I purchased on Ebay.  I've soldered the 12 pins (6 for each piece) to the level shifter so that it fits on my bread board.
http://www.ebay.com/itm/121868205078?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
This may sound trivial, but I'd like to troubleshoot the level shifter with communication both ways (Rx and Tx) to make sure it's working properly.  I've got a constant 4.85v (5V) going to the HV pin, and a constant regulated 3.24V (3.3V) going to the LV pin, along with ground to both GND pins.  Right now, I'm using pin0 (Rx) and pin1 (Tx) on the Arduino Mega 2560.
void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(1000);
  Serial.println("Test");
}

How can I test this level shifter without any fancy components?  How could I write a program to toggle an LED both on LV1 and HV1 pins, by modifying the program above?  Please note, that even though the Arduino runs on 5V, I am not using the Arduino as my HV power source.
EDIT (per comment 3 by @Paul):
Test:

Burn blank sketch into Arduino
Connect 5V (Arduino 5V) to HV pin
Connect GND (Arduino GND) to GND pin on same side as HV pin
Connect 3.3V to LV pin
Connect GND (from 3.3V power source) to GND pin on same side as LV
pin
Connect Arduino Tx pin to channel 1 (HV1)
Connect Arduino Rx pin to channel 2 (HV2)
Short channel 1 to channel 2 with jumper wire

When all of this is connected, and I open the Serial Monitor on Arduino IDE, anything I type will echo back exactly what I typed.  And when I disconnect one of these jumpers, it doesn't echo back.  So it seems to work.

Try to perform a "loop-back test" simply send a character over the Tx line through the converter (and back through the converter) into the Rx line. And check if you receive back what you send.

@Paul - I've connected HV1 (channel 1) to pin 0 (Rx) on the Arduino, and HV2 (channel 2) to pin 1 (Tx) on the Arduino.  What hardare do I put between LV1 and LV2 on the low voltage side of the level shifter to ensure the ASCII character comes back?

an 0 Ohm resistor ;)
Basically anything that is conductive, a wire preferably. The bits will then travel from output Tx -> HV1 (high) -> shifter LV1 (to low) -> wire -> shifter LV2 (to high) ->HV2 -> input Rx if that succeeds, you can safely assume it's working for UART and that it's bi-directional.

Haha!  I guess the saying goes "Keep It Simple Steve" .. or is that last word incorrect?

A 0 Ohm's resistor is a resistor that has "no resistance". Which is basically a (short) wire. Check this "tutorial" (http://www.instructables.com/id/Loopback-Test-For-Arduino-Uno/?ALLSTEPS)

One note here.  I'm using the Arduino, rather than a UART (as in comment by @Paul).  Hopefully your comment holds true when using the Arduino.  Is the Arduino and UART both 5V, which would connect in the same way to the HV pin on the level shifter?

I'm sorry, UART or USART is the "low level hardware" behind the hardware serial port (Rx and Tx pins). So yes, we're on the same line (:

@Paul - shorting channel 1 to channel 2 worked!  Does my "Test" in my EDIT look accurate to you?

if the signal goes from Tx to HV1 to LV1 to jumper to LV2 to HV2 to rx, you can safely assume that the component works. You might want to check the voltages, if they really are around 5V and around 3.3V.
But yes, you've tested/proven that this component will work for serial communication.

So, yes it seems right to me. You are shorting channel 1 LV and channel 2 LV? From your notes it could also be HV. But both should work neverthless.

Yes, I basically made a short circuit from LV1 to LV2 with a short jumper wire/cable on my breadboard.  I typed "Hello" and the Serial Monitor echoed back "Hello".  When I removed the short, it didn't echo back "Hello".

You don't need to write any program.
First, note that this is (or at least purports to be) an I2C level shifter. This means that it does not actively pull up anything; it only actively pulls down. You are supposed to provide pull-ups somewhere in your circuit.
To test it, pull up HV1 and LV1 with 10K resistors to HV and LV respectively; measure the voltage on both sides to verify you are pulling to ~5V and ~3.3V respectively.
Ground HV1, check that LV1 is low.
Ground LV1, check that HV1 is low.
Ta-dah!

The pull-ups are already on the board, as far as I can see. Though, I'm not entirely sure if you can use an I2C level shifter for UART.

@Gerben the resistors, are used for the (bi-directional) voltage conversion. I've got a similiar board (https://www.sparkfun.com/products/12009) which works for uart, logic and spi (haven't tried I2C but it should be fine).

@JayEye - When you say "pull up HV1 and LV1 with 10K resisters" do I put a 10K ohm resister between the HV1 pin and some something else, and another 10K ohm resister between the LV1 pin and something else?  Do I need a "something else" or am I just measuring the voltage drop where the "something else" is on the low voltage side and high voltage side of channel 1?

In addition to testing the voltage, I'd also like to ensure data is passed back and forth.  That's ultimately what I'm after here.  I've updated the title of the question to reflect that.

@MacGyver edited the answer to make that clear

if you wan to use this for anything other than i2c, get a proper level converter.

why would it not pass data? if you make sure that a high and a low on either side results in the corresponding signal, you're good to go.

What applications should one use an i2c for?  What is a better level shifter for other applications, that this would not work for?  Two days ago, I didn't know what a level shifter was.  :-)

at the risk of angering the moderators, I'll point to actual products:
https://www.adafruit.com/products/1875 for general-puprose shifting, and
https://www.adafruit.com/products/757 for I2C level shifting.
Read the documentation they provide, they'll explain everything you need to know.
I am not affiliated with Adafruit; I just find them convenient, as we are both in NYC and even the cheapest shipping results in two-day delivery!!

@JayEye - does "pull up" mean to go from a low voltage to high voltage, and "pull down" mean go from high voltage to low voltage?

No, "pull up" means that it's connected through a resistor to "postive" so that, if no device is driving it low, it will be defaulted to postive. You might want to check some tutorials on it. But, it's not required for communication with Rx/Tx lines.

@paul i have done some but when i connect channel1 to channe2 via jumper wire arduino stop working and text stop coming on serial monitor.

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


text:
UNO Power supply to USB
If UNO is supplied with 9VDC to Power Jack.
Will it supply power to USB connector?

No

As you can see in the schematic, the USBVCC is only connected (via a MOSFET) to the 5V line, when the voltage on VIN (barrel jack) is LOW.
If you connect 9V to the power jack, the mosfet will turn of, and disconnect the USB power from the 5V on the UNO.


text:
How to Capture Data from a Webpage in Arduino and Display it over Serial Monitor of ESP8266?
My Code is as follows->
#include <SoftwareSerial.h>

SoftwareSerial ESP8266(8,9);

String inData;
void setup() {
ESP8266.println("AT");
delay(1000);
ESP8266.println("AT+RST");

}

void loop() {
 String cmd = "AT+CIPSTART=\"TCP\",\"";
 cmd += "api.thingspeak.com";  // 184.106.153.149 thingspeak IP address
 cmd += "\",80";
 ESP8266.println(cmd);

 if(ESP8266.find("Error"))
 {
   Serial.println("AT+CIPSTART error");
   return;
}
String hostt = "GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA";
hostt += "\r\n";
hostt += "Host:api.thingspeak.com";
hostt += "\r\n\r\n\r\n\r\n\r\n\r\n";
ESP8266.println(hostt);

cmd = "AT+CIPSEND=";
cmd += String(hostt.length());
ESP8266.println(cmd);

if(ESP8266.find(">")){
ESP8266.print(hostt);
}
else{
ESP8266.println("AT+CIPCLOSE");
// alert user
Serial.println("AT+CIPCLOSE");
}
delay(5000);
}

Is this the write code? Where am I going wrong?
I am not able to see the required fetched data.
Help me with this.

You seem to only have half a get request there. Where's the HTTP/1.0 ?

Where you are going wrong is you are not receiving a response. You are sending a request and then just walking away not caring what happens.

Okay, then what more code do I need to write along with this code? So, that I may keep getting the data in void loop() ?

Okay. Guys, After obtaining this '>' symbol, I inserted GET /HTTP/1.1 and pressed Enter and then typed api.thingspeak.com/apps/thinghttp/send_request?api_key=**************   .Now I got the Output as +IPD,728:

The page you were looking for doesn't exist (404)

The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.

Now what? Where am I going wrong ?

Please edit your question to add further information. This is not a forum where you gradually tease out information in a whole heap of comments.

There are two basic things you are doing wrong:
Firstly your HTTP request is wrongly formatted.  You have:
GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA
Host:api.thingspeak.com

What it should look like is:
GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA HTTP/1.0
Host: api.thingspeak.com:80

Also you only need one blank line after your request, not 5 as you seem to have.
Secondly you are not actually doing anything with the data the site is sending you. You make the request with +CIPSEND= but then the response, which is in the form +IPD,<len>:<data> is completely ignored.  You need to use the SoftwareSerial's .read() and associated functions to receive that data into the Arduino so you can actually do something with it - like send it down through Serial.
Tips:

Look for +IPD, first
Read up to the : and interpret it as a number
You now now how many bytes to read from the data section
Read that data
Do something with it

Okay. Thanks @majenko for the reply . What is the proper Syntax to send a proper HTTP request. Can you help me with it. ?

That should actually have been a comment but the really annoying Android app is crap. You hav ethe right format in your code, but not in your manual test.

I am sorry, I don't understand. I am a Newbie. So, just help me with what should I write after the > Symbol , so that I can get my desired output? Help me with the syntax

You have seen the kind of thing it responds with in your test... +IPD,:. You need to use the serial read commands to read that data in and interpret it so you can then display it how you want. At the moment the response is going nowhere because you just aren't reading it. I suggest you find a few more tutorials that show you how.

Yes, I will refer to how to Serial.read() my required command from that data after +IPD, . Thanks for the heads up. And, just one question, to you. -> Now whenever I type : GET /HTTP/1.1 and then after \n\r I type in this: api.thingspeak.com/apps/thinghttp/send_request?api_key=VD9G5A50GGKH01J0 , why does it say "the Webpage is not available ? " I even tried googling for this, but didn't find any hopeful answer.

Because that is a badly formed request. Read your own code, it has the right form in it.

or it almost does - it lacks the HTTP/1.0 at the end of the GET request.

I am not getting that. It lacks the HTTP/1.0 request means what do you mean to say by that?    Can you Answer me with the correct form of the Syntax for that sentence. Pls?

Yep. Thanks for that. It worked. :) My > is now responding with a proper answer.


text:
Arduino Blocks at Uploading

I am trying to make an operating hours counter with arduino, i started with a basic script to make the arduino work as a stop watch, This is my script:
unsigned long start=0, finish=0, elapsed=0;

 void setup() {
 Serial.begin(9600);
 Serial.println("Clock START");
 }
 void displayResult(unsigned long elapsed){
   float h,m,s,ms;
   unsigned long over;
   h=int(elapsed/3600000);
   over=elapsed%3600000;
   m=int(over/60000);
   over=over%60000;
   s=int(over/1000);
   ms=over%1000;
   Serial.print("Elapsed time: ");
   Serial.print(h,0);
   Serial.print("h ");
   Serial.print(m,0);
   Serial.print("m ");
   Serial.print(s,0);
   Serial.print("s ");
   Serial.print(ms,0);
   Serial.println("ms");
   Serial.println();
 }

 void loop() {
   start = millis();
   delay(200);
   Serial.println("Start");
   Serial.println("doing Operations and stuff");
   delay(800);
   finish=millis();
   elapsed=finish-start;
   Serial.println("Ended !!!");
   displayResult(elapsed);

 }

Unfortuantly the arduino compiler blocks at the Uploading part, i tried compiling it at first without uploading, it gave me no warning errors. I tried compiling other scripts they worked, it only blocks for this stop watch code.
Thank you for your help

What's the error message?

I don't get any message error, it just hangs there for 5 minuts at it just gave me :  avrdude: stk500v2_ReceiveMessage(): timeout

Weird. I have no problem uploading and running this on my Mega. Looks like a communication problem. What is your OS? BTW: there is no point in using float variables here.

I use windows 7, i also tried other usb ports but it just hangs for this exact script.

There is a bug in early versions of the Mega2560 bootloader.  It crashes on !!! (or enters some other special state that stops uploading happening).
Your string that contains !!! will be breaking it:
Serial.println("Ended !!!");

Simple solution: don't use so many exclamation marks.


text:
How can I set 4 Arduino Leonardo PWM-ports between 200Hz and 1kHz?
I've noticed that I can set D9, D10, and D11 to around the timer 1 can be set to ~244Hz. However I need 4 ports that are between 200-1000Hz but I have been unable to figure out how to find the last one. I can't really touch timer 0 as they control millis etc.

Can't you use a software PWM? If your loop is long ok, you can't, but if it isn't maybe you can just implement it..

The ATmega32U4 on the Leonardo has 4 timers, named Timer0, Timer1, Timer3 and Timer4. Timer0 would be used for millis().
Timers 1 and 3 are 16-bit timers, and Timer4 is a 10 bit timer.
You can get a wide range of frequencies by changing the prescalers and other factors. A bit would depend on whether you want them to all have the same frequency (but maybe with different duty cycles) or different frequencies. Each timer has two "ports" associated with it, so you can have different outputs - up to a point - for each timer. A given timer can only be in one mode at a time, which limits a bit what its two output ports can be doing at one time.
I have a page about timers which is for the Atmega328P, but the Leonardo timers have a lot in common with that. For more details see the ATmega32U4 datasheet.
You could get a more detailed answer if you clarified what the exact frequency you want is, what mode (eg. PWM, fast PWM or something else) and whether each output should be the same or different frequencies.

According to the Leonardo product page:

PWM: 3, 5, 6, 9, 10, 11, and 13. Provide 8-bit PWM output with the analogWrite() function.

So even if you lose two to Timer 0, you should have 5 outputs left (it looks like the "B" side of Timer 1 and Timer 4 share the same pin).

According to Arduino Leonardo, you have available for PWM configuration ports numbered 3, 5, 6, 9, 10, 11 and 13. The specifications presented there do not provide the range of the frequency available, but I would expect that if you are able to use 9, 10 and 11, one of the others would fall into place.


text:
Press the Windows key using "keyboard.press();"
Is it possible to allow an Arduino Leonardo to simulate pressing the Windows key using the keyboard.press(......); command?
If so, what is the required value?

Add a delay(20) after the keyoress

if i want to press numbers key which value I need to enter in program??
Like I want to press Control Key + number Key 1... Keyboard.press(KEY_LEFT_GUI); Keyboard.press('which value I need to enter for key 1?'); Keyboard.releaseAll();

They Keyboard.press() command accept modifiers per the documentation. You may need to do multiple press() commands before releasing.
For example, if you want to launch File Explorer you could use:
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('e');
Keyboard.releaseAll();

This is equivalent to shortcut keys Win + E.
The modifier GUI is what stands in for the "command key" which is the Windows Logo on a PC or clover (⌘) on a Mac.
I don't have any restriction on the higher value on my board (Pro Micro), as indicated by @frarugi87.

Looking at the list of the HID keyboard codes (page 53), the keys you are looking for have a code of E3 (Keyboard Left GUI) or E7 (Keyboard Right GUI).
Unluckily the Keyboard::press function (you can see it here) does not accept a so high value, since you can only input numbers between 0 and 255 and, in order to send a raw value, you have to send its value plus 136 (which leads to values 363 and 367).
However, looking at the header file, there are two predefined keys called KEY_LEFT_GUI and KEY_RIGHT_GUI. Maybe these modifier keys behave in exactly the same way.
So my suggestion is to

try using one of those values (i.e. keyboard.press(KEY_LEFT_GUI); or keyboard.press(KEY_RIGHT_GUI);, or use the keyboard.write(KEY_LEFT_GUI); to simulate a press on the key instead of you keeping it pressed).
If this does not work, create your own library copying the keyboard.cpp and keyboard.h files, calling the class differently and adding the possibility to send the E3 and/or the E7 keys. In this case, you will just need to modify the press function.

Good luck

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


text:
Arduino IDE menu doesn't display properly (missing letters)
I have just installed newest version of Arduino 1.7.10 from arduino.org.
It has this problem that its menu are not displaying properly - when I hover mouse over items in menu they either disappear completely or some of the letters are missing. Sometimes the whole menu (like 'tools' menu) won't even display. Dialog windows (like "Do you want to save your changes") also suffer from this problem.
I have Windows 7 and I just installed newest version of Java to see if this helps, but it doesn't.
Have any of you had such problem?

Could you please add a picture to your question?

Do you have the same problem with version 1.6.8?

Installing 1.6.8 helped. Now it works. I don't why.

I've never had this problem, but here are some things you might want to look at.

Did you install it from an administrator account and use "run as administrator"?  If not, uninstall and reinstall.
Its possible that you are missing a font, god knows which one.  Go and look at the Arduino source on GitHub(?) and find any TTF files and install them.
Does this version support Windows 7?
What version did you have previously? Did you uninstall it before installing this?
If you didn't have a version before this one, uninstall this version go and get 1.5 or 1.6 and install that, then install 1.7 over the top.

Good luck, and keep monitoring the Arduino.org forums because if it is a problem with the app then they will start screaming quite quickly.


text:
System Is not Functioning Error. Windows XP, Arduino Uno R3, C# Listen SerialPort
Can anyone help me with this issue.
We created an arduino project. We listen microswitch.
If switch click, Arduino send basic serial data.
And C# application read serial port.
This solution is working but after more times (3Hours, 5Hours,..) system stoped.
Error message is "a device attached to the system is not functioning"
Solution: Usb remove and retry plug system is going to running.
We are try putty.exe maybe problem C# project but don't working.
If microswitch click don't flash "TX" or "RX" led.
const int button = 3;

uint64_t bounceTime = 50;
uint64_t holdTime = 250;
uint64_t doubleTime = 500;

uint64_t lastReading = LOW;
uint64_t hold = 0;
uint64_t single = 0;

uint64_t onTime = 0;
uint64_t lastSwitchTime = 0;

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

void loop() {

 int reading = digitalRead(button);

 if (reading == HIGH && lastReading == LOW) {
   onTime = millis();
 }

 if (reading == HIGH && lastReading == HIGH) {
   if ((millis() - onTime) > holdTime) {
     hold = 1;
   }
 }

 if (reading == LOW && lastReading == HIGH) {
   if (((millis() - onTime) > bounceTime) && hold != 1) {
     onRelease();
   }
   if (hold == 1) {
      delay(5000);
      reading = digitalRead(button);
      if(reading==LOW){
              Serial.println("B");
      }
     hold = 0;
   }
 }
 lastReading = reading;

 if (single == 1 && (millis() - lastSwitchTime) > doubleTime) {
   single = 0;
 }

}

void onRelease() {
 if ((millis() - lastSwitchTime) >= doubleTime) {
   single = 1;
   lastSwitchTime = millis();
   return;
 }

 if ((millis() - lastSwitchTime) < doubleTime) {
   single = 0;
   lastSwitchTime = millis();
 }

}

Why not uint32_t?

@MikaelPatel irrelevant

I assume that by "USB" you mean "USB-to-serial adaptor".
Try running the same code without any serial communications, just have an LED do the equivalent of printing, and power it from a good power supply. If it runs for more than five hours, the problem is with the USB adaptor and/or your PC (Windows XP? Really?), and hence not relevant to this forum.
If the code crashes, then maybe you have a marginal board, or there is some other environmental factor that's giving you trouble. The code looks OK on first glance.


text:
Networking multiple Arduino Megas and updating their programs from one master
Is it possible to link multiple Arduino Megas using RS485, for example, and update the program on client Megas from one master Mega, as well as for them to communicate with each other? Whilst I found multiple examples of networks, nothing comes up for programming the boards other than through a PC
Thanks for any pointers!

In principle, yes, you can do it. It's what existing bootloaders do -- they take code over the serial port, or USB, load it to flash, and then branch to it. Not to mention OTA.
So yes, you can modify the bootloader to use different pins, talk rs485, come up with code-integrity checks, specify particular bit patterns to signal "reboot" or "now load new code", and so on. If you have enough flash, you can even keep two copies, a working and a new, like most OTA code does.
I am not aware of a ready-made library that does that. If I wanted to roll my own, I would start by studying the OTA code.


text:
Arduino Serial Monitor works but not on PySerial and PuTTY
I made simple custom arduino board using an atmega328p and the PL2303 serial to USB chip.
In my arduino program, I am in a loop that sends out a string continuously. I can read this in the Arduino serial monitor with a baudrate of 9600. However, in my python program using the pySerial library, the readline function doesn't return anything. I checked using PuTTY but it still doesn't do anything.
Now I tried messing with the serial settings and found out that these lines of code work (the readline returns the string) if I call it in the exact same order.

ser = serial.Serial(comm_port)
ser.xonxoff = True
ser.rtscts = True
ser.dsrdtr = True
ser.readline()

However, the code below doesn't work
ser = serial.Serial(comm_port, xonxoff=True, rtscts=True, dsrdtr=True)
ser.readline()

What could be causing this? My guess is somehow I've switched the datalines in my USB cable and that the arduino serial monitor handles this somehow.
Another thing to note is that I couldn't program the Arduino the normal way via USB. I always have to program it using the ICSP port and a USBasp programmer.

I wrote a python application which communicated with an arduino and for some reason I had to insert a delay after opening the serial for it to work correctly, if I didn't the first data I sent would always get dropped. Perhaps that's what's occuring here? Setting the attributes of the serial connection like that is probably slower than doing it in initialisation.
For myself I found that a delay of 3 seconds was what I needed for it to work 100% correctly on all computers (on some a second was enough). You only had to wait after opening it once open it worked fine.
To do a delay import the time module and use the sleep function which takes an argument of seconds.
import time

time.sleep(3)

Also worth noting depending on your application it's worth setting a timeout value for the serial that's appropriate or just keeping it open with the timeout paramter.
 ser = serial.Serial(com, 115200, timeout=0)

If you do this make sure to close it when you finished with it though (I personally used a try finally block which makes sure its always closed).
try:
  ser = serial.Serial(com, 115200, timeout=0)
  #go nuts with whatever communicating your doing
finally:
  ser.close()

I'm afraid I can't really tell you what caused the issue though. I also realise that this question is quite old so I hope my answer is still helpful, if not to you then to someone else who stumbles across it. To note for future the people on the official Arduino forum may be of more help for arduino related questions in general.

The delay before it is ready is almost certainly caused by the auto reset on serial open behavior and the subsequent bootloader timeout.

Yes, try connecting to the RX/TX pins instead.

"Another thing to note is that I couldn't program the Arduino the normal way via USB. I always have to program it using the ICSP port and a USBasp programmer." sounds like your atmega328p does not have a bootloader. Or the PL2303 does not have the correct driver.
I never used PL2303, but I have used FTDI USB TTL (ft232r) adapters. When I first used the adapter, my Windows computer installed the wrong driver for the adapter and I had to manually download the correct firmware from the FTDI website and install it manually. You can check if the driver is correct in the device manager, the author of the driver should be the manufacturer's name (not Microsoft).


text:
Send information (such as a string) over digital pins
I wan't to send information from my arduino digital pins to another arduino's digital pins like a string, or a char. Can I do this without something like Software Serial?
The reason I am asking is because I am wanting to send information from several serial devices to my raspberry pi from an arduino. Thing is, that Raspberry pi only has one set of UART pins, so I was thinking because I have extra arduino uno's, why not send then information to the arduino and have it write the received information to the raspberry pi's digital pins..
Now that I am writing this, I think I will connect the 2 arduinos via a serial connection, and use software serial to write out to the raspberry pi, in three different stages, to get the information to the pi.
The reason I am using the PI is I want to display this information on a large screen with many different options, in short the GPU capabilities are what I am using the PI for, that and Processing.
Question still stands though, can you send information over digital pins?

If you have a RPi, why do you need Arduinos?

@IgnacioVazquez-Abrams I need one arduino to remotely pilot a platform and receive readings from various sensors connected to it, that will transmit that data wirelessly to a raspberry pi, but it will also need several serial devices connected to it..hence my problem, multiple UART's and a good GPU.

Yes, you can send information to/from your arduino digital pins using a method called Bit Banging. Wikipedia (lots more on Google!)
You can use the Arduino to output as an ad hoc serial port or parallel port. The serial could be asynchronous (UART/RS232/I2C) or synchronous (such as SPI).
The down side is you will have to write a fair bit more software to send/interpret the data.
From your description I gather that data is only going one way - from the Arduino to the Pi. I personally would bit bang SPI as I think this would be the easiest and would not require exact timing.

Thanks for the answer. I will keep this in mind! I am just going to use the arduino for multiple serial connections using software serial..so I don't think I will need to "bit bang", but useful none the less. Thanks for answering the question!

@sa_leinad, Not sure why you are going this way if you want to aggregate all data onto the RaspberryPi.  In order to use SPI or I2C you will have to make adjustments to the RaspberryPi Linux kernal.  If you go RS232 you will have to start getty programs on the RaspberryPi for every serial port you manage to set up.  The USB/FTDI solution may be the easiest to implement on the RaspberryPi.  And there is already an FTDI chip on most Arduino Uno's.

The RaspberryPi is a fairly complete linux computer.  As such it can be a USB Host to many USB Devices.  If you need more serial ports simply buy FTDI equipped USB to serial cables, plug them into a USB hub and plug that into the RaspberryPi.

Thanks for the answer. If I didn't want to buy any additional parts, could I use an arduino to act as multiple serial connections for the PI?

Also can I take an existing USB cable and cut off an end to get this? Or does something else take place here?

Actually, yes.  The (most) Arduino Uno contain an FTDI chip.  That is how the Arduino talks to the host computer.  I think what you will still need (unless you have a RasPi with lots of USB ports) is a USB hub to aggregate all the Uno's USB cables.

Your 2nd question:  The USB protocol is very complex.  It is likely that you will never cut a USB cable to get to the data.  Only to get to the 5 volts on the out side pins.

There are many different ways of communicating.
In addition to serial you can use a protocol like SPI or I²C. If the Arduino are in close proximity I²C enables many devices to communicate on a common bus.


text:
Power supply change change gps readings?
I was powering a GPS Sensor from the 3v3 pin of a raspberry pi and my reading for my GPS sensor had some strange symbols in the mix, but when i switched to the 3v3 on the arduino, my reading came back to normal. This wasted several hours of my time.
Any idea why i would get weird readings when using a different power source?? (even though it is the same voltage)
Note: Both the raspberry pi and the arduino are getting their power form the USB that is connected to my PC.

The Pi can only supply ~50mA from 3.3V. This is unlikely to be enough to run GPS.
In addition USB can only supply 500mA. This is marginal at best, and below the recommended minimum for Pi.


text:
My Arduino UNO turns LED ON forever when I connect it to my Laptop

My Arduino UNO Board keeps the LED light turned on forever whenever I connect it to my PC. And, when I try to upload even a sample sketch, it says avrdude: stk500_recv(): programmer is not responding.
How can I fix this error?

Could you try replacing the ATmega328P? You'll want to check if it's the board or the microcontroller.

Okay. My ATmega328p is a microcontroller over my Arduino UNO Board. I am a newbie. So help me in fixing that error.

Do you have a picture of the board? Could you add it to the question?

Yep. Did it. Check it now.

Hmm, the chip under the wordt "UNO" is your microcontroller, the brains of the device (: in some Arduino's, it's a replacable one, but this one is unlikely to be replaceable ;p

What is the chip right under the crystal, at the side of the USB labeled? And did the Arduino work before or is it a new one?

Cheap Chinese clone by the looks of things...

Yes, it was working fine. I even did run some programs efficiently over this piece. But, now since last 2 days, it's been giving me that error for whichever Laptop or PC I connect to.

And about that Chip, @Paul , I don't quite know what it is. A specification guide did not come with this piece.

@Abhay, it looks like a CH340G, does it have any markings like that? But when you get an upload error, it's often either the "USB chip" or the "microcontroller". (Or just complete fail) can you check the 5V and 3.3V pins, if they do givethe correct voltages?

When you connect (and disconnect) the device, are you getting the Windows "found device" sound?  If not, it's possible that your device driver is either corrupted or "confused".  If you don't get the sound, then I can walk you through checking the driver.  If you are getting the sound, make sure that in your IDE, that you select the UNO board, and then select the COM port.  It's possible that through plug and play, your COM number has changed, and you IDE is still trying to use the old one.

When you connect the device, if you hear the Windows "found device" sound, then you need to check your COM port driver, as it's very likely that the COM port number may have changed. On your Desktop or in File Manager, right click "This PC" or "My Computer", and select "Manage" from the submenu.  That will bring up the Computer Management console. On the left, select "Device Manager".  That will bring up your list of devices. In the list look for "Ports (COM & LPT)".

If you don't see, "Ports", then click "View" and check "Show hidden devices".  If this is the only Arduino that you've ever used, you should only see one listing. Make note of the COM Port Number the driver is using. It's possible that the port number may have changed since you first used the device. Plug-n-play will do this if you plug the cable into a different USB port that may be using a different USB controller, etc.
Then in your Arduino IDE, click "Tools", then expand "Boards" and select "Arduino/Genuino UNO" board, then re-click "Tools", and hover over "Port", and select the port number that is assigned to the Port that you found in Device Manager.
If that doesn't work, then you may have a problem with your driver.  Some of the "cheap chinese board" use a different FTDI chipset, so the plug-n-play windows driver may not work. In that case, the manufacturer should point you to the correct driver. Download their provided driver, then you can update the driver in Device Manager.

As answered by @Zacwolf , I checked that. It hasn't changed for my Arduino UNO. My Port is "USB-SERIAL CH340 (COM 3)" port. It was the same before too.

And, I discovered one thing more, that before this problem i.e. before few days, it used to connect to any laptop and run any Arduino program. And now, it doesn't connect to any of the Laptop. And, the LED for the Arduino still is ON continuously.

@Paul , the Chip which you had asked which is placed right under the crystal, at the side of the USB is labeled as AMS1117.

I do get the sound of Windows found device @ZacWolf whenever I plug it to the computer.

Help Anyone? ? ? !

Help me locate the ICSP header pins for Serial interface. I want to check this board by flashing  it's bootloader.

The 6 pins on the right in the photo are the ICSP header for the Atmega328P chip. You don't have an ICSP header for the Serial chip because it isn't a genuine Uno, and they have used a cheaper USB-to-serial chip which isn't programmable. Under the circumstances, presuming it was cheap, I would just replace the whole board.


text:
error: invalid conversion from 'char' to 'char*' [-fpermissive]
I have written a simple code to read data from capacitive keypad and display it on LCD.
I am getting the data from keypad in following data structure.
char phoneNumber[PHONE_DIGITS];

and then displaying the data on LCD as
   LcdString(phoneNumber[i]);

where my LCD string function is
void LcdString(char *characters)
{
  while (*characters)
  {
    LcdCharacter(*characters++);
  }
}

There is a type cast error

error: invalid conversion from 'char' to 'char*' [-fpermissive]

How can I debug it?

You're calling your function with a single char, specified by phoneNumber[i], but your function is expecting an array.
If you change your call to:
LcdString(phonenumber)

then that will pass the entire array.
Are you trying to say that you're storing multiple phone numbers?  i.e. a two dimensional array?  Check out the String reference for more details: https://www.arduino.cc/en/Reference/String


text:
Bluetooth sending values from two joysticks
Is there any good way of sending values from two joysticks from arduino A to arduino B? I tried sending using if statements, so if the Y- or X-axis' value changed then it would send that, but the servo motor on Arduino B went a little bit crazy.
Here's what I've done so far:
//Master Code
void loop()
{
      yVal = analogRead(yAxis);   // read the value of the Right Joystick (value between 0 and 1023)
      yMap = map(yVal, 0, 1023, 0, 255);
      xVal = analogRead(xAxis);     // read the value of the left Joystick (value between 0 and 1023)
      xMap = map(xVal, 0, 1023, 0, 110);

  if(Serial.available() && !(xVal > 505 && xVal < 510)){
      Serial.print('X');
      delay(10);
      Serial.write(xMap);
      }
  if(Serial.available() && !(yVal > 500 && yVal < 520)){
      Serial.print('Y');
      delay(10);
      Serial.write(yMap);

    }
    delay(10);
}

And the Slave code:
//Slave code
void loop(){
  while(Serial.available())
  {
    c = Serial.read();
    delay(5);
    val = Serial.read();
    if(c == 'X'){
        digitalWrite(13, LOW);
        myServo.write(val);
    }else if(c == 'Y'){
        digitalWrite(13, HIGH);
    }
    }

}

Edit: I was thinking that maybe I should do something like a start and stop bit for X and Y?
Edit2: I wrote an if statement in Arduino B because it was reading the value -1, I don't know why, but after the if statement the servo motor hasn't been going crazy and the program works now. I still would like to know if I can do this in a better way. Thanks in advance!

There are a number of possible issues in the code.  1) Can the sender and receiver get out of sync.  That is, can the sender send the "x" character when the receiver is expecting a servo-position-number?  Perhaps you might map to 0 through 254 and reserve the value 255 as a synchronization marker.  Then send "marker", X then Y over and over again.

Arduino A
You can read the values from two joysticks as normal and send it like this. This method ensures of no data loss. Ensure that you read the values and store them in appropriate variables and then send it over serial.
// Setting Sensor pins
const int potPin = A0;
const int pot1Pin = A1;

// Creating variables
uint8_t pot;
uint8_t pot1;

void setup() {
// Declearing the pinModes' for sensors
  pinMode(potPin, INPUT);
  pinMode(pot1Pin, INPUT);
// Begining Serial Communication
  Serial.begin(9600);

}

void loop() {
// reading from the sensors
  pot = map(analogRead(potPin),0 ,1023, 0, 255);
  pot1 = map(analogRead(pot1Pin),0 ,1023, 0, 255);

//Packing the Serial message
  Serial.print("U*"); //A header
  Serial.print("A");  //a token to indicate the message payload
  Serial.print(pot);
  Serial.println("");

  Serial.print("U*"); //A header
  Serial.print("B");  //a token to indicate the message payload
  Serial.print(pot1);
  Serial.println("");

}

Arduino B
After the data are packed and sent over the serial. You need to unpack it with the other Arduino/device
The code will look like this:
String data; //Store each line of Serial communication
String pot1String = "0", pot2String = "0";
float pot1, pot2;
void setup()
{
  //initialize Serial communication
  Serial.begin(9600);
  //read first package
  if (Serial.available() > 0)
  {
    data = Serial.readStringUntil('\n');
  }
  //Disregard the first reading
  data = "0";
}

void loop() {
  //start reading from serial
  if (Serial.available() > 0)
  {
    data = Serial.readStringUntil('\n');
  }
  String payload = "";
  if (data != "0")
  {
    int offset = data.indexOf("U*"); //This is the header (0x552A)
    if (offset >= 0)
    {
      payload = data.substring(offset + 3, data.indexOf('\n'));
      char value = data.charAt (offset + 2);
      switch (value)
      {
        case 'A':
          pot1String = payload;
          break;
        case 'B':
          pot2String = payload;
          break;
      //Add more case as the project grow
      }
    }
  }
  //convert strings to float
  pot1 = pot1String.toFloat();
  pot2 = pot2String.toFloat();

// Continue with the rest of your project

}

Make sure to use the same baud rate in both sketches

Hope this helped. Ask me if you have farther questions

Oh wow, thank you for posting this. I'll see if I can get this to work :)

I've been trying to look on Arduino B's serial monitor to see if the values of pot1 and pot2 change, but they don't. I haven't changed anthing in the code except for the baud rate. The values change the very first time I touch my joysticks, but after that it just prints those values over and over again.

Can you tell me how you read the joystick values? Did you change the baud rate in both sketches? Is your baud rate in serial monitor the same?

Try connecting the Rx, Tx of two Arduino together (Rx, Arduino A => Tx, Arduino B & Tx, Arduino A => Rx, Arduino B)

I connected Rx to Tx and Tx to Rx and I read the joystick values with analogRead. I've set the baud rate of both bluetooth modules to 115200, but so far no luck.

the Serial can be used by one device at any given time. Even when you programming the Arduinos you should disconnect both Rx and Tx so the boot loader won't get confused. I'd try connecting the arduino's Rx and Tx pins directly with no Bluetooth modules just to make sure that the serial connection is initialized fine and then try adding the Bluetooth modules.

Thank you. I used a battery with low current to power my arduino, that is why I never got it to work. I am now using two USB-B cables connected to my computer and it works flawlessly. I can't thank you enough for this code, it really is well-written and easy to understand :)

When using the ADC to control servos I get much better results when I process the ADC values through an exponential smoothing function:

There is less jitter.  However there is more lag.  You can tune the function by changing alpha between 1 (no history, effectively no smoothing at all) to 0 (no new data is averaged in, effectively not changing).  Pick 0.5 to start with.  If there is too much jitter pick smaller numbers until the jitter is reduced and the lag is still tolerable.


text:
How do you extend the wires from the arduino board to both fsr sensors to be placed on both chairs (one for each)
I’m trying to figure out how to extend the wires for both force sensitive resistors so that it could be place on each chair, one sensor on one chair and the other sensor on the other chair
This is how this was originally connected

So what would be the best way to extend both cables to place both sensors on each chair

why can't you use longer wires? Are there capacitance or noise problems?

In ADC sampling there will always be noise.  Longer cables may increase that noise.  Sensors with lower resistance tend have less noise.  For these reasons it would be better to start from a schematic, part numbers and / or specifications rather than a picture.
There are a number of ways to reduce noise.  Hardware solutions include twisted pair and shielded cables.  Software solutions include averaging multiple samples and removing outliers.
If all you are asking is if you can use longer cables, the answer is yes as long as you can tolerate the or compensate for additional noise if any.

In order to extend the wires you will need:

Crimp Connector Housing
Female Crimp Pins
Male Crimp Pins
Stranded Wire: 30 AWG

and if you want to do a better job than bread board then you can use a Strip board to solder your resistors on and some headers to connect your wires.
You should not get any noise in ideal situation.
I don't know where you from so I just posted the links to the store I usually buy from. you can find these items on ebay or similar. Plus you will need a crimping tool as well.


text:
How to calculate the needed voltage and current to supply for Arduino
I have Arduino MEGA and I'm connecting to it 5 servomotors.
{ 3 TowerPro M995
Basic Information

Modulation:  Digital
Torque:  4.8V: 130.5 oz-in (9.40 kg-cm)
6.0V: 152.8 oz-in (11.00 kg-cm)

Speed:  4.8V: 0.20 sec/60°
6.0V: 0.16 sec/60°

Weight:  1.94 oz (55.0 g)
Dimensions:
Length:
1.60 in (40.7 mm)

Width:
0.78 in (19.7 mm)

Height:
1.69 in (42.9 mm)
Motor Type:  3-pole
Gear Type:  Metal

2 Towerpro M996R

Basic Information

Modulation:  Digital
Torque:  4.8V: 130.5 oz-in (9.40 kg-cm)
6.0V: 152.8 oz-in (11.00 kg-cm)

Speed:  4.8V: 0.19 sec/60°
6.0V: 0.15 sec/60°

Weight:  1.94 oz (55.0 g)
Dimensions:
Length:
1.60 in (40.7 mm)

Width:
0.78 in (19.7 mm)

Height:
1.69 in (42.9 mm)
Motor Type:  3-pole

}

So how can I calculate the voltage and current needed to supply this Arduino?

Use a LiPo battery then you never need to worry about current again :)

Drive all your components simultaneously from an external supply at appropriate voltage. Measure current draw in series (set your multimeter's red cable on the 10A port and set it to 10A, and connect red to VOUT, black to ground). Don't hold the wires in your hands, use clip-ons. Let it run for a while, and pay attention to current fluctuations. Read the current requirements on the display. A power supply with a bit more amperage than necessary is a Good Thing(tm).
Edit: remember to get both normal load and stall measurements. It is wise to add some way of turning stalling motors off, since stalling is motor death. And sometimes power supply death - those segway-for-kids things come to mind (and make me snicker ... WHEN I WAS A CHILD WE HAD OUR FEET FOR TRANSPORTATION, AND SHOES, IF WE WERE LUCKY!).

Voltage is simple - a device has a requirement and that is what you have to provide. In the case of the servos that is a range of voltages that it can use. So 5V is a good voltage.  The Arduino can take 5V if you feed it in to the 5V pin or the USB port, or 7-12V if you feed it in to the barrel jack.
The current you cannot calculate. You haven't provided enough information. The calculation, when you have the information, is quite simple: for all the devices on the same power supply add the currents requirements together. The supply has to be able to provide at least that amount of current.

I couldn't find information about the current anywhere :/  this is the info provided by the main website..   the servos are connected in arduino ... so they are taking the volt from 5V in arduino ..

Then you will have to measure the current with your trusty DMM.

Measurements in ordinary cases will not be a reliable indication of what can be encountered.  The servos should not be powered through the Arduino.  Expect that they can draw up to several amps when loaded, especially in combination.


text:
TFT screen to change sketches
I have an Uno + WiFi 101 thermometer and I'd like to be able to take it places and easily change WiFi network SSIDs and passwords.  Can I use a TFT screen to make these changes to a sktech or am I stuck using a PC and IDE for this kind of thing?
Can someone provide a sample sketch of what this might look like?  I want to know it's something that's possible before I spend the money on a TFT.
It's possible (let's face it, LIKELY) that I fundamentally misunderstand the capabilities and limitations of the TFT screen.  Sorry for the noobish question.

The screen is just a screen. You can do whatever you like with it.

So...you can use it to modify sketches and not just view output?

If that's how you've written your sketch.

That is encouraging.  I hope that someone can provide more detail.  My research continues.

All the TFT does is display things -- it's just a screen.  What Ignacio is saying is that if you have written your sketch to be able to modify itself, then you can use the screen to display a user interface.  The screen can't modify your sketch.  Your sketch technically can modify itself, but it is very difficult to do so and would require a custom bootloader.  It would be a lot easier to store the data that can be modified in EEPROM.

If you post that as the answer I'll close this out.

A TFT screen is just a screen. You can't modify SSIDs and passwords with it, any more than you can by poking your PC monitor (unless perhaps you have a touch-screen*). To modify things you would need:

An input device (eg. a keypad)
A method of displaying what you are entering (this is where the screen would be handy)
A method of storing the new information. You could store things like passwords in EEPROM.
Code to make all that work.

* Some distributors sell touch-screen interfaces designed to go on top of screens - this might conceivably be what you are thinking of. However you still need the touch-screen, and code to make the touch-screen, and the TFT screen, work.


text:
How to request data via I2C?
How do you program an Arduino Uno to request data over I2C, sending parameters defining the request?
I'm trying to program Arduino A to read a sensor value from another Arduino B, and it first needs to tell B which sensor to report, but I can't find any easy way to do this with Arduino's Wire library. There doesn't seem to be anything like Wire.requestFrom(addr, 1235, 2) which would then call a handler on the slave the looks like onRequest(sensor_id).
I found this page on how to push data one way to a slave, and I found this page on how to request data from a slave without specifying any input, but I can't find anything in between.
Is the solution to use the first method to set the parameters, and then the second to get the data? If so, that seems very circuitous. Is there a more direct method?

Welcome to serial communications.

Its the way the protocol is designed. From the very first byte that is sent, you already indicate if you want to read or write data. You can't do both. The protocol is a lot more straightforward this way, one transaction at a time. Plus it gives the feel of a data frame, with START and STOP bits delimiting the frame (not regarding repeated STARTs).
But even for a full-duplex protocol like SPI, you've already said that the master must first send certain parameters to the slave. Nothing can be sent by the slave until it has received these parameters and processed them, full-duplex comms or not. Only after this, can it reply with the requested data.
The Wire methods are designed to send data in one direction at a time, as it should be. You could, of course, create a function like the one in your question, but it would inevitably involve the same process of first writing to the slave and then reading.


text:
Burn new bootloader without crystal
I am considering purchasing these ATmega328 s from
3 pack ATmega328P.
The company says they come with the Arduino UNO bootloader.
I do NOT have any 16 MHz crystals, and I would like to make the chips run on the 8 MHz internal crystal.
I have an Arduino Duemilanove.
Is it possible to burn the minimal setup bootloader from here onto the bootloaded chips without using a crystal?

Have you looked at the datasheet yet?

I'm not sure how much that would help. In the minimal setup description they say the chip will not work when burned with the external crystal bootloader until a crystal (i do not have one) is connected. I was wondering if this applies to bootloader burning as well

Why do you consider buying ATmega with Arduino bootloader if you don't need Arduino bootloader? I'm sure you can finder cheaper sets without any bootloader at all.

I've done just that on a Arduino Pro Mini of mine.
You need to change the fuses to have the chip use the Internal Oscillator, instead of a crystal. After that you just program the 8-MHz version of the bootloader. Like the one used in the Arduino Pro Mini 3.3V.
The only problem is that you need to connect a crystal, to change the fuses to not use the crystal. Though it doesn't need to be 16Mhz. Anything between 1 and 16MHz will do.
But since you need to change both the fuses and the bootloader, there is no advantage to buy chips with the bootloader preinstalled.
I'd just buy some bare chips without the bootloader.
PS $4.66 is on the high side for an ATMega328P-PU.


text:
Multiplying Arrays
I have an issuing multiplying two one dimension arrays together. Each array is an unsigned long that is storing values of factorials. The last row is completely off. My code is below also with a screenshot of the output.
void setup() {
//----------------------------- start serial monitor
Serial.begin(9600);

Serial.println("Factorial Table");
//----------------------------- declare variables
unsigned long fact = 1;
unsigned long r[5];
unsigned long c[5];
unsigned long product[6][6];
//----------------------------- load facotirals into array(s)
for (unsigned long d = 1; d <= 5; d++)
{
    fact = fact * d;
    r[d] = fact;
    c[d] = fact;
}
//----------------------------- multiply factorials
//                              and load into new array

for (int row = 1; row <= 5; row++)
{
    for (int col = 1; col <= 5; col++)
    {
        product[row][col] = r[row] * c[col];
    }
}

//----------------------------- print factorials

for (int prow = 1; prow <= 5; prow++)
{
    for (int pcol = 1; pcol <= 5; pcol++)
    {
        Serial.print(product[prow][pcol]);
        Serial.print(" ");
    }

    Serial.println(" ");
}

}

In C and its progeny, array indices start at 0. unsigned long r[5] declares an array of five longs; the array elements are r[0] through r[4]. Your loop, however, varies the array index from 1 though 5. r[5] is accessing whatever happens to lie in memory beyond r[4]
Here is a much better version of your code. Note, among other things, the coding style. Remember that you write programs for other humans to read!
const int kSize = 5;
void setup() {
  unsigned long r[kSize];
  unsigned long product[kSize][kSize];
  unsigned long fact = 1;
  for (int d = 0; d < 5; ++d) {
    fact *= d + 1;
    r[d] = fact;
  }
  for (int row = 0; row < 5; ++row) {
    for (int col = 0; col < 5; ++col) {
      product[row][col] = r[row] * r[col];
    }
  }

  Serial.begin(9600);
  Serial.println("Factorial Table");
  for (int row = 0; row < 5; ++row) {
    for (int col = 0; col < 5; ++col) {
      Serial.print(product[row][col]);
    }
    Serial.println();
  }
}

See the difference? Style points to note:

no unnecessary comments. In fact, the code is readable enough that no comments are necessary.
No unnecessary space.
The array size is used in several places; it's better to define it as a constant. There is also no reason to specify anything other than int; a good optimizer will detect that you are never using values of more than 5, and will optimize the code accordingly.
You don't really need two separate arrays, since they have the same values.
You obviously don't need to first store and then print, but I assume you are doing this to learn.
I didn't initialize the Serial port and didn't print the header until i was ready to print. Group logically-related statements together. (OTOH, you might have been thinking that at some point you might want to insert print statements before there, so putting Serial.begin first thing in your code might have been better.

While there are lots of styles around, https://google.github.io/styleguide/cppguide.html is good enough for Google, so it's good enough for me :)
Here is a better way to initialize the array of factorials:
  r[0] = 1;
  for (int d = 1; d < kSize; ++d) {
    r[d] = r[d - 1] * (d + 1);
  }

Thank you for the help on the code. You made good suggestions. I didnt know I could use the same array for multiplying. Also I used an unsigned long in one of the for loops because I was getting weird numbers when calculating the factorials. The code you presented was very neat. Thank you also for the style guide link.


text:
EBay "Development Programmer Board for ATtiny"
Has anyone tried these? Does the ATtiny have a bootloader? What software is used to program the chip? Arduino compatible?
Looks a lot more convenient than programming the ATtiny via an Uno.
http://m.ebay.com/itm/201536595756
/Ola

Does the ATtiny have a bootloader? does it have an attiny?

If you don't have experience working with AVRs at a low level then stay away from that. It doesn't provide any connection for a programmer and relies on the Micronucleus bootloader already being in place.
If you really want to experiment with ATtiny development then go with either an Adafruit Trinket or a Digistump Digispark (both of which already have Micronucleus loaded), or get an AVR programmer and (optionally) a ATtiny13/25/45/85 development board that includes a 6- or 10-pin programming header

It appears to break out all pins, so I would dispute that it does not provide a connection for a programmer.

@ChrisStratton: You can wire a programmer to it, but it does not use the standard 6- or 10-pin connection used for AVR ISP.

Six pins are pretty much only a "because Arduino did that" idea, but if this is an impediment the asker should probably not be attempting embedded projects at all, as essentially anything but blinking an on-board LED will require making individual connections.

Digispark (micronucleus?) USB connection is not reliable: one has to reconnect multiple times for the sketch upload to succeed. "Arduino as ISP" is much more robust solution, it allows changing the clock frequency, does not take any extra memory and startup does not take extra seconds just to decide if someone wants to reprogram it (I used Arduino Nano as my ISP -- a bit clunky setup, but achieves maximum customizability).

The layout of the 8-pins is compatible with the regular 6-pin Arduino ISP, two of the pins just go unused. Only problem is that not all 6-pin cables will fit with two extra pins in the way, but drilling some extra holes in the connector or soldering an adapter together is pretty straight forward.

Okay, so they did think ahead. Fair enough.

TL;DR: It's basically a bigger digispark with a socket and different header.
Just for completeness:
It depends on the product description, recently I ordered two of your link and some of these. Those seem to be the same board as you asked for, but in your link the "Package includes" only mentions the board without MCU, which would render the question pointless.
Like Ignacio already said correctly, without proper equipment you wont get this to work with the Arduino IDE. Once you have a bootloader (e.g. micronucleus) on it (the MCU), you can use it like a digispark.
In fact the USB connection works just like on the digispark and ist not only for power.
The mounted ATtiny85 was preflashed with micronucleus v1.6 and registered as vendor=16d0, product=0753, which means you could even start with it right away, with Arduino IDE and the digistump board manager.
Personally I use these for prototyping small projects with those tinies on the go where you often don't need a programmer. Once you're done or want to do more you can always remove the bootloader and continue with a real programmer. Or you want to reflash while using the reset pin for I/O, also handy.

This board supports Attiny25/45/85 MCUs. It is possible to use bootloader with this board. It can be a low speed (1.5MBps) USB device. More info can be found in this article: https://makbit.com/web/firmware/breathing-life-into-digispark-clone-with-attiny-mcu/

ATtiny13A is also supported

I just used one of those boards in conjunction with a cheap tinyISP board to program a DIP8 attiny85 using ISP from Arduino IDE.
The pinout matches if you put the IDC cable the right way around. I used a 10-pin IDC cable - I think you'd have to use at least an 8-pin IDC because a 6-pin wouldn't fit with the extra pins on the programmer board, unless you only soldered on the 6 header pins that you need for ISP.

If you program the digistump bootloader onto the attiny85 then you should be able to use the USB socket on that board to reprogram it. But if it's a blank attiny85 then you have to use ISP to program it in the first place.
Here's how I hooked them up:

You can see from the silkscreen that the pins are clearly designed to match up to the Arduino ISP pinout:

I don't see than much usefulness in these boards.
Negatives:

The USB port is only for power. Not for programming.
You have to buy an ATTiny chip to put into the socket. It's not included.
There is no way to put this into a breadboard.
There isn't even a way to get to the output pins. So you have to put the chip into this programmer, program it, remove it from the programmer, and place it back into the circuit.
It seems to use an 8-pin header to break out the 8 pins on the ATtiny. You'd have to use some female jumper wires to connect to them.

Positives:

There is a voltage regulator, so you can connect a higher voltage to the VIN pin
There is an 8-pin ISP header, so you can easily connect a ISP programmer, like an USB-ASP

So in conclusion, some minor plus sides, and some major downsides.
Just place the 8-pin DIP ATtiny in a breadboard.

AVR ISP uses 6 or 10 pins, never 8. You might be able to force a 6-pin connector in there, but you probably wouldn't want to.

@IgnacioVazquez-Abrams Oops. I guess this isn't a programming header, but it's the 8 pins of the DIP-chip broken out into a 2x4 header.

The claim that the USB port is only for power is likely erroneous - the surface mount components next to it strongly resemble those used to enable a software-based "close enough" USB data interface, and bootloaders leveraging that idea exist.  While limited, this type of board can be useful for "blink an LED on USB command" type tasks, or even simple ones that do not need data communication in operation.

@chrisstratton I think you're correct. You'd however still need to program the digispark/mononucleos/trinket bootloader. There also seems to be a led attached to one of the pins for a blink sketch. I however stand by my conclusion that it's a rather useless board. Just get a digispark clone if you want USB support. Or better a USBASP and some bare ATTinys.

The socket is important. One of the huge benefits of using these 8 pin packages is the ability to plug and pull over and over again. Sadly there are few development boards not obsessed with USB. Thankfully this one's is a power header and can be removed easily enough. The Digi/Ada offerings and their clones are not socketed. They are also simple enough to do your own boards.
You can program the x5's with the SparkFun Tiny AVR programmer, based on a design by D.A.Mellis using leads, or by transplanting the mcu. And you can do it from an Arduino, either way you are making up or sourcing a lead, as squid style flying leads are tedious.
Otherwise there is a 2k or so bootloader that can be used, which would be most useful for the 85. Without serial support from USB or FTDI this will be hard.
Software

Arduino with core from https://github.com/SpenceKonde/ATTinyCore
avra and avrdude from the command line for assembler, you could also compile C/C++ from the command line but this is not common.
AVR plugin for Eclipse.
Sloeber stand alone Eclipse based Arduino IDE, some quirks.
Atmel Studio 7 based on Visual Studio, requires Windows, requires genuine "Microchip" programmer. Note this is free and includes an emulator.
There is some effort to get this possible with C-Lion by JetBrains.

.


text:
How to connect an LED to Arduino LilyPad Mp3
can anyone help me with connecting LED to Arduino LilyPad Mp3  in a way, that each switch (1 of 5) light up a different LED?
I tried connecting an LED between the switch and the board, then the LED light up, but the speaker does not play the audio file.
I also tried connecting an LED directly to the speaker, then LED lights up and the speaker plays the sound file, but the problem is that all of the LED´s light up at the same time....

What kind of switches? How are they wired?

You might try connecting the anode side of your LEDs through a current limiting resistor to the positive side of the supply.  Then connecting the cathode side of the LED to the switched pin on the Arduino LilyPad Mp3.  So, in this diagram:

...that would be the pads where the switches are connected.
The current limiting resistor depends on the specifications of the LED.  Check the voltage and current required to light the LED.  Subtract the voltage needed from your supply voltage.  Then use the V=IR equation and solve for R.  That is, V = the voltage difference between your supply and what is needed by the LED and I is the current (probably in milliamps, so watch your math!) that the LED needs to light up properly.  You will probably need small current limiting resistors somewhere around between 100 and 800 ohms.
Added later...
Thanks to @Gerben we have a diagram of what I was describing:

In Gerben's diagram he has used the regulated 3 volt output of the Arduino LilyPad Mp3.  We can double check all the pin labels using a diagram from Sparkfun:

You should be able to repeat this circuit for each switch.  Sparkfun has an LED tutorial here.  But I'm not very happy with their guess approach when picking out a current limiting resistor.  Ah, this tutorial is much more to the point.
So, if we assume the LEDs you are using need 3mA @ 3V (remember to use values for YOUR LEDs!) and use this equation (Vs = supply voltage and Vf = LED voltage):

...then we set it up like (3 - 3) / (0.03) which is zero.  That's because I was using LEDs that work at 3 volts.  But if I used LEDs that worked at 3mA at 1.8V then I need... (3 - 1.8) / (0.03) = 40 ohm resistors.  Or there about. As most resistor values are on a log scale I suspect there should be a 47 ohm available.

You mean like this, right?


text:
How to use web data from GSM Sim900 to be used as input for Arduino?
I have a GSM Sim900 connected to an Arduino Uno. I'm successfully able to use HTTP READ commands to show data from the web on the Arduino's serial monitor. It is showing complete HTML from that URL on the serial monitor.
Now, how should I filter data from the web? I mean I just want to display selected numbers in the serial monitor and not the complete HTML.
And secondly, how should I store these numbers into a variable so I could use them as input data for Arduino?
Thank you.

You need to learn how to parse strings with the C string library, specifically strstr(), strtok() and strchr(), as well as how to manipulate strings with pointer arithmetic.

You should read the manual.
More specifically the "Sim900 AT reference".
I've found it on a russian server (https://www.google.nl/url?sa=t&source=web&rct=j&url=http://wiki.amperka.ru/_media/%25D0%25BF%25D1%2580%25D0%25BE%25D0%25B4%25D1%2583%25D0%25BA%25D1%2582%25D1%258B:gprs_shield:gprs-shield_sim900_at_commands.pdf&ved=0ahUKEwinze2Tp7fQAhWBMSYKHQFkBh0QFghEMA0&usg=AFQjCNGKd5Uohe7CmcJcIc1Am-SKdRsWXg&sig2=XIsvvkLWHs60sTo7FZ7tWw) but you may want to try and get it directly from the manufacturer.
In the datasheet, it will explained what values are allowed with the "at+httpread" command. You can actually specify which part you want to read. This is usefull when your Arduino can't parse the complete page.
If you have control over the page, you may also generate a device-friendly page consisting of key-value pairs, instead of it being a whole HTML page.

Mind that my answer only applies when the page is too big to put in a buffer at once.

What about RapidXml? RapidXML is a very fast and small XML DOM parser written in C++. It is aimed primarily at embedded environments so might work here. Boost software license means source is freely available. http://rapidxml.sourceforge.net.
The other way to go is just parsing out the numbers with string manipulation.


text:
Arduino nano to esp8266 level shifting needed?
I want to connect an Esp8266 Wifi module to an Arduino nano. I am wondering if I need to implement level-shifting for the Arduino TX line to Esp RX line?
I find different schema's on the net. Some with, some without level-shifting:
With:
http://community.blynk.cc/t/robot-with-esp8266-shield-and-arduino-nano/3316/8
Without:
Arduino Nano v3.0 with ESP8266
Some use a capacitor between GND and Esp CH_PD pin, others use a 10K resister between the 3.3V and the CH_PD pin (https://blogs.msdn.microsoft.com/abhinaba/2016/01/23/esp8266-wifi-with-arduino-uno-and-nano/)...
What is the most basic but required setup for a Arduino Nano and a Esp8266?
(I have Esp8266-12e modules)
Thanks!

You might also consider if one of the implementations of the ESP8266 with more I/Os could host your software under the available Arduino port, removing the need for the nano entirely.

@ChrisStratton do you have a link to such ESP8266 module?

There are many available, probably including whatever one your are running now, unless it is especially short on memory.  This is basically a software solution, not a hardware one.

The arduino nano v3's logic is 5v, and the ESP8266's logic is 3.3V, so you need to do level shifting between both.
Using a voltage divider drains more current (guess not an issue in this case) and it's ok only when going from 5V to 3.3V (when the signal must be shifted from 3.3V to 5V in the links you provide, it looks like it's based on that 3.3V is still considered "HIGH" on a TTL signal).
I personally prefer using a level shifter, it just complicates a bit the Bill Of Materials, but you won't have to debug the level shifting part.
And better than that, using an arduino mini pro @3.3v working directly at 3.3V gets rid of this hassle.

Shouldn't arduino nano 3.3v be arduino nano v3?

arduino nano v3 refers to the version of the architecture. afaik there's no arduino nano working at 3.3v. it must be an arduino mini

You could use a simple diode, between the Arduino TX and ESP RX. That's what the Adafruit Huzzah uses.
It takes advantage of the internal pull-up on the RX pin of the ESP. The diode will allow a LOW, to pull the signal low, through the diode. But it will block a HIGH 5 Volt signal from going into the ESP.

Yes, but for signals going in the other direction you have to also do something similarly, or hope that the pin the Arduino is receiving on never accidentally gets configured as an output instead and driven high.

Well, that goes for a lot of thing. The same could be said for the MISO pin on an SPI device connected to an Arduino. I've seen any protection on SPI lines, except maybe a resistor.

@ChrisStratton I dont get what you mean. One would assume that Arduino's RX pin is already configured as an input in firmware, when its used for serial comms. The risk here is no more than the usual when you connect the serial pins of 2 5V devices together.

It might boot up that way, but all it takes is mistakenly making that pin an output (perhaps while trying to make another pin one) to damage the ESP8266.  In the Arduino world, mistakes (especially purely software ones) should be considered normal, so it is unfortunate if one can cause damage.  And yes, it is even more a risk with SPI where the MISO pin is even more likely to be used for a different purpose in code that might be loaded with insufficient thought.  There's a difference between a cost-optimized solution, and an experimenter-friendly one.


text:
Running Arduino IDE in terminal?
Is there any way to use Arduino in the terminal? I have a USB 802.15.4 board that works with Arduino, but I don't want to use the IDE with it, I want to use the terminal.

I think you need to explain what you mean the Arduino IDE (Integrated Development Environment) is the graphic interface

1.) You can configure the arduino ide to use an "external editor". This means the arduino ide runs als usual but reloads the opened file for compiling and uploading. This is when you want to keep the original arduino ide.
2.) You can use the ino projekt which gives you a cli interface to manage your arduino projects. The quickstart guide gives a good overview of the project.
ino init -t blink
ino build
ino upload
ino serial

You can of course make all needed modifcations for differend boards and communication. I think the second option is what you are looking for ;)

The most popular method these days is to use arduino-builder.
This seems to be the official Arduino command line interface now, and can do most things the IDE can do short of actually editing your code for you.
It is a set of GO scripts, so you will need GO installed.