/* This function will "Play" Simon. We pass it a queue array of the buttons to push. It will pop off each element, calling actuate servo each time, until the array is empty */ void Challenge::Play(QueueArray<int> *colorSequence) { while (!colorSequence->isEmpty()) { actuateServo(colorSequence->pop()); } }
void onResourceInitialization(void) { for (unsigned i = 0; i < c_servo_count; ++i) { enableServo(i); actuateServo(i, 0); } }
/* This function will start the simon game. It does this by calibrating each photocell to its environment, and then pressing the center button; */ void Challenge::startSimon(int pinHolding[], int length) { for (int i = 0; i < length; i++) { Average<int> ave(100); for (int j = 0; j < 100; j++) { ave.push(analogRead(pinHolding[i])); } cellThresholds[i] = ave.mode(); } actuateServo(0); }
void consume(const IMC::SetServoPosition* msg) { actuateServo(msg->id, msg->value); }