I have make an apps to call a function from arduino to run, which the function is selected through the apps and when the start button is press all the function will be running. The problem is it can only read 7 value from the bluetooth and after the 7 value, it does shows an mix number of the example is 255.
#include <SoftwareSerial.h>
#include <Adafruit_NeoPixel.h>
#define rxPin 8
#define txPin 7
Adafruit_NeoPixel strip = Adafruit_NeoPixel (24,2,NEO_RGB + NEO_KHZ800);
SoftwareSerial mySerial(rxPin, txPin); // RX, TX
byte numChar=0;
byte myChar[40];
byte i=0;
// function prototypes
void ani1();
void ani2();
void ani3();
void ani4();
void ani5();
void ani6();
void ani7();
void ani8();
void ani9();
void ani10();
void ani11();
void ani12();
void ani13();
void ani14();
void ani15();
void ani16();
void ani17();
void ani18();
void ani19();
void ani20();
void ani21();
void ani22();
void ani23();
void ani24();
void ani25();
void ani26();
void ani27();
void ani28();
void ani29();
void ani30();
void ani31();
void ani32();
void ani33();
void ani34();
void ani35();
void ani36();
void ani37();
void ani38();
void ani39();
void ani40();
void ani41();
// array of function pointers
void (*animations[])() =
{
ani1,
ani2,
ani3,
ani4,
ani5,
ani6,
ani7,
ani8,
ani9,
ani10,
ani11,
ani12,
ani13,
ani14,
ani15,
ani16,
ani17,
ani18,
ani19,
ani20,
ani21,
ani22,
ani23,
ani24,
ani25,
ani26,
ani27,
ani28,
ani29,
ani30,
ani31,
ani32,
ani33,
ani34,
ani35,
ani36,
ani37,
ani38,
ani39,
ani40,
ani41
};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Test Wave");
mySerial.begin(9600);
mySerial.println("Hello, world?");
strip.begin();
strip.show();
}
void loop(){
if(mySerial.available()){
i=0;
myChar[numChar] = mySerial.read();
myChar[numChar] -= '1';
Serial.print(myChar[numChar]);
Serial.print(" ");
Serial.print(numChar);
numChar++;
if(numChar>40){
numChar=0;
}
}
if(Serial.available()){
myChar[numChar] = Serial.read();
myChar[numChar] -= '1';
Serial.print(myChar[numChar]);
}
Serial.print(i);
Serial.print(" ");
i++;
if(i>40){
i=0;
}
animations[myChar[i]]();
Serial.println();
}
void ani1(){
}
void ani2(){
for(int c=0;c<24;c++){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animtion2");
}
void ani3(){
for(int c=0;c<24;c++){
strip.setPixelColor(23-c,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animtion3");
}
void ani4(){
for(int c=0;c<12;c++){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animtion4");
}
void ani5(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation5");
}
void ani6(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation6");
}
void ani7(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation7");
}
void ani8(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation8");
}
void ani9(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation9");
}
void ani10(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation10");
}
void ani11(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation11");
}
void ani12(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation12");
}
void ani13(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation13");
}
void ani14(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation14");
}
void ani15(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation15");
}
void ani16(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation16");
}
void ani17(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation17");
}
void ani18(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation18");
}
void ani19(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation19");
}
void ani20(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation20");
}
void ani21(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation21");
}
void ani22(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation22");
}
void ani23(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation23");
}
void ani24(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation24");
}
void ani25(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation25");
}
void ani26(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation26");
}
void ani27(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation27");
}
void ani28(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation28");
}
void ani29(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation29");
}
void ani30(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation30");
}
void ani31(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation31");
}
void ani32(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation32");
}
void ani33(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation33");
}
void ani34(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation34");
}
void ani35(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation35");
}
void ani36(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation36");
}
void ani37(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation37");
}
void ani38(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation38");
}
void ani39(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation39");
}
void ani40(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation40");
}
void ani41(){
for(int c=12;c>=0;c--){
strip.setPixelColor(c,strip.Color(255,0,0));
strip.setPixelColor(c+12,strip.Color(255,0,0));
strip.show();
strip.clear();
delay(100);
}
Serial.print("animation41");
}
Here is the value of serial.print
00
2 10 animtion3
3 20 animtion3
4 30 animtion3
5 40 animtion3
8 50 animtion3
6 60 animtion3
0 70 animtion3
255 80 animtion3
0 90 animtion3
0 100 animtion3
0 110 animtion3
1 120 animtion3
0 130 animtion3
2 140 animtion3
0 150 animtion3
3 160 animtion3

