text:
Generating an 8V PWM signal
I have a control module that accepts 8V PWM signals.  My goal is to send a 500Hz PWM signal from an Arduino to an 8V PWM input on the control module.  Looks like everything generated from the Arduino is 5V.  Is there a way to generate an 8V PWM output or method of manipulating that signal to reach 8V?

How much current do you need?

I'd suggest you use a power-source that delivers you 8V. Your Arduino takes anything from 7-12V to power it and it regulates it down to 5V. But you still can access the 8V from the RAW pins. Use a MOSFET like D1703L to control the 8V with an 5V Arduino digital pin.
You just connect Drain (D) to GND and Source (S) to your RAW 8V (don't forget to put your device between the Source and RAW 8V). Your Arduino digital pin goes to Gate (G), but to not draw to much current from the pin you might want to use a resistor of roughly 1kΩ.
This is the safest way that also allows for much higher voltage and also current for up to a few amps.
EDIT
You should not connect the PWM pin to Ground on your Arduino. But you have to connect both grounds together. I'm not sure where your 8V comes from so I made a sketch where the 8V is an external source and powers your device along with the MOSFET.

Mosfets don't draw current from the gate, the resistor isn't strictly needed. Depending on the application, You might want to add a pull-down resisor on the output.

I have attempted the circuit as suggested above with an N-channel MOSFET.  This isn't working and I think my circuit is wrong.  I can't use the MOSFET to switch ground, I need it to switch the 8V.  So, here is how I connected the MOSFET:  Gate to the Arduino output (with a 10k resistor to ground).  Source to +8Vdc.  Drain to the PWM input pin on the Electronic Control Module (8V PWM input).  I have a feeling that because I'm switching the 8V through the transistor instead of ground, do I need to use a P-channel MOSFET?

No, an N-Channel MOSFET is perfectly fine. Using a P-Channel would reverse the signal (Pin High -> switched off and vice versa). The MOSFET acts like a switch. It does not matter from which side you connect it as long you watch the polarity. Can you give a sketch of your circuit?

I have added a circuit sketch to the original question.  Doesn't seem like I'm able to add an image to a reply.  Ok, thanks - I understand about the P & N channel now.  Most of the circuit sketches I look at (from Google and such) are switching ground through the transistor.  Does it even work the way I'm trying to do it, or do I need to configure this circuit differently?

I updated my answer with an Image.

The ground from the ECM and ground from the Arduino are tied together.  I made a program that cycles from 0 to 255 with an AnalogWrite function (with a 50ms delay between each iteration).  With a multimeter (on voltage setting) at the Gate I can see the voltage go from approximately 0 to 5 volts.  At the Source, I have the 8V.  But, I would expect to see the Drain cycling from 0 to 8V, but I don't.  It remains at approx. 7.4V and doesn't change.  Any thoughts on what might be the problem?

I'd suggest not to trust your multimeter. The voltage does not ramp up from 0V to 5V. It switches quickly between 0V and 5V with different duty cycles. What you need to verify the output is a oscilloscope. Only those can tell you what you really get.

The other question is: Is your device that requires the 8V PWM, really requireing a PWM or an analogue signal between 0V and 8V? In the later case you'd need at least a capacitor to smooth the square wave PWM.

authors: Рубен Карапетян


text:
Can anyone help me figure out why this buffer is overflowing? (Updated)
This should be fairly straightforward, but there must be something I'm not understanding about buffers.
I have serial data coming in to my Mega via Zigbee. I'm sending a string just like this: ~-0.6016800, where ~ is my unique starting delimiter and my end delimiter is a carriage return \n. I'm sure it's coming through the zigbee correctly, because I can see my string show up looking good in XCTU when I plug the zigbee into the PC. Here is my code:
const int numChars = 15;
char incoming[numChars];

static boolean Receiving = false;
static byte ndx = 0;
char startMarker = '~';
char endMarker = '\n';
byte K;
bool allreceived = false;

void Get() {
    memset(incoming, NULL, strlen(incoming));
    while (allreceived == false) {
        if (Serial.available() > 0) {
            K = Serial.read();
            if (Receiving == true) {
                if (K != endMarker) {
                    incoming[ndx] = K;
                    ndx++;
                    if (ndx >= numChars) {
                        ndx = numChars-1;
                    }
                }
                else {
                    incoming[ndx] = '\0'; // terminate the string
                    Receiving = false;
                    ndx = 0;
                    allreceived = true;
                }
            }
            else if (K == startMarker) {
                Receiving = true;
                ndx = 0;
            }
        }
    }
}

So somehow my buffer is overflowing or something, no matter how big I make it. I see the array start off as I expect it for the first few characters, then it turns into unintelligible characters. I think part of the problem might be that the serial data is coming through at a different rate or something, because I can see my starting delimiter ~ on my LCD screen in the middle of my array. The way it's set up, I should never be able to see my start delimiter unless I miss my end delimiter without ending the array. (Note- I've tried different unique end delimiters too, but this seems to work just the same)
Any ideas on what might be causing this??
EDIT: NOW TRYING THIS CODE- I'm still having the buffer overflow, and I'd be really grateful if someone could take a look.
Sending code:
void PayloadSendit(void) {

Payload[0] = '~';  //1 char unique start

if (outFormat == 0) {
    Payload[1] = '0';
    Payload[2] = '$';  //spacer
    strcat(Payload, stringval); //5 char for hashmarks
}
else {
    Payload[1] = '1';
    strcat(Payload, stringvalin);  //6 char for inch
}
if (dotpos <= 99) {
    Payload[8] = '@';  //spacer
    char dotpos2[2];
    sprintf(dotpos2, "%i", dotpos);
    strcat(Payload, dotpos2);    //2 char
}
else {
    char dotpos3[3];
    sprintf(dotpos3, "%i", dotpos);
    strcat(Payload, dotpos3);   //3 char ///////////////////////////
}

Payload[11] = '0';  //1 char for "no errors" code
Payload[12] = '*';  //1 char end delimiter
Serial.println(Payload);
Serial.flush();
memset(Payload, '\0', 13);

}
Receiving code:
  void Get2() {
    memset(Payload, '\0', bufsize);
    while (allreceived == false) {
        int K = Serial.read();
        switch (K) {
        case -1: // Nothing to read
            break;

        case '~': // Starting a new string
            Receiving = true;
            break;

        default: // Any other characters.
            break;

        }
        if (Receiving) {
            for (int i = 0; i <= 10; i++) {
                Payload[i] = Serial.read();
            }
            if (Serial.read() == '*') {
                Receiving = false;
                allreceived = true;
            }
            else { memset(Payload, '\0', bufsize); }  //destroy array if end delimiter not where it should be
        }

    }
}

My guess is this line:
memset(incoming, NULL, strlen(incoming));

When "incoming" hasn't yet been cleared, what is the length of it? It's whatever it counts up until the first '\0' character - and where is that character on the first run through? Who knows.
Instead you should memset the size of the buffer, not the number of non-NULL characters in the buffer:
memset(incoming, NULL, numChars);

However, that is a pointless operation, since you are storing a C string and (should be) properly terminating it, so it really doesn't matter what is in the array to begin with since you are just overwriting it anyway. So you can completely lose that whole function call.
You might like to re-write your receiving routine to use a switch/case construct instead of ifs and elses - it'll be much easier to follow:
#define EVER ;;

const int numChars = 15;
char buffer[numChars];

void Get() {
    int pos = 0;
    bool receiving = false;

    for (EVER) {
        int K = Serial.read();
        switch(K) {
            case -1: // Nothing to read
                break;

            case '\n': // Got the end of the string.
                if (receiving) return; // We have a valid string.
                pos = 0; // Reset pointer to start of buffer
                break;

            case '~': // Starting a new string
                pos = 0;
                receiving = true;
                break;

            default: // Any other characters.
                if (receiving) {
                    if (pos < numChars-2) {
                        buffer[pos++] = K;
                        buffer[pos] = 0;
                    }
                }
                break;
        }
    }
}

I know its Friday afternoon but I'm sure you don't mean buffer[pos] = K; buffer[pos++] = 0; because that will overwrite K with 0.   pos++ should be ++pos.

@Matt Actually you are wrong :P I did mean pos++, just not in that place ;) It should have been buffer[pos++] = K; buffer[pos] = 0;

Thanks for your eyeballs, guys. @ Majenko, I totally agree with you on the memset thing. It was just something I tried on for size. And I like the switch case structure. That one is new to me. Kinda reminds me of LabView (I'm not one of those who disparages LabView).
I'm going to try out this method, but I've tried quite a few and I have my doubts. I still have a sneaking suspicion that I'm actually missing serial bytes somehow and not catching my end delimiter even though my while loop is terminating.
My main evidence is that I'm seeing bytes that only exist outside of my sent string.

@ Majenko, I implemented a version of what you shared with me. I had tailored my payload so that I always have the same number of characters, so I'm trying a for loop to collect the characters and then checking to make sure the next character is my end delimiter. I don't think I'm using any functions that add a terminating null, so I don't think that matters. However, I'm still getting a huge buffer overflow.
Again, I can verify my character array via Zigbee connected to PC. I'll post my sending code and then my receiving code in an update now.

source: Stack Exchange

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

sort: votes


text:
I want to log GPS coordinates using my Arduino and other sensors
I want to log GPS coordinates using my Arduino and other sensors.  The difficulty is that I will be in forested conditions.  Would it be better to hardwire a gps device to the Arduino or to bluetooth an external device (a much more accurate, Trimble device that I know will give me the accuracy I need)?  Can such devices pair to a bluetooth receiver that would hardwire to my Arduino, or do I need an intermediate device like my iPhone?

The GPS receiver I've always used is the Adafruit Ultimate GPS:
https://www.adafruit.com/products/746?gclid=CjwKEAjwoPG8BRCSi5uu6d6N5WcSJABHzD8FmldH1vIvTt8h-S-948CJmDR6fR_BcF20UZMS4I-AEBoCt9Tw_wcB
It comes with a spot for you to plug in an external antenna (with an adapter), so you can get more precision and presumably be able to receive data much more accurately in places like forests. However, I'm not sure of this, so an external device may be the way to go. Bluetooth would be possible, but it can be a little difficult to set up with Arduino if you lack the experience, so if you can I'd go with a wired connection (with an RS232 or other).

What's more important, GPS accuracy or GPS yield?
Normally it's a trade off between the two. Under difficult conditions such as lots of trees a high accuracy GPS may simply stop outputting locations because it can't guarantee the accuracy, it depends upon the target market for the GPS.e.g. a survey system will be very conservative, survey people don't like getting bad data. A cheaper lower accuracy GPS won't care and will still output a position no matter how dubious the signals are.
I've seen $100 GPS units output a position when a $20,000 Trimble system refuses to.
The GPS should support NMEA output over bluetooth serial port protocol which would then work fine for a direct connection to your device however you may need to change the receiver settings to enable it, the default is likely to be outputting Trimbles binary TSIP format over the bluetooth.

If the Trimble has a serial output then you could connect via that.
If the Trimble supports the same Bluetooth spec as your receiver, then there is no reason why you shouldn't be able to connect them directly. You will need to find out if the Trimble is a Master, Slave or both and buy the appropriate receiver for you Arduino.

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


text:
Problem Atmel Studio 7 with uploading
I have a problem with the interworking between Atmel Studio 7 and Arduino IDE 1.6.10.
I recently upgraded from IDE 1.0 to 1.6.10 and I can no longer upload my code to the Arduino. Everything works including compiling and it does recognise my COM3 port. Atmel Studio is configured for no external programmer.
When I compile with the Arduino IDE it does upload the code. My question is what goes wrong here, what do I need to do solve it. Thanks for your help
This the message I have in the end:
Compiling 'GridMonintor_V1R1' for 'Arduino Nano w/ ATmega328' Binary sketch size: 12,268 bytes (used 40% of a 30,720 byte maximum) (22.20 secs)

Minimum Memory Usage: 774 bytes (38% of a 2048 byte maximum) Uploading to I/O board using 'COM3'

avrdude: no programmer has been specified on the command line or the config file
         Specify a programmer using the -c option and try again

Switch on verbose so that we can see the upload command

...Specify a programmer using the -c option and try again

For Arduino, the programmer switch must be -c arduino. The full arguments for avrdude, in the Atmel Studio 7 External Tools window, are:
-c arduino -p m328p -P COM3 -b 57600 -D -V -U flash:w:"$(TargetDir)$(TargetName).hex":a

See avrdude options.

you might want to try the following command:
-C “C:\Program Files\Arduino\hardware\tools\avr\etc\avrdude.conf” -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:$(TargetDir)$(TargetName).hex:i
where i is used at the end for intel. the one provided above by @flanker uses a
see this detailed tutorial How to program Arduino using ATMEL Studio 7

Switch on vMicro>Uploader>verbose then try the upload and post the output as a .txt file in a new thread in the visualmicro.com forum.
http://www.visualmicro.com/forums
Because you are using the Visual Micro plugin the forum is the best place to see help.
We will also check that you have configured the new arduino location against the arduino 1.6.x option in Visual Micro and not the Arduino 1.0. option as you had it originally. In fact you can have both IDE versions configured in Visual Micro at the same time and switch between them using the tool bar.
Thanks


text:
Interrupt for traffic light
I have mini project which is Emergency Traffic Light for Ambulance, police etc.
What I am try to do is when emergency traffic light go through first sensor 1 (in this code I just using button, “SA”), traffic light will be pause and the traffic light for ambulance will be green.
After ambulance go through second sensor (SB), traffic light will be reset and the flow become normal (red → orange → green).
My problem is I don’t know how to make interrupt for this code.
I hope anyone can help me.

#define SA 2 //sensor 1
#define SB 3 //sensor 2
#define IND 6 //indicator
/////////////////////////////////////
#define AH 13   // A
#define AK 12
#define AM 11
/////////////////////////////////////////
#define CH 10    //C B
#define CK 9
#define CM 8
#define yellowBlinkTime 500 // 0.5 seconds for yellow light blink

///////////////////////////////////c
#define BH A0   // B
#define BK A1
#define BM A2
///////////////////////////////////////////////

boolean TA = true; // west = true, east = false
int flowTime = 10000; // amount of time to let traffic flow
int changeDelay = 2000; // amount of time between color changes

void setup()
{
pinMode(SA, INPUT); //sensor 1
pinMode(SB, INPUT); //sensor 2
pinMode(IND, OUTPUT);   //indicator

pinMode(AH, OUTPUT);   // A
pinMode(AK, OUTPUT);
pinMode(AM, OUTPUT);
///
pinMode(CH, OUTPUT);   //C
pinMode(CK, OUTPUT);
pinMode(CM, OUTPUT);
///////
pinMode(BH, OUTPUT);   // B
pinMode(BK, OUTPUT);
pinMode(BM, OUTPUT);

// set initial state for lights -
//jalan A
digitalWrite(AM, LOW);
digitalWrite(AK, LOW);
digitalWrite(AH, HIGH);

//jalan C
digitalWrite(CM, HIGH);
digitalWrite(CK, LOW);
digitalWrite(CH, LOW);

///// JAlAN B
digitalWrite(BM, HIGH);
digitalWrite(BK, LOW);
digitalWrite(BH, LOW);

}//-------setup end

void loop()
{
  if(digitalRead(SA) == HIGH )
  {
  blink();
  //flow();
  //break;
  }

  else{

  flow(); // p void flow normal
} // end else
} // end void loop

void flow() // flow normal tf
{
//flow1
digitalWrite(AK, LOW);
digitalWrite(AM, LOW);
digitalWrite(CK, LOW);
digitalWrite(AH, HIGH);
digitalWrite(CM, HIGH);

digitalWrite(BH, LOW);
digitalWrite(BK, LOW);
digitalWrite(BM, HIGH);

delay(changeDelay);

//flow2
digitalWrite(AH, LOW);
digitalWrite(AM, LOW);
digitalWrite(AK, HIGH);

digitalWrite(CM, HIGH);

digitalWrite(BM, HIGH);
delay(changeDelay);

//flow3
digitalWrite(AK, LOW);
digitalWrite(CM, LOW);
digitalWrite(AM, HIGH);
digitalWrite(CH, HIGH);
digitalWrite(BM, HIGH);
delay(changeDelay);

//flow4
digitalWrite(AK, LOW);
digitalWrite(AH, LOW);
digitalWrite(CM, LOW);
digitalWrite(CH, LOW);
digitalWrite(AM, HIGH);
digitalWrite(CK, HIGH);
digitalWrite(BM, HIGH);
delay(changeDelay);

//flow 5
digitalWrite(AK, LOW);
digitalWrite(AH, LOW);
digitalWrite(AM, HIGH);
digitalWrite(BH, HIGH);
digitalWrite(BM, LOW);
digitalWrite(CK, LOW);
digitalWrite(CH, LOW);
digitalWrite(CM, HIGH);
delay(changeDelay);

//flow 6
digitalWrite(AK, LOW);
digitalWrite(AH, LOW);
digitalWrite(AM, HIGH);

digitalWrite(BK, HIGH);
digitalWrite(BH, LOW);

digitalWrite(CM, HIGH);
digitalWrite(CK, LOW);
digitalWrite(CH, LOW);

delay(changeDelay);

}//-------flow end

void blink()
{
[enter link description here][2]
    digitalWrite(AH, LOW);
    digitalWrite(AM, LOW);

    digitalWrite(BH, LOW);
    digitalWrite(BM, LOW);

    digitalWrite(CH, LOW);
    digitalWrite(CM, LOW);

    digitalWrite(AK, LOW);
    digitalWrite(CK, LOW);
    digitalWrite(BK, LOW);
    delay(yellowBlinkTime);

    ////////////////////////////////////////////////// BLINK BLINK
    digitalWrite(AK, HIGH);
    digitalWrite(CK, HIGH);
    digitalWrite(BK, HIGH);
    delay(yellowBlinkTime);

}  ///////////////// end void blink

Try using millis() instead of delay(). delay() literally delays the code, thus stopping it from doing it anything else. The loop simply pauses at the delay for the desired amount of time: thus nothing else can be done. millis() does not do this. Instead, it continuously reads out time, compares it to an earlier measurement to see how much time has passed. You can then program what it should do when it crosses a specific threshold (i.e. 20 seconds). You can find tutorials on millis() on the Arduino website.

I can truly advice you to use millis() from now on, instead of delay() as it will make your code much more efficient. Especially with semi-complicated stuff like this.

Also you should look at using a Finite State Machine instead of linear code like that.

The use of two letter variable and constants names make the code RF difficult to read.  You could look at using functions to perform repetitive tasks and reduce the volume of code.  Using delay statements like this is locking up your code, also it means that your timing will drift particularly if you service an interrupt, try triggering state changes at a certain time, this will also let you monitor sensors without interrupts.

monitor pin changes with https://github.com/neu-rah/PCINT , still you have cycle your code to allow changes, do not use delay and do not do all work inside interrupt handlers (it wont work) instead use them to set a flag and allow your code to react to that flag change quickly (therefor do not use delay)

You probably do not need to use interrupts. A typical Arduino's clock runs at 16MHz. A rough calculation means that you will be getting well over 5 million instructions per second. So unless you are doing some extremely intensive other processing and/or your ambulance is travelling near the speed of sound, polling the sensors should be fast enough. Next consider finite state machines as suggested above to simplify your code. Oh yes, don't use delay - if you do, you are simply throwing away the millions of instructions per second available for you to use.

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


text:
Is possible to process analogue inputs with variation frequencies in MHz?
Is it possible for Arduino boards to accurately process analog inputs that vary at MHz frequencies?
If possible, which Arduino board would be most appropriate for such application?
What adjustments would be required for it to handle such rapid analog input variations?

What frequencies?

Depends on what the signal actually is and what you want to measure.  The Arduino isn't fast, but you could, for example, build a board that gives you a measure of what the frequency is, if it changes slowly enough.  Or if it's a relatively constant frequency and you care only about the amplitude, you could use a variant of the standard super heterodyne circuit.

Your typical ATMega-base Arduino cannot sample anywhere near that kind of speed.
It takes 13 clock cycles to sample an analog value on an ATMega chip, and the maximum clock frequency for the ADC is 1MHz. That gives you an absolute maximum sampling speed of 76923 samples per second. That means the highest frequency you can sample is 38461Hz.
There are better chips on the market with higher sampling speeds, but they aren't Arduino. Some can sample at the tens of millions of samples per second allowing you to sample frequencies in the low MHz. Other specialised ADC chips are available that can sample in the Gsps range which are what are used in oscilloscopes and high speed communication (fibre optic) systems etc. Working with these kind of chips needs quite a lot of skill though as the analog signal paths requires special design and consideration.
Also when sampling at those kind of frequencies you need a lot of high-speed memory, which no Arduino can ever even consider the possibility of having.


text:
How do I convert a float into char*?
Asked this question on Electrical Engineering Stack Exchange and was directed here:
Pretty self explanatory; how would I go about converting a float into a char*? I have code in which the float 'resistance' is constantly being updated. I would like to be able to update the variable 'result' to take the value of 'resistance'. Here is some of the code, in case it helps:
const char * result = "";
float resistance = 2.5;

result = resistance; //This bit (obviously) doesn't work

Thanks for your help!

There is a function in the standard Arduino library called dtostrf(). I think of it as "Decimal to String Float". You pass in the float, how wide you want the whole number to be (if it will fit), the number of decimals of precision - and the buffer you want it to fill.
Note that! You need to provide the buffer, and you need to be careful to provide more than enough! Don't forget to add 1, too (to store the NUL character at the end):
char result[8]; // Buffer big enough for 7-character float
dtostrf(resistance, 6, 2, result); // Leave room for too large numbers!

This will give result values like "  1.23" and " -1.23" and "123456789" (without the quotes). Note the last example - it won't truncate the number if it's too large, and that 10- character result (don't forget the final NUL) just overflowed your buffer...
Incidentally, if you specify a negative width, it won't right-justify the answer, it'll left-justify it (put any spaces on the end instead of the beginning).

Did the trick nicely! Thank you very much kind sir :)


text:
Answer power IN from two sources
Items:

Arduino Uno
Laptop
7.4V 2s LiPo Battery
Neewer 30A ESC

Scenario:
The LiPo powers the ESC while the Laptop USB powers the Arduino. If I unplug the USB from Arduino is loses power (obviously) and when I plug in the ESC to the arduino I get power again to the Arduino. I need the USB plugged in to receive Serial information from the laptop and I need pow+gnd plugged into the Arduino or else I get a lot of PWM noise rendering my ESC useless.

ESC is 5V
USB is 5V

Question:
This is my due diligence to not blowing anything up. What is the safest way to plug in power from both USB and the ESC? Same voltage, difference sources. Or can I just connect the grounds and call it good?

Connecting the grounds would work.
You could also connect the 7.2V lipo to the Vin pin on the UNO. The UNO will automatically switch from USB to Vin, if it's present.


text:
Control/switching of headphone audio
I need to do some simple line control of audio out from a phone, 3.5mm TRS. I would have preferred to use transistors, but the voltage drop on an already fairly weak signal makes it unusable. Also not sure about negative voltage from collector to emitter. Essentially I need to switch the line on/off. How can I do this while not introducing noise or signal loss (K.I.S.S.) - I haven't checked if optocouplers are without voltage drop, but in any case they're probably overkill.
Ask for clarification if needed.

This might be of interest to you: http://www.analog.com/media/en/training-seminars/tutorials/MT-088.pdf

Settled on a CMOS bilateral switch (4002). Thanks for the input.

My first thought was what about relays.  I've done a quick search and found this http://www.geofex.com/article_folders/relays/relays_for_switching_audio_signa.htm and this https://electronics.stackexchange.com/questions/110750/is-it-possible-to-turn-an-audio-signal-on-off-using-a-solid-state-relay so maybe it's not such a stupid idea, but like optocouplers it probably is a bit OTT.


text:
Basic WiFly server returning unexpected output within web client
Currently trying to implement a lightweight webserver using the WiFly shield and an Arduino UNO, this is the code I have so far:
#include <SPI.h>
#include <WiFly.h>
WiFlyServer server(80);

/* Function defs */
void cmd(void)  { SpiSerial.print("$$$"); }
void dhcp(void) { SpiSerial.println("SET IP DHCP 0"); }
void pass(void) { SpiSerial.println("SET WLAN PHRASE 22222222"); }
void ssid(void) { SpiSerial.println("JOIN BTHOMEHUB"); }
void port(void) { SpiSerial.println("SET IP LOCAL 80"); }
void ip(void)   { SpiSerial.println("SET IP ADDRESS 192.168.1.123"); }
void tcp(void)  { SpiSerial.println("SET IP PROTOCOL 2"); }
void boot(void) { SpiSerial.println("REBOOT"); }

/* Pointer to a handler function */
typedef void (*Handler)(void);
Handler table[8] = { cmd, dhcp, pass, ssid, port, ip, tcp, boot };

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

  for(short x = 0; x < 7; x++) {
    table[x]();
    delay(100);
  }
}

void loop() {
  WiFlyClient client = server.available();

  if(client){
    while(client.connected()) {
      if(client.available()) {
        client.println("
Hi

This is text.
");
      }
    }
    delay(100);
    client.flush();
    client.stop();
  }
}

This compiles well, but when hitting 192.168.1.123 in my web browser I get an ever-increasing output like:
*HELLO*<
<
<
<
<
<
<
<
<
<
<
< (cont.)

Definitely not the expected html. I have been playing with this code for hours now and this is the most positive output I can get. If I do a Serial.write(client.read()) within if(client.available()) { I am able to print all the request information to the serial monitor, it just seems I am perhaps sending the data in an incorrect format? Any suggestions? Cheers
Edit
I have updated the codebase to include the http headers,
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println("");
client.println("<!DOCTYPE html>");
client.println("
Hi.....

now I get I different (similar) output, seems like it is printing the first character of each new line
*HELLO*H
C
C

<
<
H
C
C

A web server sends more than just HTML. It sends all the HTTP headers as well, which you seem to be missing.

@Majenko Added the http headers, check the edit

You still aren't outputting it right. There has to be a single blank line between the headers and the body to separate them.

@Majenko check now

Your browser sent a HTTP GET request. You need to send a HTTP response in kind, in accordance with the protocol, for your browser to correctly interpret the data. Something like this should do:
  #define TIMEOUT 100
  char response[] = "
Hi

This is text.
";
  unsigned long lastRead;
  ...

  while (client.connected()){
    if (client.available()){
      lastRead = millis();
      while (millis() - lastRead < TIMEOUT){
        while (client.available()){
          Serial.write(client.read());
          lastRead = millis();
        }
      }
      client.println("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: closed\r\n\r\n");
      client.print(response);
      break;
    }
  }
  delay(1000);
  client.stop();

EDIT:
It turns out that the Wifly shield sends a response status as well as "HELLO" by default. You have to disable that with a few commands:
set comm remote 0
set comm open 0
set comm close 0

This will ensure that "HELLO" isnt sent each time a client connection is made, though I'm not sure if this affects the default HTTP/0.9 200 OK response status that is always sent. You can try the sketch above with and without the response header to see what you get.

Hey, appreciate your answer -- I tried this but my browser just hangs

Weird, so with client.println("<!DOCTYPE html>"); I get a response, but again it looks like: `HELLOH
S
C5
C
<
<H
S
C5
C`

the serial monitor looks good: GET / HTTP/1.1 Host: 192.168.1.123 Connection: keep-alive Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8  but the browser still hangs

With the timer it seems to hang regardless of the <!DOCTYPE html>, and yeah the browser renders the html fine :j

@WilliamPaul How about this? I changed the timeout and the print()s

Okay, so the timer still causes the browser to hang, but without that and with the updated http header I get: *HELLO*S H <H <H <H <H <H (more than one char on a line)

@WilliamPaul I've edited the answer


text:
Cannot open file with underscores using the SD library
So I'm trying to create a new file that has underscores in its name. However, when I try this, no file is created.
This works
String fileName = "NMEA.txt";
mySensorData = SD.open(fileName.c_str(), FILE_WRITE);

This does not work
String fileName = "NMEA__23_33_3__16_7_29.txt";
mySensorData = SD.open(fileName.c_str(), FILE_WRITE);

Does anyone know why?

[The SD library] uses short 8.3 names for files.

source

Do you have any tips on how I can organize my files then? As you can see in the above format, I have it as NMEA__hr_mn_ss__yr_mm_dd.txt.

I tried String fileName = "/23_33_3/16_7_29/NMEA.txt" to organize it by directory and it doesn't seem to create them.

Have you actually created those directories? It won't magically make them for you...


text:
Connect USB cable to GPIO pins on an Arduino Uno
Electronics Newbie!!
I want to connect a USB cable to my Uno's GPIO pins (and then connect it to a USB port on my computer). I have chopped off a USB cable from a keyboard, I read this and I'm hoping that the wires will be in the correct order (the keyboard was made by Dell). I'm a little confused about which wires go where.

What are you trying to achieve? The link is about power on a USB cable.

What is the purpose of doing that? Using 5v signals on the USB data lines isn't allowed in the USB-specification. You at least need to use a multi-meter to measure which wire, is connected to which pin on the USB socket, as the color-coding isn't always the same.

Take some help from attiny designs with USB; http://electronics.stackexchange.com/questions/84663/firmware-circuit-of-attiny45-direct-usb-2-0-connection

The reason you are confused about which wires go where is simply because the Uno has no connection on it for a USB cable's wires.
You cannot directly interface an Uno to a USB port without extra hardware.  What hardware you require depends on exactly what it is you think you are trying to achieve.
(There have been some attempts to create a USB device interface purely in software, but personally I wouldn't touch it with a barge pole - the GPIO of the Arduino is not electrically compatible with USB.)


text:
can teensy 3.0 or above run fingerprint scanner fps gt-511c1r?
I have an fps gt-511c1r fingerprint sensor module. I want to know whether i can run it using teensy 3.0 or above?
I have tried it successfully using arduino uno.
EDIT: I have uploaded the fps blink sketch on the teensy 3.2 successfully, but the fingerprint scanner is not responding. Here is the code:-
         #include "FPS_GT511C3.h"
         #include "SoftwareSerial.h"
     // Hardware setup - FPS connected to:
     //   digital pin 0(arduino rx, fps tx)
     //   digital pin 1(arduino tx, fps rx)

     FPS_GT511C3 fps(0, 1);

     void setup()
     {
         Serial.begin(9600);
         fps.UseSerialDebug = true;
         fps.Open();
     }

     void loop()
     {
        // FPS Blink LED Test
        fps.SetLED(true);
         delay(1000);
         fps.SetLED(false);
         delay(1000);
     }

connected fps tx to teensy rx(pin 0),
          fps rx to teensy tx(pin 1),
          fps vcc to 3.3v teensy,
          fps gnd to teensy gnd.

Have you tried it on a teensy?

As something with a UART interface there should be very little hardware dependence - presumably the hardware serial library on the Teensy works.  You might avoid or re-work sketches that try to use software serial though, since the Teensy has plenty of hardware serial ports.

Your library looks to be using software serial internally, that is probably not what you want on a Teensy where you have plenty of real UARTs.  Or at least, if you are going to do it that way, make sure you use a version that works on the Teensy ina  way that works on the Teensy.  Some web search research is in order.

Please can u guide me as to how to disable the software serial?

The GT-511C1R is a 5V device. The Teensy 3.0 is a 3.3V device. You will require some level shifting as you would with any 3.3V Arduino connecting to a 5V device.
Besides that, yes, the Teensy 3.0 is more than capable of working with the fingerprint scanner. Will the software work? Most likely, but only trying it will confirm that.

Thank you very much:) i'll definitely try n tell if it works..

What makes you say that "The GT-511C1R is a 5V device" ?  The data sheet says "DC 3.3~6v"

The spark fun site says 5v.

I tried a simple blink code for the fingerprint scanner. It uploaded successfully but there is no response from the scanner:( I uploaded the same code on the arduino uno and powered the scanner with 3.3v and it works. So why isnt it working with teeny?? Even though the sketch is uploaded?

Because you did something wrong, obviously. I have no idea what you did, though, so I don't know what part of it was done wrong.

Can the reason be that teensy is 32 bit for a word whereas the gt-511c1r is a 16 bit for a word?

I don't know. I still can't see what it is you are doing, what your code is, how you have wired it up, nothing.


text:
Arduino Pro Mini interrupts timer not working
i am trying to make an arduino pro mini sd card serial logger.The arduino should log the data that comes over the uart and write it to an sd card and if it is no data on the serial for 25 seconds to save automatically the data into the file.Each file are named diffrent every time they are saved(for example datalog0.txt, datalog1.txt and so on).I am creating also at the start of the sketch an config(config.txt) file where the number of the file present of the sd are stored and if the file already exist than a new one will be created, this option works good.Now, after the 25 seconds past and it is no more  data over the serial the arduino dont close the datalog.txt file , so the next data will be saved in the same file, this is the problem i have, even in the config file the file number will be increased.I will attach the sketch and expect patient from you, ai am still newbie.I forgot to mention that it was working good for some time but not anymore, the only thing i did was to upload the bootloader from ide and since than is not working anymore.
Regards.
//#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <string.h>
#include <SoftwareSerial.h>

            int i;
            int incomingByte = 0;
//int data[512];
            File myFile;
            unsigned char bytes,flag_again;
            unsigned int fileNo,timer_count;
            String s_fileNo,filename,filename_master;
            char comanda;

            void Timer1_InIt()
        {
            TCCR1A = 0;
            TCCR1B = 0;
            TCNT1  = 0;
            OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
            TCCR1B |= (1 << WGM12);
                TCCR1B |= (1 << CS12) | (1 << CS10);
                //TIMSK1 |= (1 << OCIE1A);
            }

ISR(TIMER1_COMPA_vect)
{
    timer_count++;
    if(timer_count > 25)
    {
        timer_count = 0;
        TIMSK1 &= ~(1 << OCIE1A);
        myFile.close();
        fileNo++;
        myFile = SD.open("config.txt",FILE_WRITE);
        myFile.seek(0);
        myFile.print(fileNo);
        myFile.close();
        //software_Reset() ;    //reset the sketch
    }
}
SoftwareSerial mySerial(4, 5); // RX, TX

void setup()
{
    cli();
    Timer1_InIt();
    sei();

    mySerial.begin(9600);
    Serial.begin(10752,SERIAL_8E2);
    //mySerial.print("Initializing SD card...");

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

    myFile = SD.open("config.txt",FILE_READ);
// mySerial.println("Config file created");
    if(!myFile.available())
        bytes = 0;
    else
    {
        bytes = myFile.available();
        for(i = 0; i< bytes ; i++)
            s_fileNo += (char)myFile.read();
    }
    myFile.close();
    fileNo = s_fileNo.toInt();
// mySerial.print("file no:");
    //mySerial.println(fileNo);

    filename = "datalog";
    filename += fileNo;
    filename += ".txt";

    myFile = SD.open(filename,FILE_WRITE);
    if (myFile)
    {
        //mySerial.print(filename);
        //mySerial.println(" File Open...");
    }
}

void loop()
{

    if(!myFile)
        myFile = SD.open(filename, FILE_WRITE);

    while(Serial.available())
    {
        incomingByte = Serial.read();
        /*if(incomingByte == 0 || incomingByte < 15 )
        {
          Serial.print('0');
          myFile.print(0,HEX);
        }*/
        //mySerial.println(incomingByte,HEX);
        myFile.println(incomingByte,HEX);
        // myFile.println(incomingByte);
        timer_count = 0;
        flag_again = 1;
    }
    if(!Serial.available() && flag_again)
    {
        TIMSK1 |= (1 << OCIE1A);
        flag_again = 0;
    }

}

Doing these kinds of thing inside the ISR is asking for problems. Just store the timestamp (millis) of the last time you received serial data, then if the time difference between the current time and that timestamp is more that 25000ms create a new file.

Thank you very much for your answer,can i ask you to give an example to my sketch?i am not very experienced Regards.

Also filename is never changed, so it wouldn't even work properly.

In untested (pseudo-)code
unsigned long lastSerialInput = millis();

void loop()
{

    if(!myFile)
        myFile = SD.open(filename, FILE_WRITE);

    while(Serial.available())
    {
        incomingByte = Serial.read();
        myFile.println(incomingByte,HEX);

        lastSerialInput = millis();
    }

    // check for 25 seconds of inactivity
    if( myFile && (millis()-lastSerialInput > 25000 )
    {
        myFile.close();
        fileNo++;
        filename = "datalog";
        filename += fileNo;
        filename += ".txt";

        //save new fileNo to config.txt (though I'd personally find the file with the largest number in setup instead of relying on a config.txt file)
    }

}


text:
Large values are changed by Arduino when viewing with `Serial.print()`
Why are (big) values being changed?
I tried out printing some values and noticed bigger values are changed more, they seem to be rounded to quarters and then to halves when the value gets bigger.
MWE
void setup() {
  Serial.begin(9600);
  Serial.print("12457591.51 is changed into ");
  Serial.println(12457591.51);
  Serial.print("2457591.80 is changed into ");
  Serial.println(2457591.80);
  Serial.print("1234567.89 is changed into ");
  Serial.println(1234567.89);
}

void loop() {}

gives me
12457591.51 is changed into 12457592.00
2457591.80 is changed into 2457591.75
1234567.89 is changed into 1234567.87

I'm working with an Arduino Nano ATMega328.
Background
I need the calculation (2457591.33 + 0.5 - 2440588)  * 60 * 60 * 24 to be precise to within preferably a hundred, but currently it's off by about 7000.

Floating point numbers doesn't have infinite precision. But you can always change your equation to use smaller numbers (preferably integers or longs as floating point is extremely slow)
For example on AVR Freaks they mentioned precision about 6 or 7 digits. It makes sense as 24bits signed number range is from -8388608 to 8388607

Of course they don't have infinite precision, but floats should have precision after the dot, right? I thought that's where floats were for. I don't mind speed at all but I understand ints or longs are better, so I'll try to convert the calculation to use longs. Do I understand correctly that the answer is that floats do not have precision when working with more than say 6 digits?

Only small numbers have some precision after the dot. Big ones doesn't have precision even before the dot.

Saw your edit, that makes sense, hadn't thought of that. Thanks!


text:
WDT & Software RESET in ESP8266 + Arduino IDE
I am working on ESP8266 in Arduino IDE. I want to know how to Software RESET the ESP8266. Any sketch/example would be useful. Moreover, how to initialise WDT in ESP8266.
Kindly help!

Software reset in ESP8266 is achieved using ESP.reset()
as per WDT, the other answer has info on that, i.e. software WDT is cleared using yield() - hardware WDT is not accessible through software


text:
is the Arduino shield pinout a standard, so that any Arduino shield can work with any Arduino board
I'm new to Arduino and dying to delve in.
There are lots of Arduino base board vendors, and lots of shield vendors.
In general, should I be able to plug any shield into any Arduino board, even with existing shields?

No, they are not standard - not entirely - although there have been some attempts to make them more standard.
Some things to watch out for:

SPI

The Uno originally had SPI on pins 10-13
The Mega had it on another COMMS header instead

SPI has now been standardized to the 6-pin ICSP header, though not all shields honour that, and still use pins 10-13 instead, so they won't work on boards like the Mega

I2C

The Uno has I2C on pins A4/A5
The Mega has it on the COMMS header instead

I2C has now been standardized on a special pair of pins added to the end of the digital IO header (pins 8-13 + GND + AREF) though many shields still look for it on pins A4/A5, so they won't work on boards like the Mega
Some other boards, like the Leonardo, also have these (and other) functions on other pins, so may not work with some shields that don't use the SPI / I2C headers.
The basic functions, though, i.e., digital IO and analog inputs and UART 1 are all in the same places on the majority of boards, and most have PWM in the same places too. But you can't rely on any thing more than that between any two boards.

Most shields will fit most of the "regular sized" boards. the obvious exception is the boards like the nano which are tiny. Shields are going to have the best compatibility with the Uno, just because that one is the most common, so if you are going to get one arduino and a bunch of shields, get an uno. Some shields (the gen 1 ethernet and wifi shields in particular had an issue where they could not be used on Megas because the mega listens to SPI on pins 50+ which simply were not connected to the shield, however most of the newer shields will connect to the 6-pin block in the center now-adays to allow Mega usage.
The next thing you want to look at is if you are stacking shields, if they will collide on pin usage (SPI gets around this through multiplexing) and some of the 3.3 volt devices may have conflicts with 5-volt shields. Although the 3.3v devices do provide 5v power-out pins in the same locations as the Uno, it becomes more of an issue with trying to read a 5v on a 3.3v pin, which could damage the microchip.
the best thing to do is to check the documentation of the shields and check which pins they use, what voltages they need/supply, and comparing this with the particular arduino you are using.

Also a great answer


text:
Who makes this cool Arduino display shield, and what model is it?
Anyone recognize Mfgr/model of this display that reads: "Wireless Internet Of Things".  The Arduino board is a WIOT.
I've been looking and looking for a source for Arduino display like this, but cannot find.

If you google for "Arduino OLED Blue" you get hundreds of similar displays.

That will be an SSD1306 based blue OLED display with SPI interface. There's lots of them around by lots of different people. Some are I2C interface, and some of those have a "broken" I2C interface that doesn't send ACKs (especially cheap ones on eBay) and need a special ACK-less Software I2C implementation.
The SPI ones, of course, won't suffer from that problem.
They are generally 0.96" diagonal, and that one, I think, is 96x39 pixels (or it may be 128x64).


text:
4 channel Remote Control
I'm trying to make a 4 channel RC using Arduino and nrf24L01 module.
I already know how to deal with this module, but the question is "What does 4 channel mean ?", and how to make it supports 4 channel ?

Sounds like a class assignment? You might need to ask your teacher what is expected :)

4 channel means having the ability to send 4 individual values (maybe speeds?) at once.
Since the nRF24L01+ is a packet based system it is as simple as sending the different "channels" as different bytes (or groups of bytes if more than 0-255 or -128 to +127 is needed).
For instance, if you want 4 channels that can represent 0-255 then you need 4 bytes, and so you can set both sender and receiver to have a packet size of 4 bytes (for efficiency) and send a packet made up of the 4 channel values.
If you want to represent numbers bigger than that then you need to split the variable into bytes (two bytes for an int, 4 for a long) or create a struct to represent your packet of data. Of course you then need the sender and receiver to be set to a packet size at least big enough to contain the data, and both ends must agree on the packet size.

'Channel' here probably refers to something like these RF module types: http://electronics-diy.com/store/4-Channel_RF_Remote_Control.jpg. More like 4 bits/states really and a lot more direct than the NRF24 and far below its capabilities; there's no direct translation, I think.

@TisteAndii That then is just 4 values of a single bit resolution. It could be sent as the lower nibble of one byte in an nRF24L01+ packet. 'Channel' usually refers to one "pipe" of data values, such as in a radio control plane: pitch, yaw, roll, throttle (or tail flaps, tail fin, ailerons, engine). I suspect this is a (somewhat better) reposting of an earlier question that I cannot find now (probably closed and deleted) which was wanting to communicate with 4 channels for motor control or something. Or if not, the circumstances seem so similar as to make me think it's the same assignment.

You're right. I guess I just thought buying this module only for sending 4 bits is a bit wasteful, unless its for the range. But since the capacity is already being wasted, they might as well use 1 reading pipe per bit at the receiver. Have the transmitter use the pipe 0 to write a bit (a byte, really) to each of the receiver's 4 reading pipes, to better sell the whole '4-channel nRF equivalent'.

The whole concept of "channels" only has any real meaning when talking about analog communications anyway. With digital it's all packets. "Channel" is used to indicate the precise frequency it operates on.


text:
Send sensor information to processing
I am currently working on an Arduino project where the Arduino will send data to a processing program via bluetooth and processing will draw the data. However, my code doesn't seem to work.
Here is my Arduino code:
#include <SoftwareSerial.h>

int bluetoothTx = 1;
int bluetoothRx = 0;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

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

void loop() {
  Serial.println("Hello");
}

And here is my Processing code:
import processing.serial.*;
Serial myPort;

void setup() {
  myPort = new Serial(this, "COM42", 9600);
  myPort.bufferUntil('\n');
}

void serialEvent( Serial myPort) {
  String data = myPort.readStringUntil('\n');
  println(data);
}

I identified that the incoming port from the HC-05 module is "COM42" from my Bluetooth settings. I am expecting to see several "Hello" lines being printed on the processing console but this does not happen

Your whole sending program is a complete mess, sorry to say:
First you create a SoftwareSerial port using the HardwareSerial pins. (Why on earth would you do that?)
Then you "begin" that SoftwareSerial port.
Finally you try and print Hello through the HardwareSerial port!
Either use SoftwareSerial OR use the hardware UART. You can't mix and match both. And since you are using the hardware UART pins, why even consider using SoftwareSerial?
void setup() {
    Serial.begin(9600);
}

void loop() {
    Serial.println("Hello");
}

OR, to use other pins than 0 and 1:
#include <SoftwareSerial.h>

const int bluetoothTx = 2;
const int bluetoothRx = 3;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

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

void loop() {
    bluetooth.println("Hello");
}

This worked! But can you please explain why it didn't work at the first place? Also, the modified code didn't work till after I modified the COM port to be the "outgoing" one as seen in my Bluetooth settings, why is that?

Before you had turned on the hot tap on the bath and were wondering why the toilet hadn't flushed. You had created and configured a software "bit banged" serial interface, but then proceeded to attempt to send the data down the unconfigured and disabled hardware UART.


text:
What's with the debug error messages, like VMDPE_1|1_VMDPE?
I'm using visual micro for visual studio, and I understand this kind of thing is caused by conflicting serial data when I try to read and print to the main serial at the same time, right?
Well, I need to read serial data from the main serial on my Mega 2560, and then I need to see it on my LCD screen, which is controlled by the board via SPI. I know I can use those two at the same time because I'm doing it with my transmitting arduino and I can see that it's transmitting correctly.
When I try to view my serial data in the serial port, I get nothing but a stream of these error codes, or whatever they are. They generally look like this: VMDPE_1|1_VMDPE. Usually there are some numbers in there too, like: MDPE_1|2571143_VMDPE. I sort of expected that, since you can't read and write at the same time on one serial. But that would be fine, because my project is not going to be plugged into a PC anyway.
So of course I try to pipe my data directly to the LCD screen so I can plug my recieving arduino into external power and not have to see the error messages, which I thought were coming from the debugger of my compiler. Here's my code:
//on the receiver side

#include <stdint.h>
#include <TFTv2.h>
#include <SPI.h>

char incoming[3];

void setup() {
    Serial.begin(9600);
    //TFT_BL_ON;      // turn on the background light
    //Tft.TFTinit();  // init TFT library
    //Tft.setDisplayDirect(DOWN2UP);
    //TFT_BL_ON;      // turn on the background light
    //Tft.drawString("INCOMING:", 20, 301, 3, RED);
    Serial.println(incoming);

}

void loop() {

    if (Serial.available()) {

        Serial.readBytesUntil(',', incoming, 3 ) ;

        //Tft.fillRectangle(64, 236, 45, 165, BLACK);

        //Tft.drawString(incoming, 65, 235, 4, WHITE);
        Serial.println(incoming);

    }
}

But nope! I get the same error codes on my LCD screen! Even worse, now they seem to have screwed up my zigbee module! I took it off the board, plugged it into my computer, and now the XCTU utility is reading all sorts of messed up values that are total nonsense. Somehow, this seems to have overwritten the zigbee's actual SERIAL NUMBERS!!! What are they now? Take a guess!
Serial number high: E_1|2571092_VMDPE
Serial number low:  MDPE_1|2571143_VMDPE

Your incoming buffer is not big enough to handle the data that you're giving it. Cutting away the comments from your code:
char incoming[3];

This declares a buffer for two characters, allowing for the (required) 0 on the end. println() needs to know when to stop printing characters: it does this when it sees a NUL (0) character.
Serial.readBytesUntil(',', incoming, 3 ) ;

You're passing in that you want to read 3 characters - but that completely fills incoming, leaving no room for the trailing NUL (0).
Serial.println(incoming);

This then prints the first character, the second character, the third character... then the 4th, 5th, 6th, 7th etc. in memory until it finally reaches a NUL and then quits.
What you call "debug messages" are actually printed gibberish in memory... To fix it, you need to make incoming larger.
Also, it's a good idea when using buffers like this to use the sizeof() function, as follows:
Serial.readBytesUntil(',', incoming, sizeof(incoming)-1 ) ; // Note the -1!

Thanks!I see what you mean about the buffer overflow.Last night I loaded both my arduinos using "start without debugging", and the output changed to something more like numbers, bit also gibberish.
I do believe the "VMDPE_1|1_VMDPE" stuff is some kind of VisualMicro-specific error related to debugging.I have a big sketch, and it prints on the serial every time I flash the board. I read about it here: http://www.visualmicro.com/forums/YaBB.pl?num=1365950696/0
I still have no idea how it got into my sketch while not hooked up to PC, or how it invaded my Zigbee!

"I still have no idea how it got into my sketch while not hooked up to PC" Because Visual Micro's debugging works by adding a bunch of hidden serial prints to your sketch. Once you upload the sketch to your board they will be in the flash whether it's connected to your PC or not.

I have seen the same messages, using VS2017 and Arduino Unu and Visual Micro. Messages start with "DPV..." or "VMDPV...".
The solution is to upload the sketch to the Arduino using Release mode. Then the hidden debug serial prints that Visual Micro seems to put in are gone.

This might hide the unwanted output, but it is not a solution the the question.

I had the same problem. The problem seems to come from AVR Studio serial debugging. If you turn off the serial debugger the problem will go away. Remember to also turn of "Automatic Software Debugging (Release/Debug)", as shown below.

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


text:
Help me restructure code for multitasking Neopixel + IR remote + arduino
First of all, I'm completely new to both arduino, and programing. Second, as for a good newbie, i'm trying to build a fairly complicated project. So, any help and suggestion is welcome. The goal is: light up a shelf, with 2x 1m led strip, with 2 different "fire" animation. And remote control the arduino to switch between effects and colors.
The state of the project so far https://circuits.io/circuits/2459366-arduino-ir-with-neopixel
I learned one arduino is not enough to decode IR signals and drive led strips. So, I'm using two. Successfully merged 2 sketches: one, that receives, decodes and sends the IR signal to another arduino.
And based on tutorial https://learn.adafruit.com/multi-tasking-the-arduino-part-3/put-it-all-together-dot-dot-dot
I managed to control the LEDs via IR remote control. Here is code currently using (a bit bloated since its contains all the effect from the tutorial.)
Here is code so far:
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#define I2C_SLAVE_ADDRESS 8

// Remote control button codes
const unsigned int BUTTON_1 = 0xFD08F7;
const unsigned int BUTTON_2 = 0xFD8877;
const unsigned int BUTTON_3 = 0xFD48B7;
const unsigned int BUTTON_4 = 0xFD28D7;
const unsigned int BUTTON_5 = 0xFDA857;
const unsigned int BUTTON_6 = 0xFD6897;
const unsigned int BUTTON_7 = 0xFD18E7;
const unsigned int BUTTON_8 = 0xFD9867;
const unsigned int BUTTON_9 = 0xFD58A7;
const unsigned int BUTTON_UP = 0xFD50AF;
const unsigned int BUTTON_DOWN = 0xFD10EF;
const unsigned int BUTTON_VOL = 0xFD906F;

int t = 0; // variable for switching led rings with the remote
int b = 255; // brigtness starting value
// IR received code
unsigned int irCode = 0;            //ir code ends here
// Pattern types supported:
enum  pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, FIRE };
// Patern directions supported:
enum  direction { FORWARD, REVERSE };

// NeoPattern Class - derived from the Adafruit_NeoPixel class
class NeoPatterns : public Adafruit_NeoPixel
{
    public:

    // Member Variables:
    pattern  ActivePattern;  // which pattern is running
    direction Direction;     // direction to run the pattern

    unsigned long Interval;   // milliseconds between updates
    unsigned long lastUpdate; // last update of position

    uint32_t Color1, Color2;  // What colors are in use
    uint16_t TotalSteps;  // total number of steps in the pattern
    uint16_t Index;  // current step within the pattern

    void (*OnComplete)();  // Callback on completion of pattern

    // Constructor - calls base-class constructor to initialize strip
    NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)())
    :Adafruit_NeoPixel(pixels, pin, type)
    {
        OnComplete = callback;
    }

    // Update the pattern
    void Update()
    {
        if((millis() - lastUpdate) > Interval) // time to update
        {
            lastUpdate = millis();
            switch(ActivePattern)
            {
                case RAINBOW_CYCLE:
                    RainbowCycleUpdate();
                    break;
                case THEATER_CHASE:
                    TheaterChaseUpdate();
                    break;
                case COLOR_WIPE:
                    ColorWipeUpdate();
                    break;
                case SCANNER:
                    ScannerUpdate();
                    break;
                case FADE:
                    FadeUpdate();
            case FIRE:
                    RainbowCycleUpdate();
                    break;
                default:
                    break;
            }
        }
    }

    // Increment the Index and reset at the end
    void Increment()
    {
        if (Direction == FORWARD)
        {
           Index++;
           if (Index >= TotalSteps)
            {
                Index = 0;
                if (OnComplete != NULL)
                {
                    OnComplete(); // call the comlpetion callback
                }
            }
        }
        else // Direction == REVERSE
        {
            --Index;
            if (Index <= 0)
            {
                Index = TotalSteps-1;
                if (OnComplete != NULL)
                {
                    OnComplete(); // call the comlpetion callback
                }
            }
        }
    }

    // Reverse pattern direction
    void Reverse()
    {
        if (Direction == FORWARD)
        {
            Direction = REVERSE;
            Index = TotalSteps-1;
        }
        else
        {
            Direction = FORWARD;
            Index = 0;
        }
    }

    // Initialize for a RainbowCycle
    void RainbowCycle(uint8_t interval, direction dir = FORWARD)
    {
        ActivePattern = RAINBOW_CYCLE;
        Interval = interval;
        TotalSteps = 255;
        Index = 0;
        Direction = dir;
    }

    // Update the Rainbow Cycle Pattern
    void RainbowCycleUpdate()
    {
        for(int i=0; i< numPixels(); i++)
        {
            setPixelColor(i, Wheel(((i * 256 / numPixels()) + Index) & 255));
        }
        show();
        Increment();
    }

    // Initialize for a Theater Chase
    void TheaterChase(uint32_t color1, uint32_t color2, uint8_t interval, direction dir = FORWARD)
    {
        ActivePattern = THEATER_CHASE;
        Interval = interval;
        TotalSteps = numPixels();
        Color1 = color1;
        Color2 = color2;
        Index = 0;
        Direction = dir;
   }

    // Update the Theater Chase Pattern
    void TheaterChaseUpdate()
    {
        for(int i=0; i< numPixels(); i++)
        {
            if ((i + Index) % 3 == 0)
            {
                setPixelColor(i, Color1);
            }
            else
            {
                setPixelColor(i, Color2);
            }
        }
        show();
        Increment();
    }

    // Initialize for a ColorWipe
    void ColorWipe(uint32_t color, uint8_t interval, direction dir = FORWARD)
    {
        ActivePattern = COLOR_WIPE;
        Interval = interval;
        TotalSteps = numPixels();
        Color1 = color;
        Index = 0;
        Direction = dir;
    }

    // Update the Color Wipe Pattern
    void ColorWipeUpdate()
    {
        setPixelColor(Index, Color1);
        show();
        Increment();
    }

    // Initialize for a SCANNNER
    void Scanner(uint32_t color1, uint8_t interval)
    {
        ActivePattern = SCANNER;
        Interval = interval;
        TotalSteps = (numPixels() - 1) * 2;
        Color1 = color1;
        Index = 0;
    }

    // Update the Scanner Pattern
    void ScannerUpdate()
    {
        for (int i = 0; i < numPixels(); i++)
        {
            if (i == Index)  // Scan Pixel to the right
            {
                 setPixelColor(i, Color1);
            }
            else if (i == TotalSteps - Index) // Scan Pixel to the left
            {
                 setPixelColor(i, Color1);
            }
            else // Fading tail
            {
                 setPixelColor(i, DimColor(getPixelColor(i)));
            }
        }
        show();
        Increment();
    }

    // Initialize for a Fade
    void Fade(uint32_t color1, uint32_t color2, uint16_t steps, uint8_t interval, direction dir = FORWARD)
    {
        ActivePattern = FADE;
        Interval = interval;
        TotalSteps = steps;
        Color1 = color1;
        Color2 = color2;
        Index = 0;
        Direction = dir;
    }

    // Update the Fade Pattern
    void FadeUpdate()
    {
        // Calculate linear interpolation between Color1 and Color2
        // Optimise order of operations to minimize truncation error
        uint8_t red = ((Red(Color1) * (TotalSteps - Index)) + (Red(Color2) * Index)) / TotalSteps;
        uint8_t green = ((Green(Color1) * (TotalSteps - Index)) + (Green(Color2) * Index)) / TotalSteps;
        uint8_t blue = ((Blue(Color1) * (TotalSteps - Index)) + (Blue(Color2) * Index)) / TotalSteps;

        ColorSet(Color(red, green, blue));
        show();
        Increment();
    }

    // Calculate 50% dimmed version of a color (used by ScannerUpdate)
    uint32_t DimColor(uint32_t color)
    {
        // Shift R, G and B components one bit to the right
        uint32_t dimColor = Color(Red(color) >> 1, Green(color) >> 1, Blue(color) >> 1);
        return dimColor;
    }

    // Set all pixels to a color (synchronously)
    void ColorSet(uint32_t color)
    {
        for (int i = 0; i < numPixels(); i++)
        {
            setPixelColor(i, color);
        }
        show();
    }

    // Returns the Red component of a 32-bit color
    uint8_t Red(uint32_t color)
    {
        return (color >> 16) & 0xFF;
    }

    // Returns the Green component of a 32-bit color
    uint8_t Green(uint32_t color)
    {
        return (color >> 8) & 0xFF;
    }

    // Returns the Blue component of a 32-bit color
    uint8_t Blue(uint32_t color)
    {
        return color & 0xFF;
    }

    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos)
    {
        WheelPos = 255 - WheelPos;
        if(WheelPos < 85)
        {
            return Color(255 - WheelPos * 3, 0, WheelPos * 3);
        }
        else if(WheelPos < 170)
        {
            WheelPos -= 85;
            return Color(0, WheelPos * 3, 255 - WheelPos * 3);
        }
        else
        {
            WheelPos -= 170;
            return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
        }
    }

   // brightness, need some improvements probably
   void incbrigtness() {
   if (b >= 255) {
      b = 255;
   setBrightness(b);}
   else {b = b + 10;
   setBrightness(b);}
   }

   void decbrigtness() {
   if (b <= 5) {
      b = 5;
   setBrightness(b);}
   else {b = b - 10;
   setBrightness(b);}
   }

};

void Ring1Complete();
void Ring2Complete();

void receiveEvent(int numBytes) {//decode the ir signal
  byte byte1 = Wire.read();
  byte byte2 = Wire.read();
  irCode = byte2;
  irCode = irCode << 8;
  irCode = irCode | byte1;
}

// Define some NeoPatterns for the two rings and the stick
//  as well as some completion routines
NeoPatterns Ring1(24, 6, NEO_GRB + NEO_KHZ800, &Ring1Complete); // led parameters
NeoPatterns Ring2(24, 7, NEO_GRB + NEO_KHZ800, &Ring2Complete);

// Initialize everything and prepare to start
void setup()
{
   Serial.begin(9600);
   Serial.println("my-main-program starting!");
   Wire.begin(I2C_SLAVE_ADDRESS);
   Wire.onReceive(receiveEvent);
   Serial.println("my-main-program successfully started!");
 }
// Main loop
void loop()
{
    // Update the rings.
   if (irCode) {             //Reads the ir code
    handleButton(irCode);
    irCode = 0;
  }
 Ring1.Update();
 Ring2.Update();
 }

void handleButton(unsigned int irCode) {
  switch (irCode) {
   case BUTTON_UP:      // button up  will control led stip 1, button 2 will control let strip 2, button 3 both.
      t = 1;
     Serial.println(t);
     break;
   case BUTTON_DOWN:
      t = 2;
     Serial.println(t);
      break;
   case BUTTON_VOL:
     t = 0;
      Serial.println(t);
     break;
   case BUTTON_1:
     if (t == 1) {    // this also needs some improvements
      Serial.println(t);
     Ring1.TheaterChase(Ring1.Color(0,255,0), Ring1.Color(0,0,50), 100);
      }
     else if (t == 2) {
     Serial.println(t);
     Ring2.TheaterChase(Ring1.Color(255,0,0), Ring1.Color(0,50,0), 100);
      }
     else {      // some random effects for testing
     Serial.println(t);
      Ring1.TheaterChase(Ring1.Color(0,0,255), Ring1.Color(50,0,0), 100);
     Ring2.TheaterChase(Ring1.Color(0,0,255), Ring1.Color(50,0,0), 100);
      }
   break;
    case BUTTON_2:
      Serial.println("2");
       Ring1.Scanner(Ring1.Color(255,0,0), 55);
     break;
    case BUTTON_3:
     Ring1.ColorWipe(Ring1.Color(0,255,255), 55);
     Serial.println("3");
      break;
    case BUTTON_4:
      Ring1.Scanner(Ring1.Color(0,255,255), 55);
     Serial.println("4");
      break;
    case BUTTON_5:
      Serial.println("5");
      break;
    case BUTTON_6:
      Serial.println("6");
      break;
    case BUTTON_7:
      Serial.println("7");
      break;
    case BUTTON_8:         //  test the brightness here.
   Ring1.incbrigtness();
   Serial.println(b);
     break;
    case BUTTON_9:
   Ring1.decbrigtness();
   Serial.println(b);
     break;
    default:
      Serial.print("Unrecognized code received: 0x");
      Serial.println(irCode, HEX);
      break;
  }
}

//------------------------------------------------------------
//Completion Routines - get called on completion of a pattern
//------------------------------------------------------------

// Ring1 Completion Callback
void Ring1Complete() //dont really need to do anything specific after loop ended so should go back to update.
{Ring1.Update(); }

void Ring2Complete()
{Ring2.Update(); }

The problem:
What I need is help, how to restructure 2 different effects. to fit into the above code. Loops replaced wilth millis() and delay with an updater.
here is the first, fire code by danesparza:
#include <Adafruit_NeoPixel.h>
#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(29, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.setBrightness(brightness);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {

  //  Uncomment one of these RGB (Red, Green, Blue) values to
  //  set the base color of the flame.  The color will flickr
  //  based on the initial base color

  //  Regular (orange) flame:
  //  int r = 226, g = 121, b = 35;

  //  Purple flame:
  //  int r = 158, g = 8, b = 148;

  //  Green flame:
  int r = 74, g = 150, b = 12;

  //  Flicker, based on our initial RGB values
  for(int i=0; i<strip.numPixels(); i++) {
    int flicker = random(0,55);
    int r1 = r-flicker;
    int g1 = g-flicker;
    int b1 = b-flicker;
    if(g1<0) g1=0;
    if(r1<0) r1=0;
    if(b1<0) b1=0;
    strip.setPixelColor(i,r1,g1, b1);
  }
  strip.show();

  //  Adjust the delay here, if you'd like.  Right now, it randomizes the
  //  color switch delay to give a sense of realism
  delay(random(10,113));
}

And a ripple effect that needs a restructure by suhajdab
#include <Adafruit_NeoPixel.h>
#define PIN 2
#define Pixels 24
#define BG 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);

int color;
int center = 0;
int step = -1;
int maxSteps = 16;
float fadeRate = 0.6;
int diff;

//background color
uint32_t currentBg = random(256);
uint32_t nextBg = currentBg;

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop () {
  ripple();
}

void ripple() {
  if (BG){
    if (currentBg == nextBg) {
      nextBg = random(256);
    }
    else if (nextBg > currentBg) {
      currentBg++;
    } else {
      currentBg--;
    }
    for(uint16_t l = 0; l < Pixels; l++) {
      strip.setPixelColor(l, Wheel(currentBg, 0.1));
    }
  } else {
    for(uint16_t l = 0; l < Pixels; l++) {
      strip.setPixelColor(l, 0, 0, 0);
    }
  }

  if (step == -1) {
    center = random(Pixels);
    color = random(256);
    step = 0;
  }

  if (step == 0) {
    strip.setPixelColor(center, Wheel(color, 1));
    step ++;
  }
  else {
    if (step < maxSteps) {
      strip.setPixelColor(wrap(center + step), Wheel(color, pow(fadeRate, step)));
      strip.setPixelColor(wrap(center - step), Wheel(color, pow(fadeRate, step)));
      if (step > 3) {
        strip.setPixelColor(wrap(center + step - 3), Wheel(color, pow(fadeRate, step - 2)));
        strip.setPixelColor(wrap(center - step + 3), Wheel(color, pow(fadeRate, step - 2)));
      }
      step ++;
    }
    else {
      step = -1;
    }
  }

  strip.show();
  delay(50);
}

int wrap(int step) {
  if(step < 0) return Pixels + step;
  if(step > Pixels - 1) return step - Pixels;
  return step;
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos, float opacity) {

  if(WheelPos < 85) {
    return strip.Color((WheelPos * 3) * opacity, (255 - WheelPos * 3) * opacity, 0);
  }
  else if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color((255 - WheelPos * 3) * opacity, 0, (WheelPos * 3) * opacity);
  }
  else {
    WheelPos -= 170;
    return strip.Color(0, (WheelPos * 3) * opacity, (255 - WheelPos * 3) * opacity);
  }
}

So, can someone help me how to include these 2 effects based on the tutorial (unfortunately not much help on my current skill level) to the first code? Much appreciated.

You see in the second part is a void ripple(){, which is just like a void loop(){ but only runs when it is called.
You can merge these codes by placing an if-statement after your void loop(){ to check if it needs to run the loop or the ripple. You can simply use a boolean for this. For example:`
void loop(){
  if(state == true){  //I've called the boolean state
    ripple();  //this calls the ripple function, and runs void ripple()
  }

  //here's the rest of the loop, this runs if state != true.
  //you can change state wherever you'd like.
}

You could even create a new function based on what's currently in your loop. Example:
void loop(){
  if(state == 1){
    originalLoop(); //what's originally in your loop, but now as a separate function
  }
  else if(state == 2){
    ripple();
  }

  //rest of the loop in which you can change state to 1 or 2 however you like
}

Hope this helps a bit :)

Also why are you using two Arduinos? Just use an external power source to power the NeoPixels and use one Arduino to basically do everything.

Because there are many topics how IR signal decoding and Neopixel wont work together, cause IR are based on interrupts, while Neopixel disables it.  And mainly cause i couldnt find  a good example where one arduino runs  both.


text:
Stepper Motor Button Press
I am having difficulties programming what should be a simple sketch that gets my stepper motor to run at one step per second indefinitely at the press of a button and then stops at the press of another button. I am using the Bounce2.h and accelstepper.h libraries and have been unable to figure out how to do it. Any help would be greatly appreciated, and as for hardware I am using a NEMA 23 High Torque Stepper Motor connected through a M542T Motor Driver powered by a Switching Power Supply and running on an Arduino UNO.
Attatched find my code, and thank you so much for the help!
#include <Bounce2.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <AccelStepper.h>

AccelStepper stepper(1, 9, 8); // initiate stepper motor

//int buttonPresses = 0;
const byte ButtonPin = 10;
const byte LedPin = 13; // for debugging and visualization

Bounce button;

void setup() {
  Serial.begin(9600);
  button.attach(ButtonPin);
  pinMode(LedPin, OUTPUT);
  stepper.setSpeed(1);
}

void loop() {
  if (button.rose()) {
    stepper.runSpeed();
    digitalWrite(LedPin, HIGH);
    //    buttonPresses++; // count presses of button and print to monitor
    //    Serial.print("Number of Button ");
    //    Serial.print("Presses = ");
    //    Serial.println(buttonPresses);
  }
  else {
    button.update();
    digitalWrite(LedPin, LOW);
    if (button.fell()) {
      stepper.stop();
    }
  }
}

As of now, a button press runs the motor at 1 step/second, but a second press or any subsequent presses thereafter do nothing to stop the motor. Thanks so much!
!!EDIT!!
Upon adding a boolean buttonState and setting it to LOW in the setup and changing my void loop() code to look like:
void loop() {
  button.update();
  if (button.rose() == true && buttonState == LOW) {
    stepper.runSpeed();
    digitalWrite(LedPin, HIGH);
    buttonState = HIGH;
  }
  else {
    if (button.fell() == true && buttonState == HIGH) {
      stepper.stop();
      buttonState = LOW;
    }
  }
}

I know get a step every button press. Just thought it may help in answering.
EDIT 2
So I I tried pulling the runSpeed() out of the loop and adding                                                            if (buttonState = HIGH){stepper.runSpeed();}
but that now just runs the stepperMotor constantly and at variable speed and will not turn it off?
EDIT 3 and Working Code
Thank you Janw for the help. I realized my fault in calling the runSpeed function within the if statement. Further, I also needed to change button.fell() to button.rose() since button.fell() returns true when the button is released, so basically I was stopping the motor everytime I let go of the button. Here is the final, and working void loop() in case anyone runs into a similar problem in the future:
void loop() {
  button.update();
  if (button.rose() == true && buttonState == LOW) {
    digitalWrite(LedPin, HIGH);
    buttonState = HIGH;
  }
  else {
    if (button.rose() == true && buttonState == HIGH) {
      stepper.stop();
      buttonState = LOW;
    }
  }
  if (buttonState == HIGH) {
    stepper.setSpeed(1);
    stepper.runSpeed();
  }
}

You will probably get only 1 step each button press because your runSpeed() is within the if (button.rose() == true && buttonState == LOW)-statement.
The runSpeed() needs to be called every loop to check if the motor needs to step.
A simple way to change this is to set a boolean to true or false if you check your button and add something like this pseudocode:
if(motorRun == true) stepper.runSpeed();

check edits on initial question I have added some more!

You need == instead of =

Okay I'll try that and see if that does the trick! Thanks!


text:
Data transfer using SPI
Sorry for my code is long and my English is not good.
I'm working with 8x8x8 LED cube project using Arduino nano. I tried to understand code, but I don't understand how cube[][] data write on pins.
I just want to know, how write the data from cube[8][8] to hardware using SPI. code download using this link.
Thanks in advance.
My code is here :
#define AXIS_X 1
#define AXIS_Y 2
#define AXIS_Z 3
#define REFRESH_RATE 120

int CUBE_SIZE = 8;
int SPI_CS = 10;// This SPI Chip Select pin controls the MAX72xx
byte value[8];

volatile unsigned char cube[8][8];
volatile int current_layer = 0;

void setup()
{
  Serial.begin (115200);
  Serial.println("jolliFactory 8x8x8 jolliCube Demo example 1.0");

  pinMode(SPI_CS, OUTPUT);

  SPI.begin();

  maxTransferAll(0x0F, 0x00);   // 00 - Turn off Test mode
  maxTransferAll(0x09, 0x00);   // Register 09 - BCD Decoding  // 0 = No decoding
  maxTransferAll(0x0B, 0x07);   // Register B - Scan limit 1-7  // 7 = All LEDS
  maxTransferAll(0x0C, 0x01);   // 01 = on 00 = Power saving mode or shutdown
  maxTransferAll(0x0A, 0x0F);   // Set Brightness Intensity

  setUpInterrupts();
}

// Get the current status of a voxel
unsigned char getvoxel(int x, int y, int z)
{
    if (inrange(x,y,z))
    {
        if (cube[z][y] & (1 << x))
        {
            return 0x01;
        } else
        {
            return 0x00;
        }
    } else
    {
        return 0x00;
    }
}

void maxTransferAll(uint8_t address, uint8_t value)
{
  digitalWrite(SPI_CS, LOW);

    for ( int c=1; c<= CUBE_SIZE;c++) {
        SPI.transfer(address);
        SPI.transfer(value);
    }

  digitalWrite(SPI_CS, HIGH);
}

void maxTransferOne(uint8_t whichMax, uint8_t address, uint8_t value)
{
  byte noop_reg = 0x00;    //max72xx No op register
  byte noop_value = 0x00;  //value

  digitalWrite(SPI_CS, LOW);

  for (int i=CUBE_SIZE; i>0; i--)   // Loop through our number of Max72xx ICs
  {
    if (i==whichMax)
    {
      SPI.transfer(address);
      SPI.transfer(value);
    }
    else
    {
      SPI.transfer(noop_reg);
      SPI.transfer(noop_value);
    }
  }

  digitalWrite(SPI_CS, HIGH);
}

void maxTransferLEDCube(uint8_t address)
{
  digitalWrite(SPI_CS, LOW);

  for (int i=0; i<CUBE_SIZE; i++)   // Loop through our number of Max72xx ICs
  {
      SPI.transfer(address);
      SPI.transfer(value[CUBE_SIZE-i-1]);
  }

  digitalWrite(SPI_CS, HIGH);
}

void setUpInterrupts()
{
  cli();//stop interrupts while we set them up
  //set up an interrupt with timer1
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;
  OCR1A = (16000000/REFRESH_RATE/1024/CUBE_SIZE -1);
  TCCR1B |= (1 << WGM12);
  // Set to CS10 and CS12 so we have the 1024
  TCCR1B |= (1 << CS12) | (1 << CS10);
  TIMSK1 |= (1 << OCIE1A);
  sei();//re-allow interrupts
}

ISR(TIMER1_COMPA_vect)
{
  for(byte y = 0 ; y < CUBE_SIZE ; y++)
  {
    byte b = 0;

    for(byte x = 0 ; x < CUBE_SIZE ; x++)
    {
      //form data byte
      b = b << 1;

      if (getvoxel(x,y,current_layer)==1)
      {
        b |= 1;
      }
    }
        value[y] = b;
  }

  maxTransferLEDCube(CUBE_SIZE - current_layer);

  current_layer++;

  if (current_layer == 8)
    current_layer = 0;
}

First, you need to know how the LEDs are arranged. There are 8 layers, each with 8 rows, each with 8 LEDs.
Each LED is represented as a single bit inside unsigned char cube[8][8]; - the first [8] is the array of layers, the second [8] is the array of rows, and the unsigned char holds 8 bits to represent the state of the 8 LEDs in that row.
Each LED layer has one MAX7219 8x8 LED Matrix Controller. To tell it what to do you need to give it a Command byte and a Data byte. So to tell it to light up LEDs 1, 2, and 7 on the fourth row, you need to tell it 0x04 0x86. You send this command by setting CS LOW, sending the 16 bits of the Command+Data, then setting CS HIGH.
Each MAX7219 is connected one after the other in an SPI string. To command all of them at once you need to set CS LOW, send 16 bits for each MAX7219 (128 bits in all), then set CS HIGH. If you only want to command one MAX7219, you need to send a NOP Command+Data (0x00 0x00) to all the others.
The way the program works is:

setup()
a. Initialise the Serial port, and print a message.
b. Set the CS pin as an OUTPUT, then initialise SPI.
c. Initialise all the MAX7219 chips by sending a series of commands -
the same Command+Data to each of them (maxTransferAll()).
d. Initialise the Timer interrupt (setUpInterrupts()).
loop()
This isn't shown in the code. Presumably it alters the cube[8][8] array to make the special effects.
TIMER1_COMPA_vect (the interrupt handler)
Every time the timer ticks, the handler will command all of the MAX7219s to show the next row of LEDs.  This will last until the next timer tick, when the next row will be displayed. If this is done fast enough, the human eye's "persistence of vision" will not see the rows flickering.
For each row (`y`) in the `cube` array
   Set `b` to 0
   For each bit ('x') in the `cube` data
      If the bit is set (`getvoxel(...)`) set a bit in `b`.
   Store `b` in the `value[y]` array

value now holds the bytes needed as Data for the next row for each of the MAX7219 chips.
    Send value over SPI using `maxTransferLEDCube(...)`

Since the cube displays the same row for each layer simultaneously, the Command doesn't have to change, only the Data does. That's what the value array holds: the Data to be sent to each MAX7219 chip.


text:
Exporting ADC data to excel
Do I need third party s/w to export to a spreadsheet? I have built a heat flux sensor meter and wish to log my data.

You need some way of getting the data from the Arduino to the PC. There's a number of ways of doing it depending on what resources you have available.

Through serial as CSV

This entails printing the data to the serial port in CSV format then using some software on the PC to capture that and save it to a file. That could be as simple as a good terminal emulator that provides "capture to file" or similar, or you could write your own program in your favourite programming language.  This method is essentially free.

To an SD card

Writing the data as a CSV file onto an SD card directly attached to the Arduino can be quite convenient. It means you can then just take the SD card with the data on it and slip it into your computer to import the data as you would with any other file.  It needs an SD card shield or breakout board attaching to the Arduino

Through the network

If your Arduino has a network connection of some form (WiFi shield, Ethernet shield, etc) you could POST the data to a web page running on your PC and store it in a CSV file for later importing. Probably the most expensive option but it does mean you can do things with the data "live" as it comes in.

Just note that Excel sometimes expect a ; instead of a , inside a CSV file (depending on the locale settings of Windows)

If only they kept hyper terminal in WIN 7 :(

@eggroll Why? HT was shite.

True, but it offered a quick and dirty platform for what I needed. My S/W guy is writing the GUI, but I wanted to do some preliminary work and HT is easy for us H/W guys, lol.

Use tabs to separate columns of data, and newlines between each row.
Then you can copy the serial output, and paste it into Excel.


text:
ESP8266 - AT Command for Network Requiring Username AND Password
I have been using my ESP8266 module with my Arduino on my university's Wi-Fi network, which only requires a password to log on to.
The university will soon terminate that Wi-Fi network and replace it with one that requires a username and password to log on.
What would that AT command be to connect to such a network?
Edit: I have since found out that the university has changed the network so that a user can "connect" to the network and then enter their university id/password in a captive portal to gain internet access (and perhaps other features of the network). Also, I have since learned how to overwrite the firmware on my esp-01 so that I no longer need to use the AT commands -- in fact, I can program it in the Arduino IDE just as I would with another esp8266-based device, such as the NodeMCU.

sounds like you'll need WPA2/Enterprise - read this and this - though I'm not sure if the latest AT firmware has any support - but I haven't read those links too much

Get a wifi router, and make a local "development" network. (If you don't need internet on the ESP8266)

We can't tell without more information but it sounds rather like you will need a [WiFi_SSID, WiFi_PASSWORD] pair for the ESP to connect to the WiFi, and a [Network_USERNAME, Network_USERPASSWORD] pair for their network to let you use the network (as if you were logging onto it by hand from a terminal).
If so, you'd provide the first pair as you do now, with the AT+CWJAP... command, to get your device connected to the WiFi. For the second pair, your Arduino will probably need to interact with a user logon screen to provide the second pair. You'll need to get those details from the school's IT department, and possibly mimic a terminal.
Update:
As above, you need to find out whether the network requires 2 sets of credentials - the SSID and WPA2 key and network username and password. If it requires the latter, then your ESP can get you onto the WiFi but your Arduino will then have to mimic a user sitting at a terminal - read the network ID and Password challenges and provide the appropriate responses. Without know that, you can't know how to write the login code, nor can we. It sounds as if there are people on site who have already done what you're trying to do. They and their experience can be far more helpful than we, who have no knowledge of the school network.

The network will be WPA2 secured. When logging on with my Windows 10 PC, I am prompted to enter credentials in a web browser. When using the ESP8266, might I need to send an HTTP request to the AP containing login credentials?

That seems at least possible.  We really don't know enough yet to do more than guess.

I'm using an ESP-01, interfacing with it using softser. The network is WPA2 secured, which is supported by the ESP8266. I will have to connect to Eduroam to use the network.

I did not understand the changes to the network at the time. To the best of my knowledge, the network is WPA2 secured. To gain internet access, users must now enter credentials in a captive portal. I don't know how, but others at my school have been able to navigate this using  a NodeMCU programmed in the Arduino IDE.

If you are using Arduino+ESP8266 version 1(ESP-01)module. You can connect ESP module to the internet, using AT commands as follows:
Normally, AT+CWJAP="ssid","password"
If your Internet requires ssid, username and passowrd(usually in universities- eduroam) then
1) Connect to eduroam or university wifi using ssid, username and password from
   your laptop.
2) Install Connectify Hotspot software in your laptop.
3) Open "Connectify Hotspot" application and open settings tab, then create
   wifi-hotspot.
4) Give eduroam(or your wifi)-->"Internet to share" field , Give your own
   Hotspot name and password. Then click on "start Hotspot" button.
5) Now your esp01 module can detect this new hotspot using AT+CWLAP. Connect to
   it using AT+CWJAP="HOtspot ssid","HOtspot password".
This way you can overcome the problem of extra Authentication.
Hope it helped. Enjoy Programming.