Source Code–Please Use

An Open-Source Philosophy

The philosophy behind Fraction Bot is that learning tools should be universal. We recognize that instructors of all kinds are often under-funded for their own classroom supplies, so we try to accommodate school budgets by providing the code used by Fraction Bot at no cost. Should an instructor have access to other supplies that would enable him/her to create a new version of the Fraction Bot, we welcome adaptations of the code to suit what ever needs arise. The following code pertains to an Arduino Uno microcontroller.

 

Code:

//Coded by Jason King PDI Studio 5 Fall 2013
//Fraction Bot
//JAson King, Krist Glanville, Joe Bernstein

#include <SoftwareSerial.h>
#include <serialGLCD.h> // Include the library
#include <ShiftPWM.h>

SoftwareSerial mySerial(1, 0); // RX, TX
const int ShiftPWM_latchPin=8;
const int ShiftPWM_dataPin = 11;
const int ShiftPWM_clockPin = 13;
const bool ShiftPWM_invertOutputs = false;
const bool ShiftPWM_balanceLoad = false;
unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
int numRegisters = 2;
int numRGBleds = numRegisters*8/3;
int Rled = 8;
int Gled = 9;
int Bled = 10;
int Rled2 = 11;
int Gled2 = 12;
int Bled2 = 13;
float DB1 = 0;
float DB2 = 0;
float DB3 = 0;
int DB4 = 0;
float N1 = 0;
float N2 = 0;
float D1 = 0;
float D2 = 0;
float N3 = 0;
float D3 = 0;
float N4 = 0;
float D4 = 0;
float N5 = 0;
float D5 = 0;
char Mod = 0;
int Calc = 0;
int CalcH = 0;
int i = 0;
byte Hint = 0;
byte reduce = 0;
char Operator;
byte Solve = 0;
byte next = 0;
int Mixed = 0;
int Mixedcheck = 0;
int Level = 1;
int SelE = 0;
int right = 0;
//int wrong = 0;
int sensorPin = A3;
int Pot = 0;
const int SetButton = 4;
const int HelpButton = 5;
const int CycButton = 3;
const int AddButton = 6;
int Cyc = 0;
byte Loop = 0;

void setup()
{
Serial.begin(115200);
mySerial.begin(115200);
pinMode(SetButton, INPUT);
pinMode(HelpButton, INPUT);
pinMode(CycButton, INPUT);
pinMode(Rled, OUTPUT);
pinMode(Gled, OUTPUT);
pinMode(Bled, OUTPUT);
pinMode(Rled2, OUTPUT);
pinMode(Gled2, OUTPUT);
pinMode(Bled2, OUTPUT);
}
serialGLCD lcd;

void loop()
{
delay(1000);
int rst = 1;
lcd.clearLCD();
lcd.gotoLine(3);
delay(300);
lcd.toggleFont();
Serial.print(“FractionBot”);
lcd.gotoLine(5);
delay(50);
lcd.toggleFont();
Serial.print(” PDI Studio 5″);
lcd.gotoLine(7);
Serial.print(” JMAK & KDAWG & Joe”);
delay(1000);
while (rst ==1)
{
Loop = 0;
Randomize();
delay(500);
Equation();
delay(500);
Calculate();
delay(500);
Reduce();
delay(500);
// lcd.toggleFont();
delay(50);
while (Loop == 0)
{
while(digitalRead(SetButton) == LOW && digitalRead(HelpButton) == LOW)
{
SetAnswer();
delay(150);
if (digitalRead(CycButton) == HIGH)
{
DB3++;
for(DB3; DB3 > 1; DB3++)
{
Cyc++;
DB3 = 0;
}
}
LCDprint();
delay(5);
}
if (digitalRead(SetButton) == HIGH)
{
DB1++;
for(DB1; DB1 > 2; DB1++)
{
Check();
delay(50);
DB1=0;
}
}
if (digitalRead(HelpButton) == HIGH)
{
DB2++;
for(DB2; DB2 > 2; DB2++)
{
Help();
delay(50);
DB2=0;
}
}
}
}
}
void Randomize()
{
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
digitalWrite(Bled, HIGH);
digitalWrite(Bled2, HIGH); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(Bled, LOW);
digitalWrite(Bled2, LOW);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
digitalWrite(Bled, HIGH);
digitalWrite(Bled2, HIGH); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(Bled, LOW);
digitalWrite(Bled2, LOW);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
digitalWrite(Bled, HIGH);
digitalWrite(Bled2, HIGH); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(Bled, LOW);
digitalWrite(Bled2, LOW);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
digitalWrite(Bled, HIGH);
digitalWrite(Bled2, HIGH); // turn the LED off by making the voltage LOW
delay(100);
digitalWrite(Bled, LOW);
digitalWrite(Bled2, LOW);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
//Serial.println(“Random”);
if (Level == 1)
{
N1 = random(1,3);
N2 = random(1,3);
D1 = random(1,4);
D2 = random(1,4);
SelE = 1;
//Serial.println(“Random Level 1”);
//j++;
}

if (Level == 2)
{
N1 = random(1,5);
N2 = random(1,3);
D1 = random(1,6);
D2 = random(1,5);
SelE = random(1,2);
//Serial.println(“Random Level 2”);
}

if (Level == 3)
{
N1 = random(1,7);
N2 = random(1,7);
D1 = random(1,8);
D2 = random(1,8);
SelE = random(1,3);
//Serial.println(“Random Level 3”);
}
if (Level == 4)
{
N1 = random(1,5);
N2 = random(1,5);
D1 = random(1,5);
D2 = random(1,5);
SelE = random(1,4);
//Serial.println(“Random Level 4”);
}
}

void Equation()
{
Hint=0;
if (SelE == 1)
{
Calc = 1;
CalcH = 1;
Operator = ‘X’;
}
if (SelE == 2)
{
Operator = ‘/’;
Calc = 2;
CalcH = 2;
}
if (SelE == 3)
{
Operator = ‘+’;
Calc = 3;
CalcH = 3;
}
if (SelE == 4)
{
Operator = ‘-‘;
Calc = 4;
CalcH = 4;
}
}

void Calculate()
{
Solve = 1;
next = 1;
if (Calc == 1)
{
N3 = (N1*N2);
D3 = (D1*D2);
}
if (Calc == 2)
{
N3 = (N1*D2);
D3 = (D1*N2);
}
if (Calc == 3)
{
N1 = (N1*D2);
N2 = (N2*D1);
D3 = (D1*D2);
N3 = (N1 + N2);
}
if (Calc == 4)
{
N1 = (N1*D2);
N2 = (N2*D1);
D3 = (D1*D2);
N3 = (N1 – N2);
}
}

void Reduce()
{
reduce = 1;
int j = 0;
while (j==0)
{
if (abs(D3/5) == 1 || abs(D3/5) == 2 || abs(D3/5) == 3 || abs(D3/5) == 4 || abs(D3/5) == 5)
{
if (abs(N3/5) == 1 || abs(N3/5) == 2 || abs(N3/5) == 3 || abs(N3/5) == 4 || abs(N3/5) == 5)
{
N4 = N3/5;
D4 = D3/5;
j=1;
}
}
if (abs(D3/4) == 1.00 || abs(D3/4) == 2.00 || abs(D3/4) == 3 || abs(D3/4) == 4 || abs(D3/4) == 5)
{
if (abs(N3/4) == 1.00 || abs(N3/4) == 2.00 || abs(N3/4) == 3 || abs(N3/4) == 4 || abs(N3/4) == 5)
{
N4 = N3/4;
D4 = D3/4;
j=1;
}
}
if (abs(D3/3) == 1 || abs(D3/3) == 2 || abs(D3/3) == 3 || abs(D3/3) == 4 || abs(D3/3) == 5)
{
if (abs(N3/3) == 1 || abs(N3/3) == 2 || abs(N3/3) == 3 || abs(N3/3) == 4 || abs(N3/3) == 5)
{
N4 = N3/3;
D4 = D3/3;
j=1;
}
}
if (abs(D3/2) == 1 || abs(D3/2) == 2 || abs(D3/2) == 3 || abs(D3/2) == 4 || abs(D3/2) == 5 || abs(D3/2) == 6 || abs(D3/2) == 7 || abs(D3/2) == 8)
{
if (abs(N3/2) == 1 || abs(N3/2) == 2 || abs(N3/2) == 3 || abs(N3/2) == 4 || abs(N3/2) == 5 || abs(N3/2) == 6 || abs(N3/2) == 7 || abs(N3/2) == 8 || abs(N3/2) == 9 || abs(N3/2) == 10)
{
N4 = N3/2;
D4 = D3/2;
j=1;
}
}
else
{
N4 = N3;
D4 = D3;
j=1;
}
}
if (N4 == D4)
{
N4 = 1;
D4 = 1;
}
if (abs(N4/D4) > 1)
{
if (N4/D4 < 2)
{
Mixed =1;
N4 = N4-D4;
//Serial.print(“here”);
}
if (N4/D4 > 2 && N4/D4 < 3)
{
Mixed =2;
N4 = N4-(2*D4);
}
if (N4/D4 > 3 && N4/D4 < 4)
{
Mixed =3;
N4 = N4-(3*D4);
}
if (N4/D4 > 5 && N4/D4 < 6)
{
Mixed =4;
N4 = N4-(4*D4);
}
if (N4/D4 > 7 && N4/D4 < 8)
{
Mixed =5;
N4 = N4-(5*D4);
}
}
}

void SetAnswer()
{
if (Cyc == 0)
{
N5 = 1;
}
if (Cyc == 1)
{
N5 = 2;
}
if (Cyc == 2)
{
N5 = 3;
}
if (Cyc == 3)
{
N5 = 4;
}
if (Cyc == 4)
{
N5 = 5;
}
if (Cyc == 5)
{
N5 = 6;
}
if (Cyc == 6)
{
N5 = 7;
}
if (Cyc == 7)
{
N5 = 8;
}
if (Cyc == 8)
{
N5 = 9;
}
if (Cyc == 9)
{
N5 = 10;
}
if (Cyc == 10)
{
N5 = 11;
}
if (Cyc == 11)
{
N5 = 12;
}
if (Cyc == 12)
{
N5 = 13;
}
if (Cyc == 13)
{
N5 = 14;
}
if (Cyc == 14)
{
Cyc = 0;
}
if (digitalRead(AddButton) == HIGH)
{
DB4++;
for(DB4; DB4 > 2; DB4++)
{
Mixedcheck++;
DB4=0;
}
if (Mixedcheck == 6)
{
Mixedcheck = 0;
}
}

Pot = analogRead(sensorPin);
delay(20);
D5 = map(Pot, 0, 690,20, 0);
}

void Check()
{
Cyc = 0;
lcd.clearLCD();
/* Serial.println(“Check”);
Serial.print(N3);
Serial.print(” “);
Serial.print(N4);
Serial.print(” “);
Serial.println(N5);
Serial.print(D3);
Serial.print(” “);
Serial.print(D4);
Serial.print(” “);
Serial.println(D5);
*/
if (N4 == N5 && D4 == D5 && Mixed == Mixedcheck)
{
right++;
lcd.toggleFont();
lcd.gotoLine(3);
Serial.print(“Correct!!!”);
lcd.gotoLine(5);
Serial.println(“Good Job!”);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
delay(100);
digitalWrite(Gled, HIGH);
digitalWrite(Gled2, HIGH);
delay(100);
digitalWrite(Gled, LOW);
digitalWrite(Gled2, LOW);
lcd.toggleFont();
Mixedcheck = 0;
Mixed =0;
N3=0;
N4=0;
D3=0;
D4=0;

if (right==5)
{
right = 0;
//Lightcorrect();
Level++;
}
}
else
{
lcd.toggleFont();
lcd.gotoLine(3);
Serial.print(“Incorrect”);
lcd.gotoLine(5);
Serial.print(“Try Again”);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
delay(100);
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
delay(100);
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
delay(100);
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
delay(100);
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
delay(100);
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
delay(100);
digitalWrite(Rled, HIGH);
digitalWrite(Rled2, HIGH);
delay(100);
digitalWrite(Rled, LOW);
digitalWrite(Rled2, LOW);
// delay(100);
lcd.toggleFont();
/*lcd.gotoLine(2);
Serial.print(” “);
Serial.print(N4,0);
lcd.gotoLine(3);
Serial.print(Mixed);
Serial.print(“-“);
lcd.gotoLine(4);
Serial.print(” “);
Serial.print(D4,0);
*/
Mixedcheck = 0;
Mixed =0;
N3=0;
N4=0;
D3=0;
D4=0;
}
delay(500);
Loop = 1;
lcd.clearLCD();
}

void LCDprint()
{
//delay(100);
lcd.clearLCD();
//delay(10);
if (SelE == 1)
{
if (Mixedcheck != 0)
{
Serial.print(” Fraction Bot”);
lcd.gotoLine(3);
Serial.print(N1,0);
Serial.print(” “);
Serial.print(N2,0);
Serial.print(” “);
Serial.print(N5,0);
lcd.gotoLine(4);
Serial.print(“- X – = “);
Serial.print(Mixedcheck);
Serial.print(“-“);
lcd.gotoLine(5);
Serial.print(D1,0);
Serial.print(” “);
Serial.print(D2,0);
Serial.print(” “);
Serial.print(D5,0);
lcd.gotoLine(8);
Serial.print(“Level: “);
Serial.print(Level);
Serial.print(” “);
Serial.print(right);
Serial.print(“/5″);
}
else
{
Serial.print(” Fraction Bot”);
lcd.gotoLine(3);
Serial.print(N1,0);
Serial.print(” “);
Serial.print(N2,0);
Serial.print(” “);
Serial.print(N5,0);
lcd.gotoLine(4);
Serial.print(“- X – = -“);
lcd.gotoLine(5);
Serial.print(D1,0);
Serial.print(” “);
Serial.print(D2,0);
Serial.print(” “);
Serial.print(D5,0);
lcd.gotoLine(8);
Serial.print(“Level: “);
Serial.print(Level);
Serial.print(” “);
Serial.print(right);
Serial.print(“/5”);
}
}
if (SelE == 2)
{
Serial.print(“Fraction Bot”);
lcd.gotoLine(3);
Serial.print(N1,0);
Serial.print(” “);
Serial.print(N2,0);
Serial.print(” “);
Serial.print(N5,0);
lcd.gotoLine(4);
Serial.print(“- / – = -“);
lcd.gotoLine(5);
Serial.print(D1,0);
Serial.print(” “);
Serial.print(D2,0);
Serial.print(” “);
Serial.print(D5,0);
lcd.gotoLine(8);
Serial.print(“Level: “);
Serial.print(Level);
Serial.print(” “);
Serial.print(right);
Serial.print(“/5”);
}
if (SelE == 3)
{
Serial.print(“Fraction Bot”);
lcd.gotoLine(3);
Serial.print(N1,0);
Serial.print(” “);
Serial.print(N2,0);
Serial.print(” “);
Serial.print(N5,0);
lcd.gotoLine(4);
Serial.print(“- + – = -“);
lcd.gotoLine(5);
Serial.print(D1,0);
Serial.print(” “);
Serial.print(D2,0);
Serial.print(” “);
Serial.print(D5,0);
lcd.gotoLine(8);
Serial.print(“Level: “);
Serial.print(Level);
Serial.print(” “);
Serial.print(right);
Serial.print(“/5”);

}
if (SelE == 4)
{
Serial.print(“Fraction Bot”);
lcd.gotoLine(3);
Serial.print(N1,0);
Serial.print(” “);
Serial.print(N2,0);
Serial.print(” “);
Serial.print(N5,0);
lcd.gotoLine(4);
Serial.print(“- – – = -“);
lcd.gotoLine(5);
Serial.print(D1,0);
Serial.print(” “);
Serial.print(D2,0);
Serial.print(” “);
Serial.print(D5,0);
lcd.gotoLine(8);
Serial.print(“Level: “);
Serial.print(Level);
Serial.print(” “);
Serial.print(right);
Serial.print(“/5″);
}
}

void Help()
{
Hint++;
// Serial.println(” HELP “);
//Serial.print(“Hint =”);
//Serial.println(Hint);
if (CalcH == 1)
{
//Serial.println(” Multiply “);
if (Hint == 1)
{
lcd.toggleFont();
lcd.clearLCD();
delay(10);
lcd.gotoLine(3);
Serial.print(” Multiply”);
delay(10);
lcd.gotoLine(5);
Serial.print(” Across”);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 2)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(3);
Serial.print(N1,0);
Serial.print(‘X’);
Serial.print(N2,0);
Serial.print(‘=’);
Serial.print(N1*N2,0);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 3)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(5);
Serial.print(D1,0);
Serial.print(‘X’);
Serial.print(D2,0);
Serial.print(‘=’);
Serial.print(D1*D2,0);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 4)
{
Loop=1;
}
DB2 = 0;
}

if (CalcH == 2)
{
//Serial.println(” Divide “);
if (Hint == 1)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
Serial.print(“Kentucky Chicken “);
lcd.gotoLine(3);
Serial.print(“Chicken “);
lcd.gotoLine(5);
Serial.print(“Fried”);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 2)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(3);
Serial.print(“Keep Change “);
lcd.gotoLine(5);
Serial.print(” Flip”);
lcd.toggleFont();
delay(5000);
}
else if (Hint ==3)
{
float Temp = N2;
N2 = D2;
D2 = Temp;
Operator = ‘x’;
Calc = 1;
delay(100);
}
else if (Hint == 4)
{
Loop = 1;
}

DB2 = 0;
}
if (Calc == 3)
{
//Serial.println(” ADD “);
if (Hint == 1)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(3);
Serial.print(“Lowest Common “);
lcd.gotoLine(5);
Serial.print(“Denomenator”);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 2)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(2);
Serial.print(“Multiply by “);
lcd.gotoLine(4);
Serial.print(“Opposite”);
lcd.gotoLine(6);
Serial.print(“Denomenator”);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 3)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(4);
Serial.print(‘LCD =’);
Serial.print(D1*D2);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 4)
{
float TempD = D2;
N2 = (N2*D1);
D2 = (D2*D1);
N1 = (TempD*N1);
D1 = (TempD*D1);
}
else if (Hint == 5)
{
Loop = 1;
}
DB2 = 0;
}
if (Calc == 4)
{
Serial.println(” SUBTRACT “);
if (Hint == 1)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(3);
Serial.print(“Lowest Common “);
lcd.gotoLine(5);
Serial.print(“Denomenator”);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 2)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(2);
Serial.print(“Multiply by “);
lcd.gotoLine(4);
Serial.print(“Opposite”);
lcd.gotoLine(6);
Serial.print(“Denomenator”);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 3)
{
lcd.toggleFont();
lcd.clearLCD();
delay(25);
lcd.gotoLine(4);
Serial.print(‘LCD =’);
Serial.print(D1*D2);
lcd.toggleFont();
delay(5000);
}
else if (Hint == 4)
{
float TempD = D2;
N2 = (N2*D1);
D2 = (D2*D1);
N1 = (TempD*N1);
D1 = (TempD*D1);
}
else if (Hint == 5)
{
Loop = 1;
}
DB2 = 0;
}
}

void Lightshow()
{
ShiftPWM.SetAll(0);
// Print information about the interrupt frequency, duration and load on your program
//ShiftPWM.PrintInterruptLoad();
ShiftPWM.SetOne(0,255);
ShiftPWM.SetOne(3,255);
ShiftPWM.SetOne(6,255);
ShiftPWM.SetOne(9,255);
ShiftPWM.SetOne(12,255);
delay(200);
ShiftPWM.SetAll(0);
ShiftPWM.SetOne(1,255);
ShiftPWM.SetOne(4,255);
ShiftPWM.SetOne(7,255);
ShiftPWM.SetOne(10,255);
ShiftPWM.SetOne(13,255);
delay(200);
ShiftPWM.SetAll(0);
ShiftPWM.SetOne(2,255);
ShiftPWM.SetOne(5,255);
ShiftPWM.SetOne(8,255);
ShiftPWM.SetOne(11,255);
ShiftPWM.SetOne(14,255);
delay(200);
}

void Lightwrong()
{
ShiftPWM.SetOne(9,255);
ShiftPWM.SetOne(12,255);
delay(250);
ShiftPWM.SetOne(6,255);
ShiftPWM.SetOne(15,255);
delay(250);
ShiftPWM.SetOne(3,255);
ShiftPWM.SetOne(18,255);
delay(250);
ShiftPWM.SetOne(0,255);
ShiftPWM.SetOne(21,255);
delay(250);
}

void Lightcorrect()
{
ShiftPWM.SetOne(10,255);
ShiftPWM.SetOne(13,255);
delay(250);
ShiftPWM.SetOne(7,255);
ShiftPWM.SetOne(16,255);
delay(250);
ShiftPWM.SetOne(4,255);
ShiftPWM.SetOne(19,255);
delay(250);
ShiftPWM.SetOne(2,255);
ShiftPWM.SetOne(22,255);
delay(250);
}