#include <Servo.h>
Servo myServo;
int servoPosition;
int greenCount = 0;
int redCount = 0;
int yellowCount = 0;
int pinkCount = 0;
int whiteCount = 0;
int currentSelection = 0;
int rotationAngle = 45;
void setup() {
myServo.attach(5);
Serial.begin(9600);
}
void loop() {
currentSelection = random(0, 5);
myServo.write(rotationAngle * currentSelection);
if (currentSelection == 0) {
greenCount++;
Serial.print("green ");
} else if (currentSelection == 1) {
redCount++;
Serial.print("red ");
} else if (currentSelection == 2) {
yellowCount++;
Serial.print("yellow ");
} else if (currentSelection == 3) {
pinkCount++;
Serial.print("pink ");
} else if (currentSelection == 4) {
whiteCount++;
Serial.print("white ");
}
Serial.print(" ");
if (greenCount < 10) Serial.print(" ");
Serial.print(greenCount);
Serial.write(" ");
if (redCount < 10) Serial.print(" ");
Serial.print(redCount);
Serial.write(" ");
if (yellowCount < 10) Serial.print(" ");
Serial.print(yellowCount);
Serial.write(" ");
if (pinkCount < 10) Serial.print(" ");
Serial.print(pinkCount);
Serial.write(" ");
if (whiteCount < 10) Serial.print(" ");
Serial.print(whiteCount);
Serial.write(" ");
Serial.println();
delay(1000);
}