text:
Receiving serial data in acsii, how to split it.
Hello I want to know how to split an incoming serial message that comes in this format CxxxLxxx, x=number, so i can take the 3 numbers after the C and save them and then take the 3 numbers after the L and also save it, i have a code for this but it doesn't always work, can anyone tell me where I´m wrong or is the approach I´m taking is not the right one. Thanks.
int value = 0;
int channel;
int x;
String str;
int y;
String str1;
int le;

void loop()
{
if (Serial.read() == le)
{ }
  else
       {
        str = Serial.readStringUntil('C');
        str1 = Serial.readStringUntil('L');
        channel = Serial.parseInt();
        value = Serial.parseInt();
      DmxSimple.write(channel, value);
      le = Serial.read();
      Serial.println();

       }
}

This:
if (Serial.read() == le)
{ }

looks very suspicious - sometimes it can read the C or L and therefore render the rest of your code useless.
Also Serial.parseInt shall be avoided - it returns the first thing which looks like a number, and will not wait for all three numbers.
However, your problem is likely the DMX write speed. While the DmxSimple.write is getting executed, no new incoming message can be processed. Depending on your actual Arduino board and chip, there is some buffer, but the solution is not rocket-proof at all.
You can:

make a solid protocol between the PC and the Arduino, i.e. the PC sends one command, arduino sends it out over the DMX, and Arduino answers an OK to the PC. The PC will not send out any new command unless it has received an OK first.
avoid these ad-hoc mess, i.e. serial-reads and serial.printlns here-and there.

For example, if you change the protocol so: CxxxLxxxE (E stands for end) you can utilize readStringUntil to read the input until a separator, and then use the toInt method to actually convert the read data to integer:
void loop() {
    strDummy = Serial.readStringUntil('C');
    strC = Serial.readStringUntil('L'); // xxx from CxxxL
    strL = Serial.readStringUntil('E'); // xxx from LxxxE
    channel = strC.toInt();
    value = strL.toInt();
    DmxSimple.write(channel, value);
}

After learning that it is not possible to change the protocol, here is a new plan
int channel;
int value;
void loop() {
    if (Serial.read()=='C') { // wait for a C
        channel=Serial.parseInt(); // parse till first non-number
        value=Serial.parseInt(); // parse till first non-number
        DmxSimple.write(channel, value);
    }
}

See https://www.arduino.cc/en/Tutorial/ReadASCIIString for a tutorial. Note that Arduino Serial commands are pretty confusing sometimes :) for example, parseInt will actually consume one non-number character implicitly after parsing a number.
Also note that this solution works well if the command is sent as one batch. If you are trying to send the command manually, e.g. from a terminal window, character by character, parseInt may time out. Consider increasing the timeout to 10 seconds or more by https://www.arduino.cc/en/Serial/SetTimeout

Thanks for the quick answer, the problem is that I get data from a program called Freestyler DMX, with the help of a program called Serialmon i saw that the protocol that the program uses is CxxxLxxx, and that why a cant add en 'E' to the protocol, I tried using Serial.readStringUntil, but cant get it to work the right way.

Ok, then do this: read and discard anything until you get a C. Then read three characters and concatenate them to a string. Then read and discard anything until you get an L. Then read three characters and concatenate them to a string. The two strings now contains the two numbers.

Ok, I tried this but it has some problem, also i dont know how to post in code again in the comment section sorry...
C = Serial.read();
Serial.print(C);
String channel_str = String(C);
String value_str = String(C);
channel_str.remove(4);   // Remove from from index=4 leaving only Cxxx
channel_str.remove(0,1);   // Remove 1 character starting at index=0 leaving only xxx
value_str.remove(0,5);   // Remove 5 characters starting at index=0 leaving only xxx
int channel = channel_str.toInt();
int value = value_str.toInt();
DmxSimple.write(channel, value);

Unfortunately, code formatting does not work in comments. I am unsure what is the reason for printing out things what you read? and what is in C - that is one character only, it makes no sense to remove anything? Anyhow I have improved my answer with an example.

Thanks for the help, i just made some changes and its ready to connect to the software FreeStyler, just having some minor problems with the processing speed but I can deal with that, thanks a lot. Should I post the code or leave it like that?

I am happy it worked! Feel free to post your code, there is always something which can help someone in any code :)
Processing speed can be a burden, try to reduce how many DMX channels you have in use in FreeStyler. One channel is 8 byte in your protocol, that is 80 bits, which makes 4 ms at 19200 bps speed. On the DMX side things go at 250kbps, and one byte (10 bits) is needed for one channel, making a full refresh cycle 20ms. Doing that over your protocol and say, 19200bps will take a bit more than 2 seconds :) (1 byte is 8 data bits, plus a start bit plus a stop bit on the uart.)


text:
Arduino sketch taking forever to upload, followed by multiple issues
I am using Arduino Uno board with Windows 10. From the tutorials on Arduino website, I am trying to upload the following code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1);
}

It had undergone a series of issues:
First,
avrdude: ser_open(): can't open device "\\.\com3"
I searched for his issue, and found that most common solution id to go to device manager and change the name of the port, then unplug and plug again the arduino board. I did that
Second,
C:\Program Files (x86)\Arduino\hardware\tools\axr\bin\avr-ar:
unable to rename 'core.a'; reason: file exists\\

I thiught it could be a memory problem. I used the reset button on the board, and repeated steps from the solution to the first problem. I tried to upload the code again.
But now, I am not getting any error message. But the problem is that it is taking forever to upload the code. I see Uploading... status since a long while. The green progress bar is also complete, but no uploading completed till now.
Any help to understand and solve this will be appreciated.

When the Arduino IDE says its uploading but never uploads, it is most likely a COM port issue. Try plugging the Arduino in a different port and make sure you change the port in the IDE. The problem seems to be you have changed the Arduino port, but not in the IDE. The Arduino IDE registers the previous port as open and tries to upload the program to that port. Go to Tools > Serial Port and it should list the ports(example):
COM 2
COM 3
Arduino Uno at COM 4
•COM 4

Every time you unplug and replug the Arduino you should check your ports and select the appropriate one ( It usually says Arduino *type* at COM *port number*
COM 2
COM 3
•Arduino Uno at COM 4
COM 5

source: Stack Exchange

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

sort: votes


text:
How to use Arduino Pro Mini without Programmer
I'm a software engineer, but I'm not too skilled at understanding hardware design yet. I'm trying to learn how to use an Arduino Pro Mini board without the programmer connected, so I can actually make fun toys, etc. Currently, the software will only run when connected to the programmer (or at a minimum with the SCK pins connected to each other). I have been searching online for days, and I think I need a crystal or resonator hooked up somehow, but I can't figure out how to hook them up (which pins). I bought 5 16 MHz ceramic resonators, and I have them right here with me, but I can't find the answers online how to hook it up and have the board run stand alone. Any ideas? Thank you in advance.

You'll have to program it once, and then it should run whenever it's powered up. They should be able to run on internal 8Mhz clock.

You might be on the wrong track.
You do need a crystal (or not, it depends on), and an Atmel programmer if you want to program an empty chip.
However, all Arduino boards come with a chip pre-programmed with a bootloader.
Then it is rather easy: you need an FTDI cable to connect the board to a PC. Then run Arduino IDE on the PC. (The FTDI cable is actually an USB-to-serial converter.)
The Arduino IDE lets you edit a C like code, complile it to binary, and send it out via the FTDI cable to the serial port (Rx, Tx) of the board. The microcontroller on the board comes with a bootloader. Bootloader is a small program which runs at power up, and will receive the data from the computer and put your program to the microcontroller. Then your program will run on the microcontroller.
So, you don't need an external programmer.

On the other hand, you may consider picking a different Arduino board. Arduino Micro, or Pololu A-star Micro (for half of the price of the Arduino Micro) offers a board with a direct USB connection. All you need is one USB cable.
These boards come with a much better microcontroller (32u4) which has a hardware USB connection (allowing you to make a mouse or a keyboard, and control PC (such as buttonbass.com) from your gadget).

You were right. I was completely on the wrong track. My problem was that the target board wasn't being programmed at all. I started over from the beginning, loaded up Atmel Studio and burned a new bootloader. Eventually I was able to go back to Arduino IDE and program the board. I have now moved beyond this roadblock and on to bigger pastures. Thank you very much. Peace.

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


text:
Sampling frequency
I am an undergraduate student at a public university in Maryland. I am currently doing a project with an arduino and I came across a problem that I could not figure out after several days of researching. Regarding my project, I am trying to collect 6 data (acceleration and gyration in x,y,z) from an accelerometer/gyroscope sensor at a desired constant rate (trying to make it 1000 Hz, so about 1000 sets of the 6 data per second) into a SD card. However, I could not make the arduino do this; I am able to collect the data, but not at a constant sampling frequency of 1000 Hz. Could someone help me set the sampling frequency at 1000 Hz please. Here are some of the information of the sensors and arduino I am using:

Arduino nano
MPU-6050 gy-521 accelerometer/gyroscope - http://playground.arduino.cc/Main/MPU-6050
SD card reader - http://www.aliexpress.com/item/SD-Card-Reader-Module-for-Arduino-ARM-Read-and-Write-Free-shipping/526750081.html?spm=2114.12010108.1000023.4.JkncUu&spm=2114.12010108.1000023.4.JkncUu

Also, I have posted my code. Thank you in advance for the help.
My code:
#include <Wire.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>
unsigned long time;
#include "I2Cdev.h"
#include "MPU6050.h"
MPU6050 accelgyro;
#define OUTPUT_READABLE_ACCELGYRO

const int sdcard = 7;
int num;
int16_t ax,ay,az,gx,gy,gz;
LiquidCrystal lcd(10, 9, 5, 4, 3, 2); //12 is 10 and 11 is 9

void setup()
{
    Serial.begin(115200);
    lcd.begin(16, 2);
    pinMode(8, INPUT_PULLUP);
    Serial.print("Initializing SD card...");
    if (!SD.begin(sdcard))
    {
        Serial.println("initialization failed!");
        return;
    }
    Serial.println("initialization done.");
    accelgyro.initialize();
}

void loop()
{
    lcd.setCursor(0,0);
    lcd.print("Push button");
    lcd.setCursor(0,1);
    lcd.print("to start");
    int sensorVal = digitalRead(8);
    if (sensorVal == 0)
    {
        delay(500);
        num = 1;
        collect();
    }
}

void collect()
{
    File myFile = SD.open("test.txt",FILE_WRITE);
    myFile.println("Begin:");
    myFile.print("x-axis  ");
    myFile.print("y-axis  ");
    myFile.print("z-axis ");
    myFile.print("\n");

    Serial.println("Begin:");
    Serial.print("x-axis: ");
    Serial.print("\t");
    Serial.print("y-axis: ");
    Serial.print("\t");
    Serial.print("z-axis: ");
    Serial.print("\n");

    if(myFile)
    {
        while (num == 1)
        {
            accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
            lcd.setCursor(0,0);
            lcd.print((double) ax/16384*9.81);
            lcd.setCursor(7,0);
            lcd.print((double) ay/16384*9.81);
            lcd.setCursor(0,1);
            lcd.print((double) az/16384*9.81);
            lcd.setCursor(7,1);
            lcd.print(time);

            time = millis();

            Serial.print("Time: ");
            Serial.println(time);
            Serial.print(ax);
            Serial.print("\t");
            Serial.print((double) ax/16384*9.81);
            Serial.print("\t");
            Serial.print(ay);
            Serial.print("\t");
            Serial.print((double) ay/16384*9.81);
            Serial.print("\t");
            Serial.print(az);
            Serial.print("\t");
            Serial.print((double) az/16384*9.81);
            Serial.print("\n");

            myFile.print("Time: ");
            myFile.println(time);
            myFile.print(ax);
            myFile.print("\t");
            myFile.print(ay);
            myFile.print("\t");
            myFile.println(az);

            int sensorVal = digitalRead(8);
            if(sensorVal == 0)
            {
                delay(500);
                num = 0;
                Serial.println("STOPPED");
                myFile.println("STOPPED");
                Serial.print("\n");
                myFile.print("\n");
                myFile.close();
                lcd.clear();
                lcd.setCursor(0,0);
                lcd.print("Stopped");
                delay(2000);
            }
        }
    }
}

What is connected to D8? If you want to collect data at 1kHz, why are you delaying for 500ms each loop? Have you heard of interrupts?

If you want people to analyse your code try formatting it properly and including some comments. This is good for your own future analysis as well.

Sounds ambitious! Have you measured how long does it take to do the measurement, update the lcd, and write out all data to an SD card?

uint128_t : I am only delaying at the very beginning and at the very end when the button is clicked to stop the while loop that reads the data from the sensor.

milliways: sorry, I will make sure I do that next time

Gee Bee : even if i just measure them, wouldn't they just do it at their default frequencies? i should have been more specific with my question before, is there a way to change the default frequency to make it whatever you desire? is the only way to do this with a delay?

You will not remotely be able to achieve 1000 Hz operation of a loop which performs so many time consuming operations.  Even leaving out the possibility of substantial delay on some attempts to write to the SD card, your serial output alone could never keep up.  A 115200 baud serial implementation can only transmit on the order of 11 thousand characters per second, which means there is only time for 11 or so per your hoped interval, and you produce far more than that.  (And buffering is irrelevant if you are continually producing data faster than you can transmit it)
If you want to achieve a high sampling rate, you are going to have to pare the code down to the bare minimum required functionality and analytically or experimentally determine how much time each portion takes.
If you want regular samples, you are also going to have to study the rate at which the sensor produces them - you may actually want to consider letting the sensor be the timing master, and simply record the samples as they become available.
And you will need to study the SD card writing process and determine its possible worst-case delay.  To overcome that, you may find that you have to collect your samples in an interrupt and use most of your available RAM to buffer them across the worst-case card delays.  If the data you need to store is only a few megabytes, you might consider an SPI flash for its more deterministic timing behavior.


text:
Arduino GSM receiving text and then storing value as a variable in code
I am using an Arduino Mega board with a SIM900 GSM.
My goal is to be able to text the GSM with a value of two digits (ex: 79) and then store that value as a variable in the code. I know how to set up the Mega and the GSM in terms of wiring and initialization of ports, but how would I write a short function to test the incoming values and save them to a variable?
I thought about testing each bit individually, storing each one as a separate variable, and then adding them for the total. For example, if the GSM received "#79" as a text I stored the value 7 as an integer variable named One and the value 9 as an integer variable named Two. Then I did
Total = (One*10)+Two.

I am posting my code below that used this method, although it has not proved to be useful. If anyone has any suggestions I would greatly appreciate it.
#include <SoftwareSerial.h>   //GSM Library

int Max_temp;
float threshold;

SoftwareSerial SIM900(18, 19);
String destinationNumber = "+17186578989";
String outMessage1 = "Please enter the maximum desired room temp";
char inchar; // Will hold the incoming character from the GSM shield when user texts it
int M_one;
int M_zero;
void GSM_SEND_MAX();
void GSM_RECEIVE_MAX();

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

//GSM setup:
  Serial1.begin(19200);  // wake up the GSM shield
  delay(20000); // give time to log on to network.
  Serial1.print("AT+CMGF=1\r"); // set SMS mode to text
  delay(100);
  Serial1.print("AT+CNMI=2,2,0,0,0\r"); // blurt out contents of new SMS upon receipt to the GSM shield's serial out
  delay(100);
}// end void set up()

void loop()
{
  GSM_SEND_MAX();
  GSM_RECEIVE_MAX();
}// end void loop ()

/////Functions
void GSM_SEND_MAX()
{
  Serial.println("sending text");
  Serial1.begin(19200);
  delay(20000); // give time to log on to network.
  Serial1.print("AT+CMGF=1\r");
  delay(1000);
  Serial1.println("AT + CMGS = \"" + destinationNumber +"\"");
  delay(1000);
  Serial1.print(outMessage1);
  delay(1000);
  Serial1.write((char)26); //ctrl+z
  delay(1000);
  Serial.println("send text");
}//end GSM_SEND_MAX funtion

void GSM_RECEIVE_MAX()
{
  //If a character comes in from the cellular module...
 while (Serial1.peek() != '#' )
   {
    inchar=Serial1.read();
    Serial.print("bad char ");
    Serial.println(inchar);
    delay(500);
   }// end while #1

 inchar=Serial1.peek();
 Serial.println("out of loop 1");
 Serial.println(inchar);

 while (Serial1.available() != 0) //While #2 reads incoming char
 {
    Serial.println("in loop 2");
    inchar=Serial1.read();

if (inchar=='#')
  {
  delay(10);
  Serial.print("got #");
  M_one=Serial1.read();

  if (M_one >= 0 )
  {
  delay(10);
  Serial.println();
  Serial.print("got M_one");
  Serial.print(M_one);
  M_zero=Serial1.read();

      if (M_zero >= 0)
      {
          Serial.println();
          Serial.print("got M_zero");
          Serial.print(M_zero);

       }//end m_zero

  }//end m_one
  Max_temp = (M_one *10) + M_zero;

  Serial.println();
  Serial.print("Max_temp=");
  Serial.print(Max_temp);

  } //end if (inchar==#)

 }// end while #2 loop
}//end GSM_RECEIVE_MAX function

There is a code formatting button in the post editor. Highlight your code and click the {} button.

The code uses a char as int without conversion. See https://electronics.stackexchange.com/questions/38845/arduino-serial-read-to-int for details on how to convert.


text:
Arduino motor rotation
I am a beginner in Arduino. Below is my code to propel the fans of my motor. This happens in a clockwise direction but I wish to change the direction of rotation.
How can I modify it?
// Declare the pin for the motor
int motorPin = 9;

void setup() {
  // Define pin #9 as output
  pinMode(motorPin, OUTPUT);
}

void loop() {
  // Turn motor on
  digitalWrite(motorPin, HIGH);
  // Wait 250 ms
  delay(250);
  // Reanimate motor
  digitalWrite(motorPin, HIGH);
  // Wait 250 ms
  delay(250);
  // Turn motor off.
}

can you please tell something about your motor i.e. datasheet, name of some schematics?

Rewrite your code. Your code doesn't even turn off your motor. Then tell us, which shield you are using for motor control and give us information about your wiring. Without further information nobody will be able to answer your question.

Swap the wires over?

I guess you have a DC motor in use. Likely a FET drives it on port 9.
This arrangement is enough to start or stop the motor, however to change direction, you need to swap the two wires on the motor.
I guess you may perfer to do this in software - and for that you need to replace the simple FET driver with a H-Bridge. H-Bridge is an arrangement of electric switches which allows you swapping motor polarity, and it usually comes pre-assembled to a chip.
There are a vast amount of h-bridge motor driver chips to choose from. Google for "pololu motor driver", or "adafruit motor driver".
You can find all the further details in the Arduino examples on the web, e.g.:
https://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/overview


text:
exchanging data between two hc05 bluetooth modules
Iam working with gyroscope and Iam trying to send its values from one bluetooth(HC-05) module to another bluetooth module but the data exchange is not happening and I have used 2 arduino boards to do it.
Is there a simple way to do it?

You will get your required details here.

I think there is no simple answer for that. First you have to pair 2 HC-05 modules. To do so, you have to configure one HC-05 as slave, and other HC-05 as master.
Steps for SLAVE:

Be sure to select correct Baudrate in your Terminal Emulator (Arduino IDE or Terraterm etc.) for your module. There is no default baudrate... Different manufacturers set the baudrate on their HC-05's differently... 9600 and 38400 are good starting points.
Enter AT mode, by providing high level(3.3V or 5V) signal on KEY pin(PIO11)
Note the values of AT+PSWD?, AT+NAME? and AT+ADDR?(let's say 1111:22:123456) commands. You might set the password to 1234 for easy remembering. Issue AT+PSWD=0000...
Be sure to set the module to slave mode by issuing AT+ROLE=0 command.

Steps for MASTER:

Be sure to select correct Baudrate in your Terminal Emulator (Arduino IDE or Terraterm etc.) for your module. There is no default baudrate... Different manufacturers set the baudrate on their HC-05's differently... 9600 and 38400 are good starting points.
Enter AT mode, by providing high level(3.3V or 5V) signal on KEY pin(PIO11)
Reset the module to its original state by issuing AT+ORGL command.
Remove the previous parings(if any) by issuing AT+RMAAD command.
Set same password as slave by issuing AT+PASSWD=0000 command.
Change the role to master; AT+ROLE=1
Set connecting mode to any address it sees; AT+CMODE=1
Initialize the SPP profile lib ; AT+INIT
Be sure that you see the slave HC-05 module, AT+INQ command will list the modules you see.
Be sure that you see address of the slave module(1111:22:123456).
Last of all enter AT+LINK=1111,22,123456(note the commas).

With these steps you should exchange data...

Sure @szahin will try to do it


text:
How do I display serial monitor on LCD keypad shield?
I want to be able to display what I am seeing on the serial monitor onto the LCD keypad shield I have connected to my Arduino UNO. Can someone possibly write the the code ontop of this for me?
I'm very new to coding so I apologies if it's hard for anyone to understand what i'm asking for.
int ledPin = 13; // LED is attached to digital pin 13
int x = 0; // variable to be updated by the interrupt

//variables to keep track of the timing of recent interrupts
unsigned long button_time = 0;
unsigned long last_button_time = 0;

void setup() {
  //enable interrupt 0 which uses pin 2
  //jump to the increment function on falling edge
  attachInterrupt(0, increment, FALLING);
  Serial.begin(9600);  //turn on serial communication
}

void loop() {
  digitalWrite(ledPin, LOW);
  delay(500); //pretend to be doing something useful
  Serial.println(x, DEC); //print x to serial monitor
}

// Interrupt service routine for interrupt 0
void increment() {
  button_time = millis();
  //check to see if increment() was called in the last 250 milliseconds
  if (button_time - last_button_time > 250)
  {
    x++;
    digitalWrite(ledPin, HIGH);
    last_button_time = button_time;
  }
}

I think it's much better if you figure this yourself, since it is a very basic question. You should just substitute (or add to) the Serial.println function with a writing to the LCD. You can use the LiquidCrystal library (click to go on the arduino reference page to see the functions and the examples). If you have problems following the examples, post a more specific question and we'll try to help..

I have attempted it but have failed :(

It keeps giving me the number 3 on the lcd

Never  mind I have done it!!! Thank you so much for the help and links :)

And now you learnt something new ;) good work, anyway :)


text:
GPRS/GSM SIM900 Shield not working with Arduino
I have a few questions related to GPRS/GSM SIM900 Shield not working with Arduino.
To keep it short I have a list of concrete questions:

Is the Arduino GSM library compatible with the Geeetech GPRS/GSM SIM900 Shield?
On the board the green LED blinks every 3 seconds which I have read
means that it is connected. However, when I try to use any of the
GSM examples, in regard to internet, I either get error messages or
simply no progress in the program. For instance, in the testGPRS
sketch it sits stuck at the port where it says "Connecting GSM
network...". And in the bandManagement example sketch it can't find
the current band,as well as the modem not responding, well basically nothing works, except that the
shield itself indicates it is connected to a network.

The SIM card I'm using is data exclusively and can't be used for voice calls or SMS. It has no pin code and works as my secondary SIM card (it shares the same subscription as my primary card).
Edit:
I have now tested the SMS capabillities of the board with another simcard, that works with no problems, seems only the internet won't work.

which arduino board are you are using? How are you are powering this board?

Im using arduino UNO, i power it through USB on my laptop.

I have also acquired a 9 Volt battery to test if extra power will help when I have tried it I will respond with the result.

These modules consume a lot of current (2A at least) when using GPRS. A 9V battery is no good as it cant supply this current. Look for an 18650 battery or 3.7 V LiPo cell that can supply 2A easily or a wall adapter coupled with a buck converter. Voltage should be at least 4 V but no more than 4.7V.

Ok so i tried the 18650 batteries and it is still not working.


text:
Convert uint8_t array to ascii character for serial transmission
I am trying to send packets of via bluetooth data that include 6 bytes read from a sensor and stored in a uint8_t array. Instead of sending over the data as numerical digital, I would like to send the ASCII character of each of the bytes. I am doing this to reduce the size of my data packets and make it easier to interpret the incoming data.
uint8_t* temp = readBufferData(FIFO);

for (int i = 0; i < 6; i++)
{
    Serial.write(temp[i]);

}

Read buffer data returns a pointer to a uint8_t array read from a FIFO buffer.
When I use Serial.print, I get the following output, which makes sense.
22163226094255
One question is, when I use Serial.print on a single character, is it transmitted a single byte, or is it actually sending the decimal digital of the number, anywhere from 1-3 bytes?
When I use the Serial.write, however, I get something like the following
DÿÂ?ÁÏ?ÌÆ?Ûµ?Ë½?ÔÀ?Ð¿?ÃÕÓÑËÐTÿÀ?Ï3ÿÉ?¹4ÿÐ?Ê<ÿ½?µfÿ¼?ìNÿÐ?×Â?ÊÚ?×¿?Å
Also, these data display much more slowly on the screen, than normal.
How can I send each uint8_t value by sending over the corresponding ASCII character for serial transmission?
Thanks!

try with this in the loop: Serial.print("Hex: 0x"); Serial.print(temp[i],HEX); Serial.print(" - Char: "); Serial.write(temp[i]); Serial.println(""); and then post some of the lines you get

You could look at base64 encoding the data if you want to go hardcore, there are libraries out there.  If you just want something you can read then the best solution is to convert each uint8_t to two hex numbers and send them, it will double the amount of data you transmit but I don't know if that's important to you.

Why do you want to send your data as ASCII? Binary writes are much faster and of a vastly smaller size.

Possible duplicate of What is the difference between Serial.write and Serial.print? And when are they used?

You don't "convert" anything. A character is just a human representation of an 8-bit value.
Instead you just need to change what the compiler thinks the data represents (from a human perspective).  The simplest way of doing that is to either cast the uint8_t values to be char values, or to write each one individually as a raw value.
The latter way:
myBluetoothSerial.write(myData[0]);
myBluetoothSerial.write(myData[1]);
myBluetoothSerial.write(myData[2]);
myBluetoothSerial.write(myData[3]);
myBluetoothSerial.write(myData[4]);
myBluetoothSerial.write(myData[5]);

Or, with a loop:
for (int i = 0; i < 6; i++) {
    myBluetoothSerial.write(myData[i]);
}

or using a built-in variant of write that does the loop for you:
myBluetoothSerial.write(myData, 6);

Thanks for the comment. I just tried this and got the following characters out on my serial monitor. These characters should represent 6 bytes worth of data. ÆúÂÊàDÿÜ?²Nÿª?È{ÿ¹?×CÿŒ?ä`ÿà?Ïkÿð?ÿ

Are you sending the 6 bytes repeatedly over and over again?

Yes, but in between each transmission I have some other text printing to the serial monitor. E.G. a Count for ISR operations and Number of samples Below is a larger sample of the output
@¾@ÀÂ?Ç¯?¹ßßÂÄÑQÿ¿?Ë5ÿ¸?ÒGÿÐ?ÆYÿÉ?±CÿÊ?»#ÿÐ?ÔÊ?ßÑ?Øã?ÙÖ?ÜÜ?¸Û?OÿÍ?ISR Count: 84
Number of Samples: 1
ÙÎÜÍÂMÿê?¾GÿÔ?Òvÿ¤?ÍPÿÔ?æAÿÜ?áMÿÌ?:ÿISR Count: 117
Number of Samples: 1
Û?Ñ¯?ÄÄ?¹×?ÆÔ?ÑÁÄÍÇÁ¾aÿ·?ÝMÿÁ?ÔAÿË?àRÿÌ?ã0ÿÆ?ËÁ?ÃÄ?ÒÄ?ÇÄ?¸Å?ÅÅ?ÂÀÔÕÁÐAÿÂ?ÊGÿÐ?ÇEÿÛ?Ì8ÿÄ?Ç?ÿÌ?ÈUÿÕ?ÁÉ?ÐÄ?ÒÔ?ºÇ?ËÓ?ÝÌ?MÿË?ISR Count: 234
Number of Samples: 1
ÎÓæë†úþì? Cÿú?³<ÿÓ?¥'ÿÑ?Ø:ÿÚ?Ö,ÿÓ?EÿISR Count: 267
Number of Samples: 1

It is most likely correct. You won't be able to understand the data since it's no longer as numbers but ASCII characters. Without seeing your code I can't know what to expect from the output.

I added some code and details to my question above. The readBufferData function works as expected by returning a pointer to a uint8_t array. It's just the Serial output that is behaving strange. I used the software Serial output for testing purposes, but I wouldn't think that matters.

As I said, you won't be able to understand the output. It may be that the serial terminal is trying to interpret the seemlingly random data as UTF-8 and giving you all sorts of gibberish. Instead you are going to need to write the corresponding receiving software to interpret it and see if it is correct or not.

Let us continue this discussion in chat.

Try changing Baud Rate. Most of the time garbage like this happens because of difference in baud rates of transmitter serial device and receiver serial device.

Both are set to 9600, I only get this when I use Serial.write instead of Serial.print.

oh, these two are different. Have a look at this question to understand HOW.


text:
Burning servos like crazy, what am I doing wrong?
For some reason my servos keep burning out.
My code is simple, if condition, rotate to 0 degrees, else rotate to 180.
However, what that does to the motor is keep it in a constant struggle to stay in rotation 0 or 180, when there is no movement in between. Sure enough, leave it running for 1 hour, the motor burns out.
if (!strcmp("1",output)){
    myservo.write(0);
}
else {
    myservo.write(180);
}

Is there something like myservo.release or something? I presuming i need to get the servo in to position, then release it so it doesnt try to stay in position.
Please help, i've burned through 4-5 of them so far, it's not fun :(

Servo's are meant to keep their position; if you could "release" the torque you won't have a "fixed" position, since when shut down the motor does not generate the torque to keep it still. You can try to reduce the speed of the servo, but if the problem arises when you leave it still then probably you just have to consider changing servo brand..

Are you sure these servos can run all the way to 0 and 180 degrees? (If they are running against their end stops it might cause problems.) Also what voltage are they rated for, and what power are you using?

What are your servos doing, or trying to do? If they are not driving anything they should hold position with very little current. If they are holding against a load, they take current to maintain position; more load = more current. Seeking an unachievable position (beyond their, or the mechanical system's stops) is a worst-case.

First steps: Burned motors are most often the result of two things, incorrect wiring or using the wrong voltage input to the motor for power. Make sure your voltage source matches the specs on the servos and that your wiring is correct.

Some servos are actually not able to do full 0..180 rotation - or to rephrase it better, the standard 0.5ms and 1.5ms pulse will force them to a position which can not be reached. Therefore the motor keeps on rotating in a constant struggle.

change 0 to something like 20, and 180 to something like 150
check that the motor has stopped once reaching 20 or 150. I.e. it does not produce any sound, and if you touch the motor body it is not producing any vibration (so no constant stuggle)

Most servo has a range of 90deg, so the safe range is from 45 to 135 (which correspond to a pulse from 1000 to 2000ms)

Actually, I found it is not etched into stone. I have a couple of micro servos, which accept pulses of 0..180 degrees (0.5/1,5ms), still make a rotation of only 90 degrees because of difference in gears. I would say that we control the pulse width - and the servo react in some way :) I agree that it is a little oversimplification expecting that myservo.write(35) will move to 35.000 degrees.

Yes there are exception, but most use the "standard" pulse, because that is what come out from most radiocontroller

I can fully agree, @lesto! However standards are obeyed pretty liberally by many Chinese manufacturers as I have found, especially with TowerPro servos. (They are great price to value ratio, but do have the same problems what the OP mentioned.)

Ensure your voltage source matches the motors specs and that your wiring to the arduino or driver shield is correct and try the code I've posted which has worked for me to test servos.
#include <Servo.h>  // servo library
// You can control a maximum of twelve servos on the Uno
// using this library. (Other servo libraries may let you
// control more). Note that this library disables PWM on
// pins 9 and 10!

Servo servo1;  // servo control object

void setup()
{
  //  Attach the servo1 object to digital pin 4.
  servo1.attach(4);
}

void loop()
{
  int position;
  // Change position at full speed:

  servo1.write(90);    // Tell servo to go to 90 degrees
  delay(1000);         // Pause to get it time to move
  servo1.write(180);   // Tell servo to go to 180 degrees
  delay(1000);         // Pause to get it time to move
  servo1.write(0);     // Tell servo to go to 0 degrees
  delay(1000);         // Pause to get it time to move

  // Change position at a slower speed:
  // Tell servo to go to 180 degrees, stepping by two degrees

  for(position = 0; position < 180; position += 2)
  {
    servo1.write(position);  // Move to next position
    delay(20);               // Short pause to allow it to move
  }

  // Tell servo to go to 0 degrees, stepping by one degree

  for(position = 180; position >= 0; position -= 1)
  {
    servo1.write(position);  // Move to next position
    delay(20);               // Short pause to allow it to move
  }
}

I wanted to answer my own question:
I had purchased some really cheap servos from AliExpress. These are not good. They burn out really fast, which has been confirmed by some friends of mine that had purchased the same servos.
The voltage was correct, it was 5V. When using more quality servos that cost $15 I did not see any of these issues.
Do your self a favor. Do not get servos from AliExpress. Get them from DFRobot or some other more reputable website.

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


text:
Using IR Sensor to sense movement?
I was wondering if I could use a IR sensor with my Arduino to detect if someone is present in front of it.
Like, the emitter should emit continuously and if the receiver drop connection it should do something.
Will this work fine? or the emitter wide angle and a human body in front of it wont drop the signal?

This will work fine. The easiest way to do this is using IR Sensor Module.

This will give you a digital output of whether there is someone in front of sensor or not. Use can use it as an Edge Trigger to detect Humans passing by.
You can buy one. They are both cheap and easily available.
Or you can create your own.

This works quite fine !
The "hardest" part is isolating the IR beam and especially the receiver with anti-reflective paint or paper (ie : a small hole in a cardboard)
You can make this by two (at least) ways :

[IRled]         [human]          [IRreceiver]
[IRled and receiver pointing the same way]       [human]        [mirror]

The second way is what you find in auto-flushing toilet rooms. But if the human is wearing quite reflective clothes, this will fool the receiver.
This is great for long-range detection, but if you need a smaller range, go for the 1/.


text:
ESP8266 sending GET Request and getting 408 Timeout error
I am using esp8266 to send a GET Request but I am getting 408 Timeout error.
Here is a screenshot of my output.

I only count 60 characters, but you tell it your going to send 69.

@Gerben:  I am getting error when I trying to use "AT+CIPSEND=60"

Are you sending actual "carriage return" and "new line" characters or just a \r\n string? Show us your code.

I assume you're doing all this from the serial monitor. You can't use escape sequences like \r in the serial monitor entry box. Everything you enter is evaluated as a string of separate ASCII characters; \r is just a backslash character followed by lowercase r. To send a HTTP request, you make the serial monitor send the \r\n for you.

First set the serial monitor to BOTH NL & CR permanently; it will serve you well for commands and HTTP requests as it appends \r\n to everything you send.
Count the number of bytes in the your HTTP request, including the carriage return and newline characters. I count 61 characters in your request.
Use this count in AT+CIPSEND
Type the first line of your request, and stop right before the first \r\n, and click Send. Because of your setting, the monitor will now send what you typed with \r\n suffixed to it.
Type and send each line of the request, just like you sent the first line, until you've sent the last line.
Since there is an additional \r\n after the last line, you click Send again, without typing anything. And since the module requires \r to indicate the end of the data packet, you click Send one last time.

Hopefully, this should give you the right results.


text:
Send a file from PC to Arduino using HC-06 module
I want to send a file from my Laptop using its own Bluetooth transmitter to Arduino. Arduino has HC-06 module as receiver.Arduino has SD Card fore store the file.
I was able to send bytes using Python application.
How to send a file using a Python application to Arduino?

What kind of file?

Open the file in rb mode in your Python code.
Since the Arduino SoftSerial RX buffer is 64 bytes in size, sending 60 bytes per packet to the Arduino is okay. You basically call out = file.read(60) in python to read 60 bytes from the file and then write these bytes to the Arduino with ser.write(out). You can have the python program wait for acknowledgement from the Arduino, perhaps indicating how many bytes it actually received (after a given timeout period) or what byte was last received. This is just very minor error detection.
The Arduino saves the 60-byte packet to an array and writes everything at once to a file on the SD card, that you've already opened.
After receiving acknowledgement from the Arduino, the Python program reads the next 60 bytes and forwards to the Arduino like before. Continue till the file is exhausted. You could send some sort of signature byte to inform the Arduino that no more bytes are coming and to close the file. Alternatively, a timeout period can be used.

Note: It'll be more efficient if you wrote to the SD card in chunks, where the chunk size is a factor of the card's sector size. 64 bytes is the highest you can do with the default RX buffer size, but thats living dangerously as you risk buffer overflow if anything goes bump.
This can be avoided though, by reading bytes from the RX buffer and into your own array, as soon as they arrive.
Chunks of 32 bytes is safer but it will naturally take longer to send the whole file. Test and judge for yourself.

Draining the buffer shouldn't be a challenge if the Arduino is ready, and it may be more useful to operate in chunks that divide evenly into a sector on the card.

@ChrisStratton like 64 bytes, you mean? I just used 60 for some redundancy. Its easier to test this way and if it all works, optimize it. I'll edit though.

I'd personally be trying to avoid the situation where the serial buffer is holding much at all, by making sure the program is able to drain data promptly.

@ChrisStratton Just realized I strayed off...I get your point.


text:
Having a problem to control digital servo with HC-06 bluetooth module
There are two problems to control digital servo(HD-1810MG) and HC-06 bluetooth module connection.

When I put a specific number to servo(in the video, I put 45), it shakes too much and shows useless movements before get to the right angle. I have no clue why this happens. Should I add more code to control it correctly?

This is my code.
#include SoftwareSerial.h
#include Servo.h

Servo myServo;
int TxD = 10;
int RxD = 11;
SoftwareSerial bluetooth(TxD, RxD);

void setup() {
  myServo.attach(9);
  Serial.begin(9600);       // start serial communication at 9600bps
  bluetooth.begin(9600);
}

void loop() {
  if (bluetooth.available()>0)
  {
    int servopos = bluetooth.read();
    Serial.println(servopos);
    myServo.write(servopos);
    delay(100);
  }
}

I used Nexus 5X and apk app to pair with HC-06. It pairs well at the first time of connection, but it loose connection after servo moved once. Application said it is connected with bluetooth, but HC-06's LED is blinking(which means disconnected). How can I maintain connection with HC-06?

This is my board.

And I made apk app using MIT App Inventor 2.
I'm so new to arduino and I'm not in major of engineering. Please give me an advice!

The Servo you are using, its a standard servo or continuous servo?

Definitely not enough power for the servo. Insufficient power causes the BT module to reset, and can also be a good reason for unexpected servo movements. Power the servo from a separate set of batteries (keep the GND of the battery connected to the GND of Arduino).

@ARK: I think it might be a standard servo. There is no item description about continuous property.

@Gee Bee: Yes, the power source was coming from USB on PC, so as you referred the power problem might have occurred. I bought alternative power source(case for 4 AA batteries, 5V, 1A) for test. I would try again using it. Thank you!

let have a look at following line of code:
int servopos = bluetooth.read();

I think that you are thinking that if you type in 1 in your
Bluetooth application. bluetooth.read() will pass that 1 to
sevopos. But, that's what not happens. What actually happens is that it will pass the ASCII value of whatever you type in you
app, to integer. So, if you have typed in 1, it will pass 49
to servopos.

I put 45

Now, think about it. when you type in 4 of this 45,
bluetooth.available()>0

becomes true.
int servopos = bluetooth.read();

bluetooth.read() will pass 52 (ASCII of 4) to servopos. Next,
myServo.write(servopos);

myservo will move your servo to lets say 52 degrees. and then there will be a delay.
Now, when you type in 5 of this 45, the procedure will be
repeated and your servo will be moved again by 53 degrees.
Now, you might be wondering that why 4 and 5 sepratly? Well,
all these intructution are being executed in MHzs. and secondly,
you, yourself has programmed that if loop you read just once
character. Yes, it will read character by character.

but it loose connection after servo moved once

I think your servo is drawing too much current from Arduino Board
which results in a drop in net voltage. And hence your HC-05 (kind
of) tuns off. This is what happens most of the time.

It is not a problem in serial connection. I have experienced this problem when I was trying to make a biped robot using 12 servos. It is the programming bug where Arduino does not use its timers properly. You can say that it is arduino limitation.
There are two main solutions :
1). Use Raspberry Pi instead of arduino.
2). Secondly you can make a small servo controlling shield of TLC5940 IC + servo controlling library...  Here is he Link: http://bildr.org/2012/03/servos-tlc5940-arduino/


text:
Accelerometer IoT
I am not sure if I am in the right place. I would like to build a device (as small as possible) that has an accelerometer and can talk to my phone via bluetooth. Im not asking anyone to build this for me. I would just like some starting help. Can you tell me the parts that I would need to accomplish this?

For low power battery powered operation you want BLE not normal Bluetooth.

Only moments ago, I was perusing the Adafruit selection and found this BLE module for arduino and similar:
https://www.adafruit.com/products/1697

Find a tutorial, e.g. https://learn.adafruit.com/adafruit-analog-accelerometer-breakouts

you will need:

Arduino Mini (can also use Uno/Mega/Pro....)
Bluetooth Module (mostly used: HC-06/HC-05)
Accelerometer (mostly MPU-6050)
Few wires.

If you want to carry this device around, you will need a battery to power this circuit.

Your smallest solution would not involve a conventional "Arduino" at all, but rather something like an nRF51822 Bluetooth Low Energy chip/module, which in addition to being a radio is a processor in its own right capable of running custom software built in a variety of ways, including one that extends the Arduino IDE to support it.
Basically, you need the nRF51822 or similar chip, an accelerometer, and whatever solution for powering the two you decide upon.
In terms of conventional bluetooth vs. BLE the choice depends not only on technical merits, but also on which phone you want to connect to.  If you want to connect to an iphone, you are basically locked into BLE as the bluetooth stack there is restricted to approved devices.  On the other hand older/cheaper Android devices may not support BLE, or support it poorly, while their conventional bluetooth does not have the approval restrictions of iOS.

If you want Arduino programming AND you have physical size limitations, you may want to checkout RFDuino.
http://www.rfduino.com/
They have a variety of breakout boards that make rapid prototyping easier.
I should say however that while I have purchased one of these, I have yet to get around to using one. Others with more experience may want to chime in.


text:
Wi-Fi from Arduino to computer serial COM
I am somewhat new to the Arduino world and so far having fun. I am making a gardening watering system for my first project. I am at the final stages of completion and want to add a Wi-Fi module on the Arduino to send to my computer and display via serial COM the soil moisture and other relevant measurements I have going.
Now my question is, is it possible the simple analog information from my Arduino to my computer's serial COM with the Wi-Fi module ?

I fail to see where the COM port fits into the equation.

Well like I said I am still very new, so when I usually display the analog information I can usually find it under the serial COM because thats where I printed it. Is there a simpler way I can view the information on my computer?

Well, with a WiFi module you are connected to your local network wirelessly. Your computer is already connected to that network, so you just communicate through the network. Programming that sort of thing is considerably more complex though.

But is it possible to have my Serial Monitor on my computer display the information from the arduino via wifi?

No. WiFi isn't serial. The closest you could get is through Telnet.

You can of course put a serial wifi-module at both the Arduino and the PC end and get exactly what you have asked for, but adding extra wifi hardware at the PC end just to get the data appearing on a serial port rather than a network socket seems a bit silly.

I would recommend using Bluetooth, as Bluetooth communication is
mostly done by using COM Ports.
You can use HC05/HC06 Bluetooth Modules with Arduino.
You can easily pair your PC with these Bluetooth Modules.
Now, you write an application in any programming language to get &
send data to your Arduino via Bluetooth COM ports.

ok Thank you, What is the difference between the HC05 and 06? Is one better than the other?

They are approximately the same. Either one will work. Nothing to worry about.

you can use ESP8266 with ESP-LINK firmware.
There is nothing to it.Check out github.com/jeelabs/esp-link for documentation, examples and such.
Connect ESP8266 to Arduino URXD:
connect to TX of microcontroller UTXD:
connect to RX of microcontroller GPIO0:
connect to RESET of microcontroller GPIO2:
optionally connect green LED to 3.3V (indicates wifi status) And that about it. Everything else is done over WiFi

How? Can you provide more details, circuit schematic, some code, an explanation?

There is nothing to it.Check out https://github.com/jeelabs/esp-link for documentation, examples and such. Connect ESP8266 to Arduino URXD: connect to TX of microcontroller
UTXD: connect to RX of microcontroller
GPIO0: connect to RESET of microcontroller
GPIO2: optionally connect green LED to 3.3V (indicates wifi status) And that about it. Everything else is done over WiFi

Could you edit and update your answer, and put the extra details in there, rather than in comments? It just keeps the site tidier, as well as making your answer more succinct, and means people don't have to look through comments to get the complete picture. Thx.

As @Greenonline has indicated, please update your answer to better reflect and format what you've said in your comments.


text:
Can't retrieve data from X-NUCLEO-IKS01A1 using I2C protocol
So I bought this nucleo expansion board, the X-NUCLEO-IKS01A1, and on the package it says it is compatible with Arduino Uno.
My goal here is to read data from any sensor on this board. (When I can read one, I can probably read the others too using the same structure)
Here's my code.
#include <Wire.h>

#define ADDRESS 0x1E
#define REGISTER 0x16

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

void loop() {
  // put your main code here, to run repeatedly
  Serial.println(I2CreadByte(ADDRESS, REGISTER));
  delay(5000);
}

uint8_t I2CreadByte(uint8_t address, uint8_t subAddress)
{
  uint8_t data; // `data` will store the register data

  Wire.beginTransmission(address);
  Wire.write(subAddress);
  Wire.endTransmission(true);
  Wire.requestFrom(address, (uint8_t) 1);

  data = Wire.read();
  return data;
}

This should return the temperature in 2's complement. But all it returns is a 1 (I can guarantee you it's not that cold in my room).
I have the board plugged on my Arduino.
Can anyone tell me what I'm doing wrong?
Here's the datasheet for the sensor I'm trying to communicate with.
Datasheet
The sub addresses are on page 33 and the I2C explantation on 27. It's called the LSM6DS0.
Thanks sooo much in advance.

You're using a wrong slave address. From the datasheet:

The Slave ADdress (SAD) associated to the LSM6DS0 is 110101xb. The SDO/SA0 pin can be used to modify the less significant bit of the device address. If the SDO/SA0 pin is connected to a voltage supply, LSb is ‘1’ (address 1101011b), else if the SDO/SA0 pin is connected to ground, the LSb value is ‘0’ (address 1101010b). This solution permits to connect and address two different inertial modules to the same I2C bus.

This means your sketch should contain:
#define ADDRESS 0x6A  // if SDO pin is pulled down

or:
#define ADDRESS 0x6B  // if SDO pin is pulled up

It's also a good idea to check if there's actually anything in the Wire buffer (with Wire.available()) before you attempt reading.
Finally, I suggest you read both OUT_TEMP_H and OUT_TEMP_L registers, in order to calculate the temperature correctly. The datasheet says the temperature output is zero at 25 degrees Celsius and that the sensitivity is 16 LSB/C. This means you have to read both registers, combine their results to get a 16-bit signed integer (OUT_TEMP_H is the MSB), divide it by 16 to get the temperature offset, and add the result to 25 degrees Celsius to get absolute temperature.

Where did you find the offset and precision? I can't seem to find them.

@CasperVranken Its all in a table in the datasheet. I dont remember the page but search the pdf for "LSB" and you should come across the 3-row table. The offset is mentioned below the table in a note.


text:
Atmega328 xbee and softaware serial libraries
I use an atmega328 with fdti cable wired at rx/tx and i want to connect a zigbee s2 at diferrent pins. I have tried to use  SoftwareSerial library but i would like to use the xbee library too. Is there a way to use both libraries? If there is no way doing this, is it a problem to connect both fdti cable and zigbee at the same rx/tx? In the future, in opposition to fdti cable i will use a micro usb avr.


text:
Oddness with #define and #ifdef in a sketch
I'm putting together a simple sketch to read a few sensors and have come across some odd behaviour associated with #define and #ifdef.
Here are some snippets from my code:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
#define GPSSYSTEM 1
#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
#endif

With this snippet the rest of the sketch compiles, but with this:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
//#define GPSSYSTEM 1
#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
#endif

The compile fails, claiming that the error is in some functions further down.
BTW, Mth, Day and TMZ are not used anywhere yet, not are they defined anywhere else.  What is even more odd is that the error messages are announcing the erroneous line numbers to be about 12 lines removed from where they really exist in the sketch, and have no association with the declarations here.
Now, this gives a clean compile:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
#define GPSSYSTEM 1
//#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
//#endif

as does this:
// Defines
//#define DEBUG 1
#define ACCELEROMETER 1
#define GYROSCOPE 1
//#define GPSSYSTEM 1
//#ifdef GPSSYSTEM
  unsigned int Mth=0;
  unsigned int Day=0;
  char TMZ[2];
//#endif

I've been chasing this weirdness for a day now and am getting nowhere.

It's hard to pinpoint the error withouth having the actual error and code. @ARK is right, but I'm not sure if that is the error you're looking at.

Try removing all and adding one define at a time to see who the problem child is. Additionally versions 3&4 compile because you're only defining three small variables. More color on errors would've been helpful

The #ifdef Directive you are using is one of Conditional
  Directive.
  This directive checks whether the identifier is currently defined.

In general, it has following syntax:
#ifdef identifier newline

For Arduino, you can modify your #ifdefs to following code:
#if defined(GPSSYSTEM)
    //Code here
#endif

Explaining your code snippets behaviors:

In your first code snippets, GPSSYSTEM has been defined by following line of code:
#define GPSSYSTEM 1

Now, For this code snippets, #ifdef GPSSYSTEM is true, and following variables are defined.
But, when you comment this #define GPSSYSTEM 1 line in your 2nd code snippets, GPSSYSTEM is no more defined and so #ifdef GPSSYSTEM is false, and thus following variables are not defined which result in compilation errors in your code.
Following same logic, behavior of your 3rd and 4th code snippets can be explained easily.


text:
SimpleSDaudio giving a lot of static from speaker
I'm using SimpleSDaudio (http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio) to play wav files. The connections are as follows:
MISO pin 12
SCK pin 13
SS pin 4
MOSI pin 11
Speaker pin 9
/*
 Simple SD Audio bare minimum example, plays file EXAMPLE.AFM from root folder of SD card.

 This example shows how to use the SimpleSDAudio library for audio playback.
 You need:
 - An Arduino with ATmega368 or better
 - An SD-Card connected to Arduinos SPI port (many shields will do)
   -> copy EXAMPLE.AFM on freshly formated SD card into root folder
 - A passive loudspeaker and resistor or better: active speakers (then stereo output will be possible)

 Audio signal output is at the following pin:
 - Arduino with ATmega328       (many non-mega Arduinos): Pin 9
 - Arduino with ATmega1280/2560 (many mega Arduinos)    : Pin 44

 Using passive speaker:
    Audio-Pin --- -[100 Ohm resistor]- ---- Speaker ---- GND

 Using amplifier / active speaker / line-in etc.:
    Audio-Pin --||--------------[10k resistor]----+----[1k resistor]---- GND
              100nF capacitor                   to amp

 See SimpleSDAudio.h or our website for more information:
 http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio

 created  20 Jan 2013 by Lutz Lisseck
 */
#include <SimpleSDAudio.h>

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

  // Using F("...") to avoid wasting RAM
  Serial.print(F("\nInitializing SD card..."));

  // If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:
  // SdPlay.setSDCSPin(10);

  if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER)) {
    Serial.println(F("initialization failed. Things to check:"));
    Serial.println(F("* is a card is inserted?"));
    Serial.println(F("* Is your wiring correct?"));
    Serial.println(F("* maybe you need to change the chipSelect pin to match your shield or module?"));
    Serial.print(F("Error code: "));
    Serial.println(SdPlay.getLastError());
    while(1);
  } else {
   Serial.println(F("Wiring is correct and a card is present."));
  }

  Serial.print(F("Looking for on.wav... "));
  if(!SdPlay.setFile("hi.wav")) {
    Serial.println(F(" not found on card! Error code: "));
    Serial.println(SdPlay.getLastError());
    while(1);
  } else {
   Serial.println(F("found."));
  }

  Serial.print(F("Playing... "));
  SdPlay.play();
  while(!SdPlay.isStopped()) {
    ;   // no worker needed anymore :-)
  }
  Serial.println(F("done."));
  SdPlay.deInit();
}

void loop(void) {

}

The problem is when playing the wav files. It plays with a lot of static. I've tried adding a 1k resistor between the speaker and gnd but that just lowered the overall volume. I resampled the wav files in itunes to 32khz, 8bit, mono. If I lower to 16khz then the audio volume becomes very low and the song just plays extremely fast. Here is a google drive link to one of the sounds:
https://drive.google.com/file/d/0B3yAl4G-mcC4dlppN3dtczJvT1k/view?usp=sharing
I really need help. I'm not sure what to do!

Is that sample a source sound or a playback recording?  I don't hear any static in it.

Have you read the documentation in that link you provide? Especially the bit about converting the WAV files to 8-bit mono raw files prior to use?


text:
Am I multiplexing my LEDs correctly?
I am new to electronics. I have a good amount of programming under my belt however.
I want to know if I am multiplexing correctly or not. My intended output is how I want it, but I am not sure if I implemented it how it's supposed to be, i.e. am I potentially damaging my equipment.
I have 6 RGB LEDs hooked up to my arduino, let's called them L1 - L6.
I have each R, G, and B pin on L1 - L3 connected in parallel, and the same for L4 - L6. Then I have ground on L1 and L4 connected in parallel, and the same for L2 to L5, and L3 to L6.
So this gives me 6 pins to supply voltage to, to which I put a 220 ohm resistor in each one. Then it gives me 3 different spots for ground.
My question is about the ground. How should I control the different 'pins' for ground.
This is what I have right now, and it works, but I don't know if this is dangerous to my equipment for some reason.
I have the 3 ground pins connected to the Arduino in 3 different pins, 7, 4, and 2.
In Setup() I configure these 3 pins as outputs, and I later found out in order to keep them all 'off' I need to set them all to high.
So then in order to turn L1 on to red, I need to turn its red pin to high, but turn its ground pin to low, then L1 turns on.
Using this same technique, I am able to get every LED to every desired color. So I mean it works. But why is this? Is this how I should be doing it? I understand LEDs polarity matters, but why would supplying its cathode with voltage make it turn off? That's the part I'm worried about, am I destroying my LEDs by doing this?
Any and all help much appreciated!
Here is how I have it all wired up for clarity.

So I mean it works. But why is this?

It works because the LED inside the RGB LED, all three of the LEDs inside have the characteristic of a diode, this means it will allow current flow in one direction, but will stop, or restrict it in the opposite direction. Also are you asking why it works because of your specific wiring?

Is this how I should be doing it?

Yes, how you are doing it is fine. Although I would suggest you use NPN transistors to drive your cathodes of the LEDs.

This will at least remove any worry of applying 5v to the cathode.
It will also reduce the amount of current your I/O pins have to handle.
You should also move the resistors from the cathodes to the anodes as this is more reliable and pretty much the norm.

I understand LEDs polarity matters, but why would supplying its cathode with voltage make it turn off?

This works because of the theory of the p-n junction, (inside construction of a diode), this means that because of the construction of the diode it requires the voltage on the Cathode to be at a lower potential. So that means when you set the output HIGH the 5v on the anode and the 5v on the cathode "stop" current flow because it stops the breakdown within the p-n junction.

That's the part I'm worried about, am I destroying my LEDs by doing this?

No you are not, the LED acts as a diode and when the potentials are the same, current doesn't really flow and thus doesn't do anything to the LED.

LEDs are not powered by a particular voltage level, but by the voltage difference between anode and cathode. That's why you need to drive cathode pins (7, 4, and 2) LOW to switch the LEDs ON and HIGH to switch them off. A truth table could help:
╔═══════╦═════════╦══════════════════════════╦═══════════╗
║ anode ║ cathode ║ voltage anode to cathode ║ led state ║
╠═══════╬═════════╬══════════════════════════╬═══════════╣
║ LOW   ║ LOW     ║ 0V                       ║ OFF       ║
╠═══════╬═════════╬══════════════════════════╬═══════════╣
║ LOW   ║ HIGH    ║ - 3.3V                   ║ OFF       ║
╠═══════╬═════════╬══════════════════════════╬═══════════╣
║ HIGH  ║ LOW     ║ + 3.3V                   ║ ON        ║
╠═══════╬═════════╬══════════════════════════╬═══════════╣
║ HIGH  ║ HIGH    ║ 0V                       ║ OFF       ║
╚═══════╩═════════╩══════════════════════════╩═══════════╝

Your schematic looks safe to me, but be aware that if you decide to illuminate L1, L2 and L3 to the same color simultaneously (e.g drive red line HIGH and pins 7, 4, and 2 LOW), your LEDs will not have uniform brightness. Only one of the cathode pins should be LOW at a time, otherwise you will end up in the situation described here.

I see what you mean. I'm having trouble trying to figure out PWM now and I don't know how to make L2 @ 255 red while keeping L1 @ 127 red - because they use the same red pin (11).

first drive cathode L2 low, L1 high, and PWM @255. Then drive cathode L1 low, L2 high, and PWM @ 127. repeat about 100 times per second so both LEDs appear lit simultaneously.


text:
Retrieve value from ThingSpeak using ESP8266 with Arduino setup
I just started learning ESP8266 and in my first project I am successfully able to send data to ThingSpeak.com using ESP8266 with following code:
uploadData() {
  String apiKey = "ESDS8678890SDDS";
  String myData = "45.5"; // example of data to send
  if (espClient.connect(server,80)) {
    String postStr = apiKey;
    postStr +="&field1=";
    postStr += String(myData);
    postStr += "\r\n\r\n";
    espClient.print("POST /update HTTP/1.1\n");
    espClient.print("Host: api.thingspeak.com\n");
    espClient.print("Connection: close\n");
    espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
    espClient.print("Content-Type: application/x-www-form-urlencoded\n");
    espClient.print("Content-Length: ");
    espClient.print(postStr.length());
    espClient.print("\n\n");
    espClient.print(postStr);
    Serial.print(postStr);
    Serial.print("My Data: ");
    Serial.print(myData);
    Serial.print("\n");
  }
  espClient.stop();
}

But I have no idea how to retrieve data from ThingSpeak using ESP8266.
// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.
Help would be appreciated.
Thanks.

Connect to the server as usual with espClient.connect(). The following request should return a JSON object containing your channel description and the first 2 entries in your feed:
espClient.println("GET /channels/CHANNEL_ID/feeds.json?results=2 HTTP/1.1");
espClient.println("Host: api.thingspeak.com");
espClient.println("Connection: close");
espClient.println();

If it's a private channel, then you must supply your Read API key like this:
espClient.println("GET /channels/CHANNEL_ID/feeds.json?api_key=<your API key>&results=2 HTTP/1.1");

Notice that I use println() and not print() in order to implicitly terminate each request line properly. You should end each line not with \n but with \r\n. You only need to type this yourself if you use print().
To read the returned JSON data:
while (espClient.available() == 0);  // wait till something comes in; you may want to add a timeout here

unsigned long lastRead = millis();  // keeps track of last time a byte was read
while (millis() - lastRead < 2000) {  // while 2 secs havent passed since a byte was read
  while (espClient.available()) {
    Serial.print(espClient.read());
    lastRead = millis();   // update last time something was read
  }
}
client.stop();  // close socket

To parse the JSON string, you either get a library from GitHub or you parse the string yourself.

authors: Обычный Юзер


text:
How can one use the SPI hardware on the Arduino Nano?
I recently prototyped and programmed a system that used some SPI sensors on an Arduino Uno. I wanted to get the size down a bit, so I was thinking I might buy an Arduino Nano and re-wire my system around that. The problem is that I have seen mention of SPI not working on the Nano. From the Nano product page:

These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

Yet I have also seen mention of SPI working on this board, or at least people saying that it should. Someone asked a similar question on Stack Overflow and was told that it should work with the same level of support as I2C, even if it isn't built in to the core framework. But that answer does not definitively answer the question of whether SPI does work, and it doesn't explain any caveats that one may come across. In this question, the OP's premise is that their SPI device works on the Nano but not on other boards; this seems to be a strong indication that SPI does work.
I figured it would be worth it to buy a Nano 3 and see if it worked. SPI devices did not work on that board, including the same radio module mentioned in the question linked to above. So, I am inclined to believe the Arduino product page when they say it isn't supported. But that still isn't satisfactory, and it is the opposite conclusion from that of the other questions: The hardware is all there and the software framework is in place, so what does one need to do to make SPI work on the Arduino Nano? Why is it that some sources say it works while others say it doesn't?

Don't always trust the arduino website. It's very outdated and often incorrect. You could try compiling some example code that uses SPI. If it compiles, the statement from the arduino site would be incorrect.

You can always connect your logic analyser or oscilloscope to the SPI pins and actually look at what is happening on the pins... You do have the basic test tools you need to do electronics, don't you? https://hackingmajenkoblog.wordpress.com/2016/03/23/top-6-things-every-engineer-needs/

@Gerben Although I did not try to run one of their samples, I did run my own code (the same code that works on the Uno) and double-checked the wiring. While the compile and build were fine, the SPI device did not respond with any data, nor could I see any other sign that it was working.

I thought this was a purely theoretical question. Showing your wiring and your code would be helpful.

@Gerben I am asking it theoretically, having been prompted (as mentioned) by seeing a certain behavior in reality. I would like to keep this question away from my specific test and focus on the theoretical situation: Does the Nano support SPI, and is there anything that must be done differently on the Nano to use it? If the answer is that it does support SPI out-of-the-box, I will then investigate on my own why I was unable to get it to work.

I am having the same problem - a code for Uno, which compiles fine for Nano, but does not work. One thing to notice is that MISO and MOSI pins are switched between Uno and Nano, but that's not all. The crystal frequency of Uno is 16MHz, while Nano is at 12MHz. I wonder if this means some constants need to be changed in SPI.h.

Yes, the Nano supports SPI when used with a modern Arduino version, and no, you do not have to do anything special to utilize it on this board.
The information you found that seems to suggest something to the contrary is simply a result of the fact that that the web page for the Nano is sadly out of date date and does not reflect the current state of the Arduino libraries which support SPI on this processor and hence board.
In terms of components, the Nano it is very nearly just a form-factor shrink of the discontinued Duemilanove, and in the current version updated to an an ATmega328p it has capabilities essentially comparable to an Uno, differing primarily the in the USB interface which has nothing to do with SPI.
In terms of what is wrong with the web page, if we examine archive.org's records for the page of the comparable Duemilanvoe, on September 15th, 2010 it said:

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language.

But a few days later on September 26th, 2010 it had been changed to say:

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.

Although the page for that once-flagship product was updated to reflect SPI support nearly six years ago, they've not yet made a corresponding correction to the Nano page.  But as the difference is in the software and the same software is used in either case, the addition of SPI support to the Duemilanove was also automatically an addition of that support to the Nano.

In this Nano schematic, I see MOSI, MISO & SCLK on pins J1-14, J1-15 & J2-15.
On this page I see a SPI library.
The Nano is not specifically listed in the latter link.  However the Nano and other Arduino boards are similar.

The Nano is just a smaller version of the Leonardo.

Sorry. I was thinking of the Arduino MICRO.


text:
Create own apache web server on Arduino Uno... just like you can on a raspberry pi?
I was wondering if I could create my own apache web server on my Arduino Uno, just like I did on my raspberry pi - https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
Anyone have any idea about this? From my research it seems like I cant achieve the same results on an arduino uno.
Thanks

You can only make a very, very, very basic webserver, that won't be able to handle more than a few requests per second.
You also need to add something like an ethernet shield, and probably an SD card reader. Which would make it about the same price as a Pi.
It's possible, but very limited, not practical in most cases, and not that much cheaper.

Indeed - essentially, whatever you use as a network interface ends up being a better "computer" than the Arduino, so you might as well just run your code on that instead.  And with things like the ESP8266 port of the Arduino environment, it doesn't even require much of a thought shift to do so.

I do recall someone actually managing to run Linux on an Arduino. It was quite impressive, involving a very large amount of external DDR RAM and bit-banging the interface to it. Basically emulating a virtual computer within the Arduino.  I can't find the original post though - it's been lost in time...
So yes, technically it is possible to run Linux, and thus Apache, on an Arduino.
Is it recommended to even think about trying to do something like this though?
Certainly not.
The Arduino is a microcontroller, not a computer. It is designed for controlling things (hence its name) not for general computing tasks.
It can, though, run its own web server software - that is, you can connect some form of network interface (Ethernet, WiFI, etc) and implement a very very basic web server. It can't really do much, and all interactivity has to be hard coded into it in C++. There doesn't (yet) exist any simple scripting engine or anything like that (PHP, etc) and you are very limited on how much you can implement (lack of memory) as regards anything fancy.
In general a web server running on an Arduino is used as a back-end to a proper web server and interacted with using Ajax calls or other similar methods.  More commonly though a web interface is shunned in favour of much lighter weight protocols or push technologies like MQTT.

While you can't make an apache web server with an Arduino Uno, you can if you access the linux module of the Arduino Yun board. I in fact did this and with some testing realized that it can't handle more than a few packet requests per second.
Although a raspberry pi is much cheaper and more capable than a re-programmed Yun if you want a "Mainstream" server
(Namely one Arduino Yun is $75.00 while a Raspberry Pi model 3 B is $35.00 at the time of this writing.)

No you can't. Apache (or any web server of similar functionality) will require:

tens to hundreds of megabytes of RAM
about 50 megabytes of storage
an actual operating system

Perhaps you can get the required storage with the SD shield, but it's practically impossible to get enough RAM or run a suitable OS on arduino.

Yes, you can make a web server.  Here is the tutorial.
You do not need Apache to create a web server.


text:
keypad code is not working and produces wrong numbers
I have the following issues:
1) When i press for example number 7 on the keypad it shows a different number on the serial monitor
2) The servo motor works for any combination of 4 numbers.
Code:
/*http://openhwdesign.comLock system using a Keypad
*/
#include <Password.h>
#include <Keypad.h>
#include <Servo.h>
#pragma GCC diagnostic ignored "-Wwrite-strings"
Servo myservo; //declare servo
Password password = Password( "5523" );

const byte ROWS = 4; // declare the rows of the keypad
const byte COLS = 3; // declare the columns of the keypad

// Define the Keymap

char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};

byte rowPins[ROWS] = {2,3,4,5}; // Connect keypad’s pins to these Arduino pins.
byte colPins[COLS] = {6,7,8}; // Connect keypad’s pins to these Arduino pins.

// Create the KeyPad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
Serial.begin(9600);
myservo.write(0);
pinMode(11, OUTPUT); //The green led is set as an output.
pinMode(12, OUTPUT); //The red led is set as an output.
myservo.attach(13); //The servo is connected to the digital pin 13.
keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad

}

void loop(){
keypad.getKey();
myservo.write(180); //why? what happens if you comment it? ###########################
//delay(5);
}

void keypadEvent(KeypadEvent eKey){
// When the KeyPad will be pressed, the results will appear on the serial monitor.
switch (keypad.getState()){
case PRESSED:
Serial.print("Enter: ");
Serial.println(eKey);
delay(10);

switch (eKey){
case '*':
checkPassword(); // Will check the password.
delay(1); // Delay used for stability.
break;

case '#':
password.reset(); //Will reset the password
delay(1); // Delay used for stability.
break;

default:
password.append(eKey); //Append any keypress that is not a ‘#’ nor a ‘*’.
delay(1);
}
}
}
void checkPassword(){

if (password.evaluate()){ //If the combination inserted is equal to the combination saved, the servo’ll rotate.
Serial.println("Accepted");
//delay(5000);
delay(10);
myservo.write(50); //was 140
delay(5000);

digitalWrite(11, HIGH); //Turn the green led on.
delay(500); //Wait 5 seconds.
digitalWrite(11, LOW); //Turn the green led off.

//break; // remove if trial did not work #####################try#####################
}
//break; // remove if trial did not work ##########################################
else{ //If the combination inserted isn’t equal to the combination saved, the servo will not rotate.
//delay(5000); delays response
Serial.println("denied");
delay(10);
//delay(5000);
myservo.write(20); // was 50
digitalWrite(12, HIGH); //Turn the green led on.
delay(5000); //Wait 5 seconds. was 500 ///
digitalWrite(12, LOW); //Turn the green led off.

    }
}

Thank you.

Just change the keys array to get the correct values. The keypad you have is probably wired differently from the one in the article.

The first thing you need to do is just look at what the problem is.  Create a new sketch and paste this code into it.
#include <Keypad.h>

const byte ROWS = 4; // declare the rows of the keypad
const byte COLS = 3; // declare the columns of the keypad

// Define the Keymap
char keys[ROWS][COLS] =
{
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};

byte rowPins[ROWS] = {2,3,4,5}; // Connect keypad’s pins to these Arduino pins.
byte colPins[COLS] = {6,7,8};   // Connect keypad’s pins to these Arduino pins.

// Create the KeyPad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void keypadEvent(KeypadEvent eKey)
{
    // When the KeyPad will be pressed, the results will appear on the serial monitor.
    switch (keypad.getState())
    {
    case PRESSED:
        Serial.print("Enter: ");
        Serial.println(eKey);
        delay(10);
        break;
    }
}

void setup()
{
    Serial.begin(9600);
    keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad
}

void loop()
{
    keypad.getKey();
    delay(20);
}

You should recognise it, its a reformatted version of your code (pretty code is easier to debug), but with only the keypad bits in.
Now load that onto your hardware and write down what number is shown when you press 1 three times.  Do it three times just to make sure its the same number and you haven't got something totally obscure happening. Repeat for the other 11 buttons.
If 7 and 3 always give you 3 and 6 then you have got your row and column wires crossed.
If 7 always gives you 1 and 9 always gives you 3 then the wires for row 4 and 2 are crossed over. etc
If you can't work out the patter post your findings and I'm sure someone will solve the puzzle.
As for problem 2, don't even go there until you know what you are typing. :)
Hope that helps


text:
avrdude/stk500 protocol error
I'm running into a bizarre problem. I've got a custom board using an Atmega328P, running off the internal oscillator. From Atmel studio, I've successfully uploaded the standard optiboot bootloader (optiboot_atmega328.hex) and burned the appropriate fuses (hfuse = 0xDE, lfuse = 0xE2, extended_fuse = 0x05). As per an arduino forum post, I added the following entry to boards.txt:

    atmega328_384_8.name=ATmega328 Optiboot @ 38,400baud w/ 8MHz Int. RC Osc.
atmega328_384_8.upload.protocol=arduino
atmega328_384_8.upload.maximum_size=30720
atmega328_384_8.upload.speed=57600
atmega328_384_8.upload.tool=avrdude

atmega328_384_8.bootloader.low_fuses=0xE2
atmega328_384_8.bootloader.high_fuses=0xDE
atmega328_384_8.bootloader.extended_fuses=0x05
atmega328_384_8.bootloader.path=optiboot
atmega328_384_8.bootloader.file=optiboot_atmega328.hex
atmega328_384_8.bootloader.unlock_bits=0x3F
atmega328_384_8.bootloader.lock_bits=0x0F

atmega328_384_8.build.mcu=atmega328p
atmega328_384_8.build.f_cpu=8000000L
atmega328_384_8.build.core=arduino
atmega328_384_8.build.variant=standard

Note here, I've modified the upload speed to 57600 baud to "fool" it into the right upload speed given an 8MHz oscillator.
I can now successfully upload sketches from the Arduino IDE (1.6.3) on the lab windows machine, but when I try from my Mac (various IDE versions have been tried), I get the following protocol error:
avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0
Here's the full trace:
/Applications/Arduino-1.6.8.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino-1.6.8.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbserial-AH02F0KI -b57600 -D -Uflash:w:/var/folders/db/hw2v9r6j7qj_w9gh3qkhh_580000gr/T/build53eb1895270295360d41549eaf6e0624.tmp/sketch_apr19a.ino.hex:i

avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino-1.6.8.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/npisenti/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-AH02F0KI
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00
         Hardware Version: -1538883332
         Firmware Version: 6291456.-1538883332

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0
         Vtarget         : 322122165.6 V
         Varef           : 275608114.4 V
         Oscillator      : 0.001 Hz
         SCK period      : 368336.6 us

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xe0

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x00
avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0xe0
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xe0

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

On Windows, the "successful" full trace from avrdude is:
Sketch uses 1,974 bytes (6%) of program storage space. Maximum is 30,720 bytes.
Global variables use 192 bytes of dynamic memory.
C:\arduino-1.6.3\hardware\tools\avr/bin/avrdude -CC:\arduino-1.6.3\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM10 -b57600 -D -Uflash:w:C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex:i

avrdude: Version 6.0.1, compiled on Mar 30 2015 at 14:56:06
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\arduino-1.6.3\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex"
avrdude: writing flash (1974 bytes):

Writing | ################################################## | 100% 0.77s

avrdude: 1974 bytes of flash written
avrdude: verifying flash memory against C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex:
avrdude: load data flash data from input file C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex:
avrdude: input file C:\Users\GENERA~1\AppData\Local\Temp\build1097250116669309732.tmp/sketch_apr19a.cpp.hex contains 1974 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.86s

avrdude: verifying ...
avrdude: 1974 bytes of flash verified

avrdude done.  Thank you.

In both cases, I'm using the FTDI friend from Adafruit; at first I figured it must be a driver issue, but I've installed the latest FTDI drivers and doesn't seem to help. Besides, I can successfully get text dumped from the ucontroller onto the serial port from a sketch previously uploaded on the windows machine.
Any help would be greatly appreciated!

I managed to figure this out after hours of searching. I wanted to flash the new Nano bootloader to my Nano, but it would fail with the same error as you.
For some reason, after Arduino 1.8.5, AVR boards with "Arduino as ISP" were changed so that they no longer work for me.
The solution for me was to revert programmers.txt to what it was on 1.8.5, i.e. change the arduinoasisp lines to:
arduinoasisp.protocol=stk500v1
arduinoasisp.speed=19200
arduinoasisp.program.protocol=stk500v1

This uses the stk500v1 protocol instead of the arduino protocol (you can see the -carduino option in your command line) and makes everything work for me.

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


text:
Motor controller for 24v motor, Arduino Uno
I need a motor controller for a 24v motor and I want to control it using än Arduino Uno. Suggestions?
The motor needs to run both directions and is going to draw about 5A

I see, the Arduino Motor Shield only supports upto 12V. But there are motor controllers for 24V and beyond that and can find those on ebay, aliexpress and whatever local suppliers you can find.

try this Arduino Compatible Mega Motor Shield. Specs:

Low-cost robust H-bridge ''shield'' for Arduino
Provides the ability to control up to 30A of current at up to 28V
Supply voltage: 5V to 28V (24V max battery rating)
Continuous output current: 13A
Have, a look:

I'm doing my own driver dude using Tip122 but you can use TIP120 too TIPand other components

Using bipolar power transistors for this is far from the best idea in this day and age.  This is a classic MOSFET application.  Also, since you posted the question has been updated to clarify the need for bidirectional drive, which means two high side switches and two low.

better invest few dollars and use a motor controller that will keep you from shooting threw the MOSFET transistors, enable soft start of motor and let you select between fast decay and slow decay when PWM is in OFF state. ( see details for DRV8814 by TI)


text:
Arduino PRO Mini - The pads [was "jumpers"] on the back and Low Power Consumption
I've noticed that on the back of an Arduino PRO mini are two Jumpers next to the A4 and A5 pins, marked with red in the following :

Looking at the leads one seems to be a bypass for the POWER Led and the other a bypass for the regulator, but not sure.
Further, the schematic reveals just one Jumper SJ1 :

https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf
So, my questions are :

Why are there two physical Jumpers on the board ?
Are these two jumpers actually just one : SJ1 ?
And if so how to connect them in order to enable Power isolation ?

Both responses are correct but be mindful that this is a SparkFun feature.  An Arduino Pro Mini from China won't necessarily have the SJ1 pad.
1) Like Gerben said, the pads on the underside of the board are for I2C pull-up resistors.
2) Like David said, SJ1 is on the top of the board next to the GND and RST pins.  (It looks like a small solder blob.)
3) To isolate the regulator from VCC, remove the solder blob on the top of the board with a sucker or solder wick.
The Sparkfun schematic shows all of these elements:
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf

I think those aren't jumpers, but pads to place two pull-up resistors for I2C.
It seems the eagle files Sparkfun shares aren't the same as the board in the picture.
But you don't need to worry about this. If the RAW pin is not connected the MIC5205 regulator uses only 0.01μA according to the datasheet.

These pads are not jumper SJ1. On the front of the board just beneath the GND pad there is a blob of solder. This is SJ1 (I believe - I am writing from memory, I do not have a Pro Mini sitting on my desk at the minute) and removing the solder blob will disconnect the LED and output of the regulator from Vcc.

You can look up the location of SJ1 in the Eagle project files that are provided by Sparkfun). For example, you can import them into KiCad (Free and Open Source), which opens a PCB and a Schematic editor.
To locate SJ1 you can simply click on it in the Schematic editor such that it's highlighted in the PBC editor, as well. For better overview, you may want to hide all the layers besides the foreground one (e.g. 'F.Cu') and click View/Zoom-to-Fit:

-> That means SJ1 is located on the front of the board, right of pin 9 (ground), i.e. it's highlighted in a lighter red. For comparison, I included an image (Sparkfun, CC BY 2.0) of the front, where you can see that SJ1 is marked by a white rectangle (painted on the board) and that it's closed, by default by a solder blob, which can be de-soldered (e.g. using solder wick and a bit of flux).

NB: To enable power isolation (i.e. such that the MCU can be directly powered without also powering the power-on LED and one side of the on-board LDO, e.g. in order to save power), you have to open SJ1.

Thus, the pads on the back of the board, you marked in an image you included in the question, are something different. In KiCad you can look them up as well: that means switch to the back layer (e.g. 'B.Cu') and click on the pads such that the related parts are highlighted in the schematic editor:


text:
Arduino to send sms one time only when a button is pressed
The LED_UPDATE() is called in my loop() function, I implemented it (tried anyways),
to send sms as shown in the code such that  only one sms is sent , because as the loop() keeps calling LED_UPDATE(), it's going to keep sending an sms every time (yep you guessed it, very bad for credit :o )
any tips on how I can get around this or what i'm doing wrong in my code would be much appreciated.
p.s. nearly left my mobile phone in the code lol
void LED_UPDATE(int state)
{

int count; // initialized to zero, once program runs it automatically enter state ==1
if (state == 1)
{

    digitalWrite(RED_PIN, LOW);
    digitalWrite(GREEN_PIN, HIGH);
    count=0;
}
else if (state == 2)
{
  count+=1;
  Red_Blink();

  if(count == 1 )
  {
    sms.SendSMS("086XXXXXXX", "PANIC BUTTON PRESSED, Subject needs help!!!");
  }

}

Can you please add the code to sms.SendSMS(string phoneno,string msg)

You are resetting count every time you enter the function.
static int count; // initialized to zero, once.

Adding the static statement should initialise the variable once and preserve its value between calls.