int allOn(String args) { int firstCommaPosition = args.indexOf(","); int lastCommaPosition = args.lastIndexOf(","); int r = atoi(args.substring(0,firstCommaPosition)); int g = atoi(args.substring( firstCommaPosition+1,lastCommaPosition)); int b = atoi(args.substring(lastCommaPosition+1)); button.allLedsOn(r,g,b); return 1; }
void loop() { int xVal = button.readX(); int yVal = button.readY(); int zVal = button.readZ(); if ((abs (prevX - xVal) > threshold) || (abs (prevY - yVal) > threshold) || (abs (prevZ - zVal) > threshold)) { int r = abs(xVal) % 255; int g = abs(yVal) % 255; int b = abs(zVal) % 255; button.allLedsOn(r,g,b); } prevX = xVal; prevY = yVal; prevZ = zVal; }