text:
FreqMeasure.h uncompatible with my code problem
I have written code to read temperatures on a motor which also has pulse feedback to see speed, (one hall sensor) and my previous version of the code does work fine, however when i add example frequency code from codebender into my code it doesn't give feedback on the frequency. Standalone the frequency code works fine. Is there any obvious failure in the code or is there just some conflict between files in library?
Trying to return RPM into the SD card results in 0.00. And the temperature measurements goes into switching between 85C and -127C.
Equipment: Arduino Nano, DS18B20, 2x16 LCD, Homemade SD shield, motor with internal motordriver.
Here is my code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <SD.h>
#include <FreqMeasure.h>

// Data wire is plugged into pin 9 on the Arduino
#define ONE_WIRE_BUS 9

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

float temperature1, temperature2, temperature3;
double RPM;
void setup(void)
{
  // start serial port
  Serial.begin(57600);
  FreqMeasure.begin();
  Serial.println("Dallas Temperature IC Control Library Demo");
  // Start up the library
  lcd.begin(16, 2);
  sensors.begin();
  Serial.print("Initializing SD card...");      // Initialize SD card

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");   // Initialize SD card failed
    return;
  }
  Serial.println("initialization done.");       // Initialize SD card done
}

double sum=0;
int count=0;

void loop(void)
{
  if (FreqMeasure.available()) {
    // average several reading together
    sum = sum + FreqMeasure.read();
    count = count + 1;
    if (count > 30) {
      double frequency = F_CPU / (sum / count);
      RPM=frequency*60;
      sum = 0;
      count = 0;
    }
  }

  unsigned long curMillis = millis();
  unsigned long curSeconds = curMillis/1000;   // Get current seconds
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  temperature1=sensors.getTempCByIndex(0);
  temperature2=sensors.getTempCByIndex(1);
  temperature3=sensors.getTempCByIndex(2);
  logData();
  Serial.print("Temperature for Device 1 is: ");
  Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
  Serial.print("Temperature for Device 2 is: ");
  Serial.print(sensors.getTempCByIndex(1));
  Serial.print("Temperature for Device 3 is: ");
  Serial.println(sensors.getTempCByIndex(2));

  lcd.setCursor(0, 0);
  lcd.print("T1=");
  lcd.setCursor(3, 0);
  lcd.print(sensors.getTempCByIndex(0));
  lcd.setCursor(8, 0);
  lcd.print("T2=");
  lcd.setCursor(11, 0);
  lcd.print(sensors.getTempCByIndex(1));
  lcd.setCursor(0, 1);
  lcd.print("T3=");
  lcd.setCursor(3, 1);
  lcd.print(sensors.getTempCByIndex(2));
  lcd.setCursor(8, 1);
  lcd.print("S=");
  lcd.setCursor(10, 1);
  lcd.print(curSeconds);
    // You can have more than one IC on the same bus.
    // 0 refers to the first IC on the wire

}

void logData() {
  Serial.print("Temperature1 = ");   Serial.print(temperature1);    // Printing to serial communication
  Serial.print(" C, Temperature2 = ");  Serial.print(temperature2);       // Printing to serial communication
  Serial.print(" C, Temperature3 = ");  Serial.print(temperature3);       // Printing to serial communication
  Serial.println(" C");                                           // Printing to serial communication
  Serial.println(RPM);
  unsigned long curMillis = millis();          // Get current time
  unsigned long curSeconds = curMillis/1000;   // Get current seconds

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File myFile = SD.open("LOG.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to LOG.txt...");                        // Printing to serial communication
    myFile.print("Time = "); myFile.print(curSeconds);            // Printing to log file on sd card
    myFile.print(" Temperature1 = "); myFile.print(temperature1);   // Printing to log file on sd card
    myFile.print(" Temperature2 = "); myFile.print(temperature2);         // Printing to log file on sd card
    myFile.print(" Temperature3 = "); myFile.print(temperature3);       // Printing to log file on sd card
    myFile.print(" RPM = "); myFile.println(RPM);       // Printing to log file on sd card
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening LOG.txt");                      // Error either SD card not connected or not detected
  }
  delay(1000);
}

if (FreqMeasure.available() == false) then RPM is not initialised but it is used later on, this will produce odd results, but not the fault you see.
Also why keep calling sensors.getTempCByIndex(2) when you have written the values to Temperature3?

The repetition of 'sensors.getTempCByIndex(2)' is just a minor fault from my previous version of the code. And i have checked the 'FreqMeasure.available()' and it is false in the start but goes to some number between 1-11 during motor running, so should start running then.

Gísli - Sorry neither of the things I mentioned will fix you problem, I should have said that.  Yes sensors.getTempCByIndex(2) is a minor thing.  The RPM is  going to cause problems.  I will do an answer so I can explain.

I believe there is a conflict bewteen the code relative to the SD card, which uses SPI and the use of timer1 within FreqMeasure.
My advice is to temporarily remove the code for the SD card and write that data onto the serial console: if the data displays correctly on the serial monitor than you have an indication the issue is in there.
The problem with SPI and time based interrupts is the latter might prevent the SPI communication to properly complete.

Thanks for the idea, will check it out and then post if it is the problem.

The conflict is between the (OneWire.h DallasTemperature.h) and the FreqMeasure.h, tried the SD.h and all its variables and that was not the conflict however when i tried disabling the temperatures then the frequency worked fine.

This is an explanation of the issue with the RPM variable in the code, its not an answer, but it needs formatting to explain it clearly.
double RPM;
...
if (FreqMeasure.available()) {
...
  RPM=frequency*60;
...
}
...
Serial.println(RPM);

It is possible that RPM is going to be written to Serial.println() before it has a value set.
In this case it is very unlikely to cause anything more than 'garbage' to be printed, but it could be much worse.  So I think if you initialised the RPM variable to 0.0 when you declare it it would be good practice.

From what i have tested myself towards then it seems that the problem with this code is that OneWire.h and DallasTemperature.h are the problem when combined with FreqMeasure.h, so i found a way to use the A0 as RPM reader. So the answer to the question is that those libraries are uncompatible, and with the following code it is possible to read RPM, temperature and write to SD.
My code works with the added A0 as RPM reader.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <SD.h>

// Data wire is plugged into pin 9 on the Arduino
#define ONE_WIRE_BUS 9

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

float temperature1, temperature2, temperature3;
double RPM=0.0;
//storage variables
byte newData = 0;
byte prevData = 0;
//freq variables
unsigned int timer = 0;
unsigned int period = 0;
double frequency;

void setup(void)
{
  cli();  //disable interrupts
  ADCSRA = 0; //clear register
  ADCSRB = 0; //clear register

  ADMUX|=(1<<REFS0);  //Set reference voltage
  ADMUX|=(1<<ADLAR);  //left align the ADC value so we can read highest 8 bits from the ADCH register only
  ADCSRA|=(1<<ADPS2)|(1<<ADPS0);  //set ADC clock with 32 prescaler- 16mHz/32=500kHz
  ADCSRA|=(1<<ADATE); //enable auto trigger
  ADCSRA|=(1<<ADIE);  //enable interrupts when measurement is complete
  ADCSRA|=(1<<ADEN);  //enable ADC
  ADCSRA|=(1<<ADSC);  //start ADC measurement
  sei();  //enable interrupts

  // start serial port
  Serial.begin(57600);
  Serial.println("Dallas Temperature IC Control Library Demo");
  // Start up the library
  lcd.begin(16, 2);
  sensors.begin();
  Serial.print("Initializing SD card...");      // Initialize SD card

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");   // Initialize SD card failed
    return;
  }
  Serial.println("initialization done.");       // Initialize SD card done
}
ISR(ADC_vect){  //when new ADC value ready
  prevData = newData; //store previous value
  newData = ADCH; //get value from A0
  if(prevData<127 && newData>=127){ //if increasing and crossing midpoint
    period = timer; //get period
    timer = 0;  //reset timer
  }
  timer++;  //increment timer at rate of 38,5kHz
}

void loop(void)
{
  frequency = 38462/period; //timer rate/period
  RPM = frequency*60;
  unsigned long curMillis = millis();
  unsigned long curSeconds = curMillis/1000;   // Get current seconds
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  temperature1=sensors.getTempCByIndex(0);
  temperature2=sensors.getTempCByIndex(1);
  temperature3=sensors.getTempCByIndex(2);
  logData();

  lcd.setCursor(0, 0);
  lcd.print("T1=");
  lcd.setCursor(3, 0);
  lcd.print(temperature1);
  lcd.setCursor(8, 0);
  lcd.print("T2=");
  lcd.setCursor(11, 0);
  lcd.print(temperature2);
  lcd.setCursor(0, 1);
  lcd.print("T3=");
  lcd.setCursor(3, 1);
  lcd.print(temperature3);
  lcd.setCursor(8, 1);
  lcd.print("S=");
  lcd.setCursor(10, 1);
  lcd.print(curSeconds);
    // You can have more than one IC on the same bus.
    // 0 refers to the first IC on the wire

}

double sum=0.0;
int count=0;

void logData() {
  unsigned long curMillis = millis();          // Get current time
  unsigned long curSeconds = curMillis/1000;   // Get current seconds
  Serial.print("Time="); Serial.print(curSeconds);
  Serial.print(" Temperature1 = "); Serial.print(temperature1);
  Serial.print(" Temperature2 = "); Serial.print(temperature2);
  Serial.print(" Temperature3 = "); Serial.print(temperature3);
  Serial.print(" RPM = "); Serial.println(RPM);
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File myFile = SD.open("LOG.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to LOG.txt...");                        // Printing to serial communication
    myFile.print("Time = "); myFile.print(curSeconds);            // Printing to log file on sd card
    myFile.print(" Temperature1 = "); myFile.print(temperature1);   // Printing to log file on sd card
    myFile.print(" Temperature2 = "); myFile.print(temperature2);         // Printing to log file on sd card
    myFile.print(" Temperature3 = "); myFile.print(temperature3);       // Printing to log file on sd card
    myFile.print(" RPM = "); myFile.println(RPM);       // Printing to log file on sd card
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening LOG.txt");                      // Error either SD card not connected or not detected
  }
  delay(100);
}


text:
Need help with 2X3 matrix for braille
I'm an intermediate Arduino progammer, and I'm making an electronic braille display for my friend. You can think of this display as an array of 28x3 LEDs(one braille character contains a maximum of six (2x3 for one letter) dots so there can be 14 characters displayed at a time, including spaces) but actually instead of LEDs, there will be electrical braille cells. This will be the algorithm:

Read string (English alphabet) files from SD card
Count the letters, including spaces, until it becomes 14. Convert them into braille (2x3 for one letter) and then display them (as we will be able to display only 14 letters at a time )
When the user presses the button for the next row/page do the same process(step 2) for the next string.

So this is the complete process I want to do.
I have 5 months deadline to make it. The main problem is how I can make the code to convert and then display it. I know there are already a lot of Arduino libraries out there for displaying stranded English characters, but this is different, because I'm new to Arduino and 'C'.
Instead of losing your mind and saying this site is not for fool people like you, please guide this 17yr old what should I learn in order to make this for my friend who lost his eyesight in an accident(consider I have time of 5 months).
Do I have to build entire new Library for converting alphabet and multiplexing braille? Or is there existing code that will work.

Do you have a conceptual prototype in a language you do know?

no this will be the first time

Well, that would be a good starting point.

Why would you want braille on a display? Doesn't that defy the purpose of braille itself? Anyway, Arduino is capable of recognizing characters in an array. You simply then need to check which char it is, then display the associated dots. I suggest googling some of these things: read sd card string to char arduino, or something like this. Then find a tutorial for a display and start writing the code for only 1 letter. This way you can check if it works, if it does you can make the code for all the other letters and punctuation.

A lot of display libraries have a way to define custom font. Just create a font that shows braille dot

that will solve my complete problem, please can you tell me where can I find those libraries?

@Len He had already described that the Braille display was a 'cell'. For your information, one cell is a 2x3 element that raises different physical pins for the reader to feel with their fingertips. But for non-Braille people, he likened this cell to an LED display - very clever of him actually!

@JohnBurger Oh, that is actually pretty cool. Thanks for information :)

First of all, may I say "Thank you" for helping your friend like that? I cannot think of a better way to use an Arduino than as a driver for a Braille display like you describe!
As you know, Braille is a representation of characters into a "shape" that many systems don't recognise. Most people only encounter Braille when they press a button on an elevator or an ATM and see raised dots. Nevertheless, this is MUCH easier than the system that deaf people use: they represent whole words with a hand gesture.

I hereby challenge EVERY reader of this post to enter an elevator, or look at an ATM, and notice (and decode!) the Braille dots on the buttons. Elevators for some reason use the double coding "#1", "#2", "#3" etc. (as described in the question's graphic) when it is clearly unnecessary - of course you want to press a floor number! ATM buttons just use the 'raw' number pattern.

Because in Braille each character is converted into its own representation, you can do a VERY simple conversion. If you think about it, it is happening in computers trillions of times a day: when a computer converts a keypress into a set of pixels that represent the character on a computer screen. Your "pixels" are just a WHOLE lot simpler than the 5x7, 13x15 or font-specific conversion for the characters that normal-sighted people see.
The first thing that you need to do is define a system that converts the 2x3 array into an array of bits. Why? To make storage easier. I'm going to represent the Braille cell with a set of digits from 0 to 5:
 0   1
 2   3
 4   5

Why? Because it is then possible to "compress" the representation into a single byte of data. If you know computing well enough, you know that it runs in binary, and each digit above can be represented in a single bit, numbered 0-5.
Thus A is represented by raising the top left pin, which is the same as bit 0: which can be represented by the byte B000001 or 0x01:
X .
. .
. .

Of course a space, with nothing raised, would be represented by B000000 or 0x00.
You may not know this, and most computing people wouldn't either: the next "obvious" encoding (for B) would be B000010 or 0x02:
. X
. .
. .

But a blind person would have a serious difficulty in decoding this, since in isolation (no way of interpreting the "down" pins) it would look exactly like an 'A'. So the fact that 'B' is encoded as:
X .
X .
. .

means that the binary encoding would be B000101 or 0x05.
As a further example, the character 'I' would be
. X
X .
. .

or the byte B000110 or 0x06.
I'm not going to convert every character, but I hope that this explains things well enough for you. By giving every character its own bit pattern, you can then convert any possible string into a set of bytes for conversion by your library.
Only... there's a problem. With Braille, you need to convert numbers 0 to 9 into a special pattern. Because Braille only has 6 'bits' to choose from (and even then not every combination is "nice" for blind people to read), there is a special "flag" character to say "the following characters are digits!" (and a pattern to say "OK, back to normal letters again").
This means that there is not a one-to-one translation between an English string of characters, and the resultant string of bytes to represent those characters in Braille: you need to add extra "convert" bytes to the process. Of course these "convert" bytes can also be represented by the same bitmap as described above:
. X
. X
X X

is equal to B111010 or 0x3A.
That means that it is possible to write a function to convert a series of ASCII characters into a series of Braille bytes: you just need to provide more bytes than the string converts! This also means that you may need to use less than 14 characters from the source before you run out of room on the display...
I would love to give you my address for more help: I'm afraid that StackExchange won't let me post my e-mail address!

The elevator buttons being marked with '#1', '#2', etc could be to distinguis between say the 'Bottom/Basement' floor and the '2nd' floor.

@TwoD That makes sense! Very few elevators here have anything but numbers. I do remember seeing all sorts of things in the US - "Mezzanine", "Banquet", etc - although I don't remember the Braille (if any) those buttons had.

Each character will be 6 bits (so let's use a byte to store it) and we'll use the following bit to LED mapping
bit0   bit1
bit2   bit3
bit4   bit5

Now you just need an array of bytes where each byte signifies an ASCII character.
Your code will get the letters to display and for each one will do something like this:
byte BrailleBytes[] = {0x01, 0x05, 0xD, etc etc}; // only done the first 3 chars

byte getBrailleForCharacter(char c)
{
    int index = asc(c) - asc('A');
    return BrailleBytes[index];
}

The key to decoding it this way is to make sure you sequence your bytes in BrailleByte the same way the ASCII table does - so if you want punctuation/numbers etc then you'll have to start lower and adjust the asc('A') accordingly
Now you have the byte it is just a case of checking what bits are set and turning on the relavant LEDs.

thank you very much for answering my queries, considering I'm a beginner in arduino programming, is there any book which is specifically designed for arduino programming which can help me learning or should I just focus on normal C programming courses so that I'll be able to understand and build complex codes?

https://www.arduino.cc/ is probably the best place - lots of tutorials available.

source: Stack Exchange

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

sort: votes


text:
Arduino Rubber ducky?
So there is this hacking tool called a rubber ducky , the concept is that the device looks like a flash drive but the computer thinks it's a keyboard . According to what i know , a usb port has 4 wires , VCC GND and 2 for data , so i thought if it was possible to take a usb cable , cut it and connect it to the arduino accordingly , and send the computer that data so that he would think i connected a keyboard , and basicly create a fake reprogrammable keyboard

You mean buy an Arduino Leonardo or Arduino Micro and plug it in?

You can fake a keyboard using VUSB for AVR.

@Gerben I would never touch a solution like that even with someone else's barge pole. Bit-banged USB is very very nasty, and a 5V (non-USB) Arduino doesn't have a suitably compatible electrical interface to USB which risks damaging your hub or computer.

Most Arduinos can't be a USB keyboard (not without some really nasty bit-banging code and dodgy electronics).
Some can, though - such as the Arduino Leonardo or the Arduino Micro. And you don't need to cut any cables, you just plug it in.

i meant like if i take a usb cable and cut it and connect the according wires of the usb cable to the arduino and sending data , any chance the computer can see this data and think a keyboard or mouse has been connected ?

Why take a cable and cut it? Just plug it direct into an Arduino that is designed for the job!

I mean sending raw data , since when i connect and arduino , it sends the pc certain bytes that tell the pc that is an arduino , but i want to trick the pc  into thinking that is a keyboard

So you mean plugging in an Arduino that is designed for the task, like the Arduino Leonardo or Arduino Micro? Do you actually have the faintest clue what an Arduino Leonardo or Arduino Micro actually are?

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


text:
While condition with & bitwise of PINx read
I was looking into ATmega32u4 datasheet to configure the SPI, and there is initialization snippet for data transmission.
void SPI_MasterTransmit(char cData)
{
    /* Start transmission */
    SPDR = cData;
    /* Wait for transmission complete */
    while(!(SPSR & (1<<SPIF)));
}

What I didn't quite get is the last line of the snippet with the while condition to check the state of the SPIF bit in SPSR register.
What I think I understand that it means, if SPIF bit with the a conditional value of 1 which would be in the ALU for comparing it with the actual bit state in SPSR. If this is true with & bitwise operator which would be true if the actual bit in the SPSR is set with the given value (1 << SPIF).
My questions:

Am I understanding it right?
What this line actually means?
I have removed the semicolon at the end of the line and it compiled OK! Is what I did OK?

I prefer to write it like while(!(SPSR & (1<<SPIF))){}; (with curly braces). In essence it just wait till the SPIF bit in the SPSR register is set. Removing the semicolon probably only worked because it was the last line of the function.

It won't compile for me if I omit the last semicolon: “error: expected ‘;’ before ‘}’ token”.

I tried this one with the curly braces, and it didn't work actually. The one with only semicolon surprisingly work. Which is a new technique for me. I know also you can perform if condition with no curly braces and it would activate only the next line of code. So this while technique with or without curly braces is new to me. So yeah thanks :)

After some testing with a code with IO pins. I discovered that there is another command which would do the same as while (condition); which is if (condition){ } and if (condition) without curly braces. So the while with the semicolon and the if with the curly braces! OK sounds good to me now :) Thanks all for help.

SPI transmitt is started by writing one Byte into SPDR. And this code won't return from SPI_MasterTransmit function before it's complete. Transmitt completition is anounced by setting SPIF by hardware (and if SPI interrupt and global interrupts are enabled, it'll run also ISR and clear that flag).
If you write into SPDR before transmission is completed you'll corrupt current "transaction", so you have to wait until it's complete before another write.
Bitwise & is used for bit masking. Bits in the result are set if bits at corresponding positions in arguments are both set:
0b00110011
         &
0b00100001
        ==
0b00100001

So if bit at position SPIF is not set, it will loop again and when it's set, it exits the loop, as there is inverted logic.
( SPSR     & (1<<SPIF))                    !(SPRS &(1<<SPIF))
0b0xxxxxxx & 0b10000000 == 0b00000000  =>  !0b00000000 == true
0b1xxxxxxx & 0b10000000 == 0b10000000  =>  !0b10000000 == false

OK First, the SPIF would be set always whether SPIE is enabled or not. So, in this piece of code the while condition is at the end of the transmit function, would the while condition work the same whether the SPIE is set or not? If this it would work the same because it's connected with a bit mask of SPIF and SPSR. If the SPIE is enabled then the interrupt request would take another action other than while condition.

@PerchEagle Well, if SPIE and global interrupts are enabled, it might result into infinite loop or not executing ISR. Depends how ISRs are done in hardware when you clear that flag before entering ISR (few clock cycles). So if you have interrupt driven transmission, you can write it into the buffer and ISR will send it..

OK, so if I want an interrupt then I have to remove the while line of code and apply another code with enabling SPIE and ISR handling. Correct? So the technique here it that they don't require an interrupt for SPI TX completion so they only doing it by checking SPIF with requirement for ISR.

If you want interrupt driven SPI, you'll need buffer, buffer size, ISR handler that will send next character from buffer and decrements size and maybe CS pin number to release it at the transaction end. The first character must be sent in transfer request (which adds rest of the data into buffer and sets correct size)

OK I'm doing testing with IO pins all configured as outputs with one pull-up pin and drive the other two to high with testing different while & if code configurations: So, 1. while (condition); code >> drive o/p pins from low to high 2. while (condition){code} >> do the opposite drive them from high to low 3. if (condition) {code} >> drive high to low 4. if (!(condition)){code} >> drive low to high >>>> so the only two which works as I want are while (condition); code & if(!(condition)){code}, but I don't understand how they work?!

I think you should take a look to this tutorial.

OK thank you :) That's a good one I have to learn more later on that PDF. So, I have another question I don't know if it's suitable to post it here or in a new thread. Which is about SPI return on MISO. I read in a PDF file that that same SPI code provided in the datasheet, which is: void SPI_TX(char data){ SPDR = data; while (!(SPSR & 0x80)); <<< which has to end in this arrangement, and the author of the PDF file added a last line which is return SPDR as to be read on MISO } >> how this works? is it that SPI automatically receive on MISO after transmission completion?

The SPI is Full Duplex protocol and only the Master is allowed to send Clock signal. So, if the Master wants some data from the Slave, dummy bytes must be sent.

I'm sorry I forgot to mention that I'm applying SPI loopback technique to test SPI functionality. What I'm wondering about is if I apply loopback, then how it works, as the code shows that the author added the return SPDR at the end of TX function, would that actually works? when the MOSI is directly connected to MISO of the same board? Is SPI actually after you send data the MISO get active to receive data, when you actually didn't configure the SPI module to receive data while you're in Master Mode?

I mean if you're the master, how would you read the returned data coming from the slave on the master's MISO pin?

Interrupt signal from slave or polling on master.

I didn't understand how to work with SPI, so I'm posting another thread about how to use SPI for sending data from master and perform a simple blink on slave. Thank you very much :)

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


text:
Is there a library to use Amazon IoT services on any Arduino?
I started to work with AWS IoT today, which offers a MQTT based connection to their web service. They officially only have a demo for the Arduino Yún, which is rather expensive. Has someone managed to get it running (e.g. with a NodeMCU with a ESP8266)?

Any comments from the downvoter?

You can try the AWS IoT Embedded C SDK, that is for more general devices.
Other Arduinos requires a crypto library and a device powerful enough, maybe PI, to support the authentication process...
At this time they have no crypto library like the YUN SDK, for other Arduinos...
Try it...


text:
How do I program my Arduino Yun Shield when I keep getting this AVRDUDE error message?
The error message is:

avrdude: AVR device initialized and ready to accept instructions
  avrdude: Device signature = 0x1e950f
  avrdude: Expected signature for ATmega32U4 is 1E 95 87
  Double check chip, or use -F to override this check.

This error message is thrown when I attempt to upload any program to the Yun shield through an Arduino Bridge between the Uno and Yun shield with the Uno’s ATMega32 shorted into reset mode.
Any advice on how to get this working? Thanks.

Make sure the board selected in the Yun Shield is the correct one (in this case Arduino UNO).
Steps for selecting the board on the Yun Shield

In your web browser load the Yun Shield page and log in (how to do this is described in the Quick Start Guide).
Click on the SENSORS menu button.
Under Arduino Board Type select the correct one.
Click on the CONFIGURE & RESTART MCU button to apply settings.
Maybe manual restart of the board would be needed (power unplug).

Apparently there is no ATMega32U4 on that board but ATmega328P according to the signature 0x1e950f.
Anyway, you may have to change or add new board with correct MCU setting.
Now I can see the difference between Yun and Yun shield. Shield can be connected to any Arduino board and Yun is similar like Shield + Leonardo.
I've found board definition for Arduino UNO:
unoyun.name=Arduino Uno -- Dragino Yún
unoyun.upload.via_ssh=true

unoyun.vid.0=0x2341
unoyun.pid.0=0x0043
unoyun.vid.1=0x2341
unoyun.pid.1=0x0001
unoyun.upload.tool=avrdude
unoyun.upload.protocol=arduino
unoyun.upload.maximum_size=32256
unoyun.upload.maximum_data_size=2048
unoyun.upload.speed=57600
unoyun.upload.disable_flushing=true
unoyun.upload.use_1200bps_touch=true
unoyun.upload.wait_for_upload_port=true

unoyun.bootloader.tool=avrdude
unoyun.bootloader.low_fuses=0xff
unoyun.bootloader.high_fuses=0xde
unoyun.bootloader.extended_fuses=0x05
unoyun.bootloader.file=optiboot/optiboot_atmega328.hex
unoyun.bootloader.unlock_bits=0x3F
unoyun.bootloader.lock_bits=0x0F

unoyun.build.mcu=atmega328p
unoyun.build.f_cpu=16000000L
unoyun.build.board=AVR_YUN
unoyun.build.core=arduino
unoyun.build.variant=standard

More info about it here: https://www.arduino.cc/en/Guide/ArduinoYunShield or similar product http://wiki.dragino.com/index.php?title=Yun_Shield

So there may be a chance that the reset and gnd pins aren't shorted?  Definitely not a clone btw - original Uno, and I've got the bill to prove that...

@Raihaan Yeah, I've noticed the difference between Yun shield and Yun, so it's updated now.

Ah.. I tried adding this to my boards.txt file but it wouldn't let me make changes as an admin... I also used another installer to install these definitions onto the IDE (the dragino yun shield with arduino uno) but same error... I tried it with an Arduino 101 too, but that's not an AVR board so didn't really expect that to work...


text:
Unable to analogWrite to MOSFET properly (IRLB3034)
I've got a 5 meter LED strip connected to a breadboard as such
12V Supply
(+) -> (+) on breadboard rail
(-) -> ground on breadboard rail
Arduino (Wemos D1, all pins w/ PWM)
pin7 -> gate(1st MOSFET)
pin8 -> gate(2nd MOSFET)
pin9 -> gate(3rd MOSFET)
GND -> ground on breadboard rail
MOSFETs (IRLB3034 equivalent)
Gates (already explained)
Drain(1st MOSFET) -> Red line on WS2812 strip
Drain(2nd MOSFET) -> Green line on WS2812 strip
Drain(3rd MOSFET) -> Blue line on WS2812 strip
Source(all MOSFETs) -> (-) on breadboard
And despite this, when I run an extremely simple program such as this, I get white light (all being lit up), and can never individually address a color. I can write all to 0 and will still have a white light, same with writing all to 255, and same again with writing one or two to 255 and the remainder to 0.
int redPin = 7;
int bluePin = 8;
int greenPin = 9;

void setup() {

}

void loop() {
  analogWrite(redPin, 255);
  analogWrite(bluePin, 0);
  analogWrite(greenPin, 0);

}

I'm thinking my AliExpress board may just be faulty, advertising PWM on every pin when that is not the case, or I may have selected the wrong MOSFETs for this application. Using this identical setup (same breadboard, same MOSFETs) with my Raspberry Pi 2B I was able to change the color of the lights.
Hoping someone here has worked with the Wemos D1 and can help. The documentation on this board seems to indicate that everything should be working, but it is not. I have two boards (same seller) and can confirm that it works with neither.

"Red line on WS2812 strip" Uh... WS2812 only have power and data.

You say “with my Raspberry Pi 2B I was able to address the lights individually” ... was the program the same?  Or perhaps you used a WS2812 library on the Raspberry?  Anyhow, each WS2812 has a chip that PWM's the lights; they aren't intended for external PWM.

A schematic (instead of the text) would greatly improve the quality of your question.

Please supply some details on the LED strip you have and how it is powered since it's clearly not WS2812's.

Unfortunately the WS2812 LEDs color is set by powering it up and sending data to it. This means that you don't need the FETs at all.
Sparkfun have a really good walkthrough for hooking up and controlling these LEDs:
WS2812 Breakout Hookup Guide
To achieve what you set out to do (ie controlling the color with the FETs) you will need a different analog LED strip (such as this). Adafruit have a really good walkthrough for hooking up and controlling the LEDs in this fashion.
Controlling Analog RGB LED Strips

The setup duplicates this ( http://popoklopsi.github.io/RaspberryPi-LedStrip/#!/ ) to a T. The strip I have is non-addressable, and needs about 5A to power it when R,G, and B are at full throttle. Unfortunately none of the examples in that Sparkfun link apply to my case, as each refer to individually addressable strips. The way I understood it was that the lines each carry 12v and use the PWM to dim/brighten each color individually, hence the MOSFET.
This has worked before in an identical setup, with the only change being using a RPi instead of the Wemos.

Are you sure that the LED strip is using WS2812 LEDs. According to the datasheet (https://cdn-shop.adafruit.com/datasheets/WS2812.pdf) it is controlled by digital data.

@Logan Halloran, thanks for the link. Just to prove that your circuit works, have you tried the program controlling the I/O digitally (ie. digitalWrite())?  You may need to add a pull down resistor to the gate of the FETs. Something like this: https://github.com/freetronics/NDriveModule/raw/master/NDRIVE_NDriveModule.pdf


text:
How to power two stacked motor shields with one 3S Lipo battery (11.1V)?
I have these 2 motor shields:
Adafruit Motor Shield V2 and
Seed Motor Shield V2.
They are stacked on top of an Arduino UNO.
My question is, how can I power 2 of those motor shields with one 3S Lipo battery(Turnigy 3S 2200mAh 20C), given that I have 6 identical 4.6-6V DC gearmotors?
Thanks!

Get a UBEC (switching buck regulator) for 5V with enough current to drive the motors. Turnigy do some good ones.

Could you provide links to the gear you are using?

Buck regulator as Majenko says is best with battery you have. BUT better is probably a 2S LiIon and linear regulator - only if you are willing to change battery.

@RussellMcMahon Why linear? Isn't that wasteful of energy? A buck regulator will increase the current availability from the batteries, but a linear won't. 6 motors could be quite thirsty on current, especially stall current...

@Majenko Note that I suggested linear only with 2S LiIon. 2S range is say 6V - 8.4V with most energy in say 6.4-8V range or maybe 7.8V. AT 8V to 6V linear regulator gives 75% efficiency. At mid range of say (8+6.4)/2 = 7.1V efficiency at 6V out is 6/7.1 = 85%. Buck is better than that across range but if you want usefully high stall currents then a linear reg that handles 1 or 2 or 4 A is a doddle. Buck is not overly hard but harder. Simplicity wise linear is nice. Losses per amp are 2W at 8V and 0.4W at 6.4V. IF gearmotors allow slightly >6V they may allow 2S directly.

@RussellMcMahon Note that I recommended a UBEC specifically - that is a single module with battery input and 5V output. Not a single component or a circuit you have to build. They are designed for model vehicle enthusiasts, and I even recommended one by the same manufacturer as the battery (I use the same make myself as it happens). No messing with components or circuitry, just wire it up and away you go. You can't get simpler than that - even simpler than wiring your own linear with all that messing with capacitors ;)

@sa_leinad Sure: https://www.amazon.com/Seeed-motor-shield-for-Arduino/dp/B00KAE2B3U/ref=sr_1_1?ie=UTF8&qid=1475012972&sr=8-1&keywords=seeed+motor+shield https://www.amazon.com/gp/product/B00PUTH3B0/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1 and https://www.amazon.com/gp/product/B0072AEY5I/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

@Majenko Thank you so much! So if I want to power those two motor shields at the same time, I would need two UBECs?

It depends on the current capacity of the UBEC and the current requirements of the motors. If one UBEC can provide enough current then you can power both shields off one UBEC - just connect the output of the UBEC to both shields.

@Majenko  there are 6 identical motors (each takes max 250mA and min 190mA). First motor shield will control 2 motors (or 500mA) and second one will control 4 motors (or 1A). Would this 3A  UBEC do the job? Thank you again!

Yep, that would do it fine - and still leave you plenty of capacity to also power the Arduino as well if you like.

@Majenko Sweet, I ordered it. I will post the results. Thanks!

You can avoid using a linear voltage regulator. Try using this voltage regulator.
You will get 5 Volts 2 Amp output which should be easy to connect to motor shield's input power ports.

Thanks. How is this different from UBEC suggested by @Majenko ?

No, you really don't want to run a motor on a regulator.  Choose an appropriate power source, use a regulator for the electronics and use PWM to deliver an appropriate amount of power to the motors.


text:
How to properly understand verbose compiler error text? For beginner level
I'm an Arduino newbie, no background in C/C++, needing help to understand Arduino IDE verbose output about compiler errors. My searching failed to find suitable info - have I missed a relevant guide?
Below example of compiler errors produced when I try to compile Example sketch (TestRTC) from a downloaded library. I assume this Example code is valid. Guessing that my errors relate to missing components. The library was one of two recommended in answer to question. I used IDE Manage Libraries to install from downloaded zip files. Windows file manager shows both library folders are present.
In example below: Which components did the compiler find/not find? Where did compiler search for needed components? What other useful info could be gleaned from this error output?
Would be very grateful for general advice on interpreting error text as well as this particular example. Many thanks.
Arduino: 1.6.11 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\jdocs\00_arduino\duinosketches\libraries -fqbn=arduino:avr:uno -ide-version=10611 -build-path C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\jdocs\00_arduino\duinosketches\libraries -fqbn=arduino:avr:uno -ide-version=10611 -build-path C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino
Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\Wire.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master\DS3232RTC.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp" -o "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master" "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp" -o "C:\Users\Jules\AppData\Local\Temp\build8b85ae284f2ad840f4c667e76a0588ca.tmp\sketch\TestRTC.ino.cpp.o"
In file included from C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino:49:0:

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:82:22: error: 'tmElements_t' has not been declared

     static void read(tmElements_t &tm);

                      ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:83:23: error: 'tmElements_t' has not been declared

     static void write(tmElements_t &tm);

                       ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:84:27: error: 'tmElements_t' has not been declared

     static void writeTime(tmElements_t &tm);

                           ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:85:27: error: 'tmElements_t' has not been declared

     static void writeDate(tmElements_t &tm);

                           ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:87:61: error: 'tmElements_t' has not been declared

     static void readAlarm(uint8_t alarm, alarmMode_t &mode, tmElements_t &tm);

                                                             ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:88:61: error: 'tmElements_t' has not been declared

     static void writeAlarm(uint8_t alarm, alarmMode_t mode, tmElements_t tm);

                                                             ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:110:24: error: 'tmElements_t' has not been declared

     static void _wTime(tmElements_t &tm);

                        ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:111:24: error: 'tmElements_t' has not been declared

     static void _wDate(tmElements_t &tm);

                        ^

TestRTC:79: error: 'tmElements_t' does not name a type

 inline uint8_t monthLength(const tmElements_t *date)

                           ^

TestRTC:297: error: 'tmElements_t' does not name a type

 void printAlarm(byte alarmNum, const alarmMode_t mode, const tmElements_t time)

                                                              ^

TestRTC:79: error: 'tmElements_t' does not name a type

 inline uint8_t monthLength(const tmElements_t *date)

                                  ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: In function 'uint8_t monthLength(const int*)':

TestRTC:81: error: request for member 'Month' in '* date', which is of non-class type 'const int'

     if (date->Month != 2 || !isLeapYear(date->Year))

               ^

TestRTC:81: error: request for member 'Year' in '* date', which is of non-class type 'const int'

     if (date->Month != 2 || !isLeapYear(date->Year))

                                               ^

TestRTC:82: error: request for member 'Month' in '* date', which is of non-class type 'const int'

         return monthLengths[date->Month - 1];

                                   ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: In function 'void cmdTime(const char*)':

TestRTC:213: error: 'tmElements_t' was not declared in this scope

     tmElements_t tm;

     ^

TestRTC:218: error: expected unqualified-id before '.' token

         tm.Hour = readField(args, posn, 23);

           ^

TestRTC:219: error: expected unqualified-id before '.' token

         tm.Minute = readField(args, posn, 59);

           ^

TestRTC:221: error: expected unqualified-id before '.' token

             tm.Second = readField(args, posn, 59);

               ^

TestRTC:223: error: expected unqualified-id before '.' token

             tm.Second = 0;

               ^

TestRTC:224: error: expected primary-expression before '.' token

         if (tm.Hour == 99 || tm.Minute == 99 || tm.Second == 99) {

               ^

TestRTC:224: error: expected primary-expression before '.' token

         if (tm.Hour == 99 || tm.Minute == 99 || tm.Second == 99) {

                                ^

TestRTC:224: error: expected primary-expression before '.' token

         if (tm.Hour == 99 || tm.Minute == 99 || tm.Second == 99) {

                                                   ^

TestRTC:228: error: expected primary-expression before ')' token

         RTC.writeTime(tm);

                         ^

TestRTC:233: error: expected primary-expression before ')' token

     RTC.read(tm);

                ^

TestRTC:234: error: expected primary-expression before '.' token

     printDec2(tm.Hour);

                 ^

TestRTC:236: error: expected primary-expression before '.' token

     printDec2(tm.Minute);

                 ^

TestRTC:238: error: expected primary-expression before '.' token

     printDec2(tm.Second);

                 ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: In function 'void cmdDate(const char*)':

TestRTC:245: error: 'tmElements_t' was not declared in this scope

     tmElements_t tm;

     ^

TestRTC:256: error: expected unqualified-id before '.' token

         tm.Day = (byte)(value % 100);

           ^

TestRTC:257: error: expected unqualified-id before '.' token

         tm.Month = (byte)((value / 100) % 100);

           ^

TestRTC:258: error: expected unqualified-id before '.' token

         tm.Year = CalendarYrToTm( (unsigned int)(value / 10000) );

           ^

TestRTC:259: error: expected primary-expression before '.' token

         if (tm.Month < 1 || tm.Month > 12) {

               ^

TestRTC:259: error: expected primary-expression before '.' token

         if (tm.Month < 1 || tm.Month > 12) {

                               ^

TestRTC:263: error: expected primary-expression before ')' token

         uint8_t len = monthLength(&tm);

                                      ^

TestRTC:264: error: expected primary-expression before '.' token

         if (tm.Day < 1 || tm.Day > len) {

               ^

TestRTC:264: error: expected primary-expression before '.' token

         if (tm.Day < 1 || tm.Day > len) {

                             ^

TestRTC:269: error: expected primary-expression before ')' token

         RTC.writeDate(tm);

                         ^

TestRTC:274: error: expected primary-expression before ')' token

     RTC.read(tm);

                ^

TestRTC:275: error: expected primary-expression before '.' token

     if (tm.Wday > 0) Serial.print(days[tm.Wday - 1]);

           ^

TestRTC:275: error: expected primary-expression before '.' token

     if (tm.Wday > 0) Serial.print(days[tm.Wday - 1]);

                                          ^

TestRTC:276: error: expected primary-expression before '.' token

     Serial.print(tm.Day, DEC);

                    ^

TestRTC:277: error: expected primary-expression before '.' token

     Serial.print(months[tm.Month - 1]);

                           ^

TestRTC:278: error: expected primary-expression before '.' token

     Serial.println(tmYearToCalendar(tm.Year), DEC);  // NB! Remember tmYearToCalendar()

                                       ^

TestRTC:278: error: 'tmYearToCalendar' was not declared in this scope

     Serial.println(tmYearToCalendar(tm.Year), DEC);  // NB! Remember tmYearToCalendar()

                                            ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: At global scope:

TestRTC:297: error: 'tmElements_t' does not name a type

 void printAlarm(byte alarmNum, const alarmMode_t mode, const tmElements_t time)

                                                              ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: In function 'void printAlarm(byte, alarmMode_t, int)':

TestRTC:324: error: request for member 'Second' in 'time', which is of non-class type 'const int'

             printDec2(time.Second);

                            ^

TestRTC:328: error: request for member 'Minute' in 'time', which is of non-class type 'const int'

             printDec2(time.Minute);

                            ^

TestRTC:330: error: request for member 'Second' in 'time', which is of non-class type 'const int'

             printDec2(time.Second);

                            ^

TestRTC:336: error: request for member 'Day' in 'time', which is of non-class type 'const int'

               Serial.print(time.Day);

                                 ^

TestRTC:340: error: request for member 'Wday' in 'time', which is of non-class type 'const int'

               Serial.print(days[time.Wday - 1]);

                                      ^

TestRTC:343: error: request for member 'Hour' in 'time', which is of non-class type 'const int'

             printDec2(time.Hour);

                            ^

TestRTC:345: error: request for member 'Minute' in 'time', which is of non-class type 'const int'

             printDec2(time.Minute);

                            ^

TestRTC:347: error: request for member 'Second' in 'time', which is of non-class type 'const int'

             printDec2(time.Second);

                            ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: In function 'void cmdAlarms(const char*)':

TestRTC:359: error: 'tmElements_t' was not declared in this scope

     tmElements_t time;

     ^

TestRTC:362: error: no matching function for call to 'DS3232RTC::readAlarm(byte&, alarmMode_t&, time_t (&)(time_t*))'

         RTC.readAlarm(alarmNum, mode, time);

                                           ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino:362:43: note: candidate is:

In file included from C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino:49:0:

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:87:17: note: static void DS3232RTC::readAlarm(uint8_t, alarmMode_t&, int&)

     static void readAlarm(uint8_t alarm, alarmMode_t &mode, tmElements_t &tm);

                 ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:87:17: note:   no known conversion for argument 3 from 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' to 'int&'

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino: In function 'void cmdAlarm(const char*)':

TestRTC:373: error: 'tmElements_t' was not declared in this scope

     tmElements_t time;

     ^

TestRTC:391: error: request for member 'Hour' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'

             time.Hour = readField(args, posn, 23);

                  ^

TestRTC:392: error: request for member 'Minute' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'

             time.Minute = readField(args, posn, 59);

                  ^

TestRTC:393: error: request for member 'Hour' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'

             if (time.Hour == 99 || time.Minute == 99) {

                      ^

TestRTC:393: error: request for member 'Minute' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}'

             if (time.Hour == 99 || time.Minute == 99) {

                                         ^

TestRTC:417: error: no matching function for call to 'DS3232RTC::readAlarm(byte&, alarmMode_t&, time_t (&)(time_t*))'

     RTC.readAlarm(alarmNum, mode, time);

                                       ^

C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino:417:39: note: candidate is:

In file included from C:\Users\Jules\AppData\Local\Temp\arduino_modified_sketch_461291\TestRTC.ino:49:0:

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:87:17: note: static void DS3232RTC::readAlarm(uint8_t, alarmMode_t&, int&)

     static void readAlarm(uint8_t alarm, alarmMode_t &mode, tmElements_t &tm);

                 ^

C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:87:17: note:   no known conversion for argument 3 from 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' to 'int&'

Multiple libraries were found for "DS3232RTC.h"
 Used: C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master
 Not used: C:\Program Files (x86)\Arduino\libraries\RTC
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library DS3232RTC-master in folder: C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master (legacy)
exit status 1
'tmElements_t' does not name a type

The problem is that one error leads to 100’s of error messages. But usually you can trace it back to one single problem. After fixing one thing, you should re-compile, and check what errors persist (or are new ;p). You shouldn't always take the errors too literally, just re check the parts around the error and then the parts related to that.

As @st2000 said, it's best to start with the first error shown as that error may be causing other errors that will go away once you fix the first one. You should be aware of the difference between warnings and errors. Warnings may or may not be related to the error preventing your code from compiling so I'd just focus on the error at first. So scroll the console window all the way up and then start reading down until you find the first error. If the output is very long you may find it useful to copy the output and paste into a text editor then do a search for the word error, starting from the beginning of the file.
In your compiler output the first error listed is:
C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h:82:22: error: 'tmElements_t' has not been declared

     static void read(tmElements_t &tm);

                      ^

The first thing we can learn from this is the file where the error occurred:
C:\jdocs\00_arduino\duinosketches\libraries\DS3232RTC-master/DS3232RTC.h

The next part of the error message is:
:82:22

This means that the error occurred at line 82, column 22 of the file DS3232RTC.h. This makes it easy for you to find that code in the file. Any decent text editor will show the current line number and column at the cursor.
The next part of the error message is a description of the problem:
error: 'tmElements_t' has not been declared

Often you may not understand exactly what it means. This is where your favorite search engine comes in handy. You can try searching for "'tmElements_t' has not been declared". The 'tmElements_t' part is very specific to this code so you will get less results but they may lead you to others who have had the same problem and the solutions they found.
Searching for the general error "has not been declared" will give you a broader description of what the compiler is trying to tell you.
Finally is the actual code line:
 static void read(tmElements_t &tm);

                  ^

The carat shows the column number of the error.
Unfortunately the actual bug may often be in previous code so this isn't as simple as it may seem.
Now lets talk about your specific issue. A search for "'tmElements_t' has not been declared" does yield some results from others having similar problems but you will probably find after going through their solutions that none of them fix the error. This is because the error is caused by a recent update to a new version of avr-libc in Arduino IDE 1.6.10/Arduino AVR Boards 1.6.12 and later. This version of avr-libc contains a file named time.h. On a case insensitive operating system such as Windows this will cause
#include <Time.h>

to include the wrong file, time.h which causes the error since indeed that file doesn't declare tmElements_t. This problem is known to the author of the Time library and he has moved the code to a file named TimeLib.h as a workaround. The file Time.h was left for backwards compatibility. So the solution is to change:
#include <Time.h>

to:
#include <TimeLib.h>

I was able to get the TestRTC sketch to compile by just making this change in TestRTC.ino but you may also need to change line 25 of DS3232RTC.h.
I have submitted a pull request to fix this issue to the DS3232RTC repository: https://github.com/Tecsmith/DS3232RTC/pull/9
EDIT: My pull request has now been merged so the issue can also be solved by installing the updated Tecsmith/DS3232RTC library.
If this solves your problem please also update your other question so that the people trying to help you there will know it's fixed.

Thank you, I added a link at the other question. I will try what you suggested. Will comment again to confirm. Appreciate very helpful answer. Regret I cannot upvote it (insufficient reputation), hope other people will upvote it please.

Confirming that TestRTC compiled without error after I changed Time.h to TimeLib.h for two includes as recommended above. This answer helped me to understand what was wrong (actually a difficult issue with same-name components).

Consider the Arduino paradigm as a collection of well established (very) sophisticated computing tools. Arguably, the C compiler is the most complex of these tools.  So understanding the compilers output can be challenging at times.
That said, the normal way to approach compiler problems is to solve the 1st error the compiler finds then recompile.  More often then not solving the 1st error will resolve many other errors.
A guess, in this particular case, is that an include file has been omitted.  Find where the type "tmElements_t" is defined and check to see if the include file (a.k.a. header file) where it is defined needs to be included into the source code file where the 1st errors shows up.
Added later...
Ug, the 1st error is not even your code!  It is in the DS323RTC library you downloaded.  We can probably assume this library is working and compiles.  So that leaves the burden on us to find the reason why your code does not compile.  Besides, you can't go back to GitHub saying there is a bug in the library with out trying to solve the problem first.
The 1st stop is to read any readme.txt file at GitHub or the copy of it you downloaded with the library.  We find in the 1st few dozen lines this:
To use the DS3232RTC library, the Time and Wire libraries must also be included. For brevity, these includes are not repeated in the examples below:

#include <DS3232RTC.h>    //http://github.com/JChristensen/DS3232RTC
#include <Time.h>         //http://www.arduino.cc/playground/Code/Time
#include <Wire.h>         //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)

So right away we see we need to include Time.h.  If you look in the Time library (another library you need to download if you have not already) you will find that it is where tmElements_t is defined.  It does bother me that Time.h is included after DS323RTC.h.  If you are still having problems try including Time.h first.

Understand this forum deals with sketch programming. To use a sketch we must compile and we must understand compiler errors in order to fix them. Can you recommend a forum more suited for asking about Arduino compiler errors please?

You are right. Stackexchange is the place to ask software questions. But as soon as they see you are asking about sketches they will likely move you back here. I'll change my answer later when I get more time. More importantly, did you figure out the problem? Was the answer correct?

@per1234 figured out the problem. Please see accepted answer that explains the issue and provides information to fix the compile errors.

Meant to say Stackoverflow.com for software questions, which is connected to the *.stackexchange.com family of forum.  Sorry about the confusion.  Then my comment above starts to make sense.


text:
How to use millis()
I'm trying to have a keypad do two one of three things when a key is pressed:

If the 1 is pressed I want LED 1 to blink twice then stay on
If either the 2 or the 3 is pressed I want LED 2 to blink forever
If the # key is pressed I want it to cancel whatever's going on with the other LEDs

How can I use millis() to blink forever? Or just blink twice then stay on? When in my blinking should I be checking for another keypress? What's frustrating me is that I know how to do all this with delay(), and I've written 70% of the code for it with delay, but if I use delay I don't think it'll be able to check for another key input, will it?
Thanks for any help.

How can I use millis() to blink forever?

The algorithm is essentially as follows:
if (it_is_time_to_toggle_the_led()) {
    toggle_the_led();
}

The details are thoroughly covered in the Blink Without Delay
Arduino tutorial. It is essential to understand this technique: as soon
as you have more than one thing to do in your program (here: blink an
LED and monitor button presses), delay() is toxic because it blocks
all the program. You should really ban delay() from your vocabulary,
except for the simpler single-task programs.

Or just blink twice then stay on?

For this and your other questions, the canonical answer is “implement a
finite state machine”. I recommend the Finite State Machine
tutorial[] by Majenko.
In this particular instance, I would probably implement two FSMs, one
for each LED. The first one would have three states: (OFF, BLINKING,
ON), and a counter for the number of blinks. The transition rules:

If button 1 is pressed and the state is not BLINKING go to the
BLINKING state
If it is BLINKING and it's time for it to toggle, do it
If it is BLINKING and it is switching on for the third time, go to
the ON state
If '#' has been pressed, go to the OFF state.

Or maybe you could split the state BLINKING into BLINKING_ON and
BLINKING_OFF.
The second LED would be essentially the same, except for lacking the ON
state and rule number 3.
I am not writing the code, but you may want to take a look at this code
for automatic door[]. It is an answer to a seemingly unrelated
question, but it gives a good example on how to combine millis()-based
timing with a finite state machine. Your program could be written mostly
along the same lines.

Wow, I had never heard of FSMs before, really cool! Thanks for your help.

So I've tried many different ways of doing it and the system seems to have trouble advancing through the loop. Here's my code so far. I know I'm not supposed to use delay() but it works okay for right now. The problem is that the red LED will turn on (when 4 or 5 is pressed), and stay on. There's no blinking or anything, which leads me to believe it runs through the code then waits for another keypress before running back through the loop? Does that make sense? Any more help you can offer would be greatly appreciated.

@finlay: Your code won't compile.


text:
Does serial speed affect performance of other tasks?
I have explored Google and the Arduino site and this site and cannot find a mention of this, so my guess is that serial is handled by a separate component to the core processing and so different serial communication rates will not affect code performance.
Is this correct?
Where can I find information about how serial passing is handled? For instance, when I call Serial.prinlnt("test"), how does that get to the serial line?

It depends. Serial data is received into, or sent from, buffers (one for sending and one for receiving). If you have a processor with 1024 bytes of RAM or more, then the buffer size is 64 bytes, otherwise it is 16 bytes. (See the HardwareSerial.h file in your distribution).
If the buffer fills up when sending, it will block (that is, the code will wait for the buffer to empty). If it fill up when receiving the extra bytes will be discarded.
If the buffer does not fill up, then the baud rate will not affect performance. That is because data is sent, or received, by an interrupt service routine, in the background.
As a rule of thumb, you can expect data to be sent or received at the baud rate divided by 10. That is because each byte is 8 bits, plus a start and a stop bit (10 bits in total).
So, for example, at 9600 baud you can send 960 characters per second. If you are sending something simple, like a temperature which is 20 bytes, every second, then the baud rate won't affect performance at all. If you are trying to send thousands of bytes per second, it will affect performance, because the Serial.println will probably block once the buffer fills up.

For instance, when I call Serial.prinlnt("test"), how does that get to the serial line?

If the buffer is not full, then "t" "e" "s" "t" are copied into the buffer, and the code returns immediately. If the buffer is full then it waits for it to become not-full.
As an efficiency measure, if you are sending a single byte, and the buffer is empty, then the byte is placed in the hardware register immediately (saving a small amount of time). In this case, if the buffer was empty, "t" would be sent immediately, and "est" would be sent afterwards, as a "byte has been sent" interrupt is raised.1
This is described in the code comments:
size_t HardwareSerial::write(uint8_t c)
{
  _written = true;
  // If the buffer and the data register is empty, just write the byte
  // to the data register and be done. This shortcut helps
  // significantly improve the effective datarate at high (>
  // 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
  if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
    *_udr = c;
    sbi(*_ucsra, TXC0);
    return 1;
  }
  tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;

  // If the output buffer is full, there's nothing for it other than to
  // wait for the interrupt handler to empty it a bit
  while (i == _tx_buffer_tail) {
    if (bit_is_clear(SREG, SREG_I)) {
      // Interrupts are disabled, so we'll have to poll the data
      // register empty flag ourselves. If it is set, pretend an
      // interrupt has happened and call the handler to free up
      // space for us.
      if(bit_is_set(*_ucsra, UDRE0))
    _tx_udr_empty_irq();
    } else {
      // nop, the interrupt handler will free up space for us
    }
  }

  _tx_buffer[_tx_buffer_head] = c;
  _tx_buffer_head = i;

  sbi(*_ucsrb, UDRIE0);

  return 1;
}

Notice that the byte is not placed in the buffer at all if it is empty, and nothing is being sent.

For more information see my question and answer about serial processing.

Strictly speaking, after discussing this in the comments with Majenko, the interrupt that is raised is really that the hardware "send" buffer is empty. When the send buffer empties then the interrupt is called so that the interrupt code can put a new byte into it.

As an efficiency measure, if you are sending a single byte, and the buffer is empty, then the byte is placed in the hardware register immediately (saving a small amount of time). - actually that's not for the sake of efficiency - that's done so that a TX interrupt can be raised - otherwise you put stuff in the buffer and the TX interrupt never triggers (because there is nothing in the TX FIFO to send) and so the buffer never empties. You need that first manual entry in the TX FIFO to start the ball rolling.

That's not what the comments in the code say (see amended answer). However I agree that a side-effect is that if you go to write another byte, you now know there will be an interrupt from writing the first one. Although I'm wondering now if there could be a race condition. If the code fails that first test (ie. something is being sent) but the sending completes, and the interrupt is processed before the byte is put into the buffer, then that byte may not be sent.

Nah. It enables the Data Register Empty interrupt at the end of write() which, if the transmit buffer is empty triggers the ISR to fill it. If it has triggered during the first if and the buffer has been filled with the last byte in the ring buffer the IF will fail, it will fall through to placing the byte into the ring buffer, and the next time the interrupt fires it will be picked up. If it was the last time the interrupt would fire (empty ring buffer) then the interrupt is re-enabled anyway and fires because the TX buffer is empty.

I'm used to chips with a proper multi-level hardware FIFO, so there's no messing with these silly ring buffers anyway...

Ah, OK, I was looking at the specs for the wrong flag (TXCIEn). What you say makes sense.

However that contradicts what you said before: otherwise you put stuff in the buffer and the TX interrupt never triggers. You agree that the TX complete interrupt is not the important one, but rather it is the TX buffer empty one? I just checked with a test program. There is no TX complete interrupt handler generated. The only thing it is interested in is the TX buffer being empty. Thus your statement that "the buffer never empties" because the "TX interrupt never triggers" is not correct.

Yeah, you can ignore my first bit. I am too used to a different UART system.

No, it affects code performance always. For how much is dependent on used data types, baudrate, tx buffer size.
Data types:

AVR doesn't have hardware floating point operation support. Software support is super slow, so if you want to print some floats, it will be affecting performance a lot (but it's same as just using it).
There is no integer division either (except for bit shifts/rotates which is division by powers of two). So printing bytes, integers, longs in DEC base takes some performance.

Baud rate settings and transmit buffer size:
Sending data over Serial is limited by its speed (baud rate). So if you use common 9600 baud rate you'll be limited by this speed. If you're sending data at higher rate. Transmit buffer gets filled and next write into Serial will be blocked until another character from buffer is sent.


text:
FastLED and Neopixel Help
I'm in the process of trying to create a "Aurora Glow" effect using a Particle Photon and a Neopixel ring.
I have the code fully working using a single Breadboard-friendly NeoPixel however when upgrading this to a NeoPixel Ring (16 LED) the code does not run as expected
The current working code for a single NeoPixel can be found here: http://pastebin.com/Yj1cywpx
It was my assumption that i could change Line 33 from one LED to Sixteen e.g.:
FastLED.addLeds<NEOPIXEL, 6>(&led, 1);

to
FastLED.addLeds<NEOPIXEL, 6>(&led, 16);

However when I run this code rather than all NeoPixels cycling through the Aurora Colours, only the very Top LED does and rest are either off or a static colour (e.g. https://i.stack.imgur.com/6rY38.jpg)
Could someone please advise what i missing? Apologies if this is a "Noob" question but this is my 2nd Arduino project and I cannot understand why this would not work.
Thanks

Never used neoPixels in arduino before so this is a complete guess based on reading the code but it looks like you are only setting the colour of the first LED.
Try creating 16 LED colours:
CRGB led[16];

and then setting them all:
for (int i = 0;i<15; i++) {
  int colourIndex = index + i;
  if (colourIndex > 15)
    colourIndex -= 15;
  led[i] = ColorFromPalette(auroraPalette, colourIndex , 255, LINEARBLEND);
}

edit - as @rDg indicates in his answer
FastLED.addLeds<NEOPIXEL, 6>(&led, 16);

becomes
FastLED.addLeds<NEOPIXEL, 6>(led, 16);

since led is now an array not a single value
Finally I think paletteSize should only be 16 not 5*16, you only have 16 colours in there.

Thanks Andrew for a swift response i will make the changes and let you know! Thanks again

Hi Andrew,
When editing the void loop() to use the for loop i get:
ringtest.cpp:41:6: error: 'i' was not declared in this scope
do i need to declare this at the top of the script?
http://pastebin.com/8FaDdzLW
Thankyou again for your help

You need to declare it somewhere for (int i=0;... would work fine. I'll update the original answer...

In addition to the above, you need to tweak your addLeds line:
FastLED.addLeds<NEOPIXEL, 6>(led, 16);

That's confusing.  I'm not sure why stackexchange is currently ordering your answer first.   But, if I may, I think it would be clearer to say  "In addition to @Andrew's answer, you need to tweak your addLeds line".  Yes, I agree, it is no longer a variable but an array and no longer needs the ampersand.

@rDg Thankyou for your comment i have since removed the ampersand.
Taking yours and Andrews comments into account i have modified my script. Changing the if statemnet to use Andrews For loop. Getting errors compiling but working on the issues: http://pastebin.com/8FaDdzLW
Thanks for your help

@4dogsofwar You seem to have removed most of the code from your loop() code. The for loop in my changes only replaced the single line that was setting the value of led, with code that set all 16 values. You still needed the other lines that were in your loop(). Something like this http://pastebin.com/5N1dEYTv

@Andrew. Apologies this was my mistake i wasnt 100% sure. I have edited the code (http://pastebin.com/nGgUXw9B) and it complies successfully :D I Will test and run the code when I'm home.
I would like to thank you for bearing with me and your hard work, its been a very good learning exercise!