interupting task or multi tasking

Alcon,

I didnt realize the pride you guys take on as a collective here in the forums. and I have realized in teaching me its almost like the sketch is your baby too. So I wrote everything down that I wanted to do then I got started on my sketch. I hope its understandable. and it goes on the small wheels principals that you guys where talking about.

//Neopixel Side of things
#include <Adafruit_NeoPixel.h>
#define NEO_PIN 5
#define NUMPIXELS 12
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ800);

// LedReading is the type we get when we call Bean.getLedValues();
// For example, to get the amount of red in the Bean's LED,
// we use ledColor.red to get a value from 0 to 255
LedReading ledColor;
// previousLedColor will be used to check if the LED's color has changed
LedReading previousLedColor;


//Seial Side of things for interaction with the BLE App.
//I did copy this part from another,mainly cause I am at a total lost on 
//the IOS App to BLE to Serial to Arduino part. I am willing to learn and intend too.
//Please dont bite my head off for this part. 
#define BUF_SIZE 64
char buffer[BUF_SIZE] = {0};
// Sandbox control IDs
const char MSG_XYPAD_X = 8;
const char MSG_XYPAD_Y = 9;
const char MSG_XYPAD_Z = 11;
const char MSG_PAGEA_SLIDER_0 = 0;
const char MSG_PAGEA_SLIDER_1 = 2;
const char BUTTON_1 = 13;
const char BUTTON_2 = 14;
const char BUTTON_3 = 15;
const char BUTTON_4 = 16;
const char BUTTON_5 = 17;
const char BUTTON_6 = 18;
char brightness = 30;



#define starttime 200


void setup() {
//This is the only part of the code that has delays at this moment. 
//Mainly cause I was being lazy last night. But I am switching this to millis()
pixels.begin();
pixels.show(); // Initialize all pixels to 'off'
pixels.setPixelColor(0, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(1, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(2, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(3, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(4, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(5, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(6, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(7, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(8, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(9, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(10, 255, 255, 255);
pixels.show();
delay(starttime);
pixels.setPixelColor(11, 255, 255, 255);
pixels.show();
delay(starttime);

}

void loop() {

color_wheel();
    
    
    
    
    
}


//void serial_poll()

//void ANCS_poll()

//void ANCS_Noti()

//void rainbow_anim()

//void sparkle()

//void rainbow_slider()

void color_wheel()
{
    ledColor = Bean.getLed();
    {
    if(ledColor.red != previousLedColor.red ||
      ledColor.green != previousLedColor.green ||
      ledColor.blue != previousLedColor.blue) {
      for(int i = 0; i < NUMPIXELS; i++) {
        pixels.setPixelColor(
          i, pixels.Color(ledColor.red, ledColor.green, ledColor.blue));
        pixels.show();
      }
    previousLedColor = ledColor;
    }
  }
}
//void weather()

All in all, this as of right now does compile on the Arduino IDE when using the Lightblue Bean Bootloader.

Also I do intend on changing the void setup animation code to that of a neater one. again just going on baby steps here. but thats my goal today.

ok, and what do you guys think about the adafruit tutorial on multitasking, its got 3 parts to it and the last lesson ends with this....

https://learn.adafruit.com/multi-tasking-the-arduino-part-3/overview

does this seem like a smart way of doing things? I just want to make sure im learning things the right way. and you guys have been guiding me well.

I would start by reading Overview | Multi-tasking the Arduino - Part 1 | Adafruit Learning System

And in case it was not mentioned, Robin2’s Demonstration code for several things at the same time

Looking at part one of the Adafruit tasking tutorial I only cringed here and there but they carried over one real mistake:

They use type long (signed) variables for timing instead of unsigned long.

Good part is that it would take almost 25 days wait to go wrong. Most beginner projects run hours at most.

Bad part is that it teaches something that will go wrong when you make a long running automation or data logging project.

The Arduino millis() and micros() functions return unsigned long values. Where the example code uses long, change it to unsigned long.

They use a good bit more code than necessary but when you're young there's time to waste. I did until I learned better. Maybe I push too hard but I'd love to save new people from much of that.