Our first tinkering experience with the Annikken Andee U shield proved that it is possible for us to use it to control our product!
We did further work on the coding to create widgets which could control the various fingers of our exoskeleton individually. The widgets were named according to the pins that the motors were attached to on the Arduino Mega.
Figure 1: Screenshot of the layout of our widgets
The video below shows how our phone can successfully control each finger via Annikken Andee!
Our code:
#include <SPI.h> #include <Andee.h> #include <Servo.h> AndeeHelper btnTurnLeft1; AndeeHelper btnTurnRight1; AndeeHelper btnStop1; AndeeHelper btnTurnLeft2; AndeeHelper btnTurnRight2; AndeeHelper btnStop2; AndeeHelper btnTurnLeft3; AndeeHelper btnTurnRight3; AndeeHelper btnStop3; AndeeHelper btnTurnLeft4; AndeeHelper btnTurnRight4; AndeeHelper btnStop4; AndeeHelper btnTurnLeft5; AndeeHelper btnTurnRight5; AndeeHelper btnStop5; Servo servot1; Servo servot2; Servo servot3; Servo servot4; Servo servot5; void setup() { Andee.begin(); Andee.setName("Servo Demo"); Andee.clear(); //? servot1.attach(3); servot1.write(90); servot2.attach(4); servot2.write(90); servot3.attach(5); servot3.write(90); servot4.attach(6); servot4.write(90); servot5.attach(7); servot5.write(90); setInitialData(); //Do i need a serial.begin(9600) here? NO } void setInitialData() { // Initialize buttons // Set 1: Pin 3 btnTurnLeft1.setId(0); btnTurnLeft1.setType(BUTTON_IN); btnTurnLeft1.setLocation(0,0,ONE_QUART); btnTurnLeft1.setTitle("Open Pin 3"); btnTurnLeft1.requireAck(false); btnTurnRight1.setId(1); btnTurnRight1.setType(BUTTON_IN); btnTurnRight1.setLocation(1,0,ONE_QUART); btnTurnRight1.setTitle("Close Pin 3"); btnTurnRight1.requireAck(false); btnStop1.setId(2); btnStop1.setType(BUTTON_IN); btnStop1.setLocation(2,0,ONE_QUART); btnStop1.setTitle("Stop Pin 3"); btnStop1.requireAck(false); // Set 2: Pin 4 btnTurnLeft2.setId(3); btnTurnLeft2.setType(BUTTON_IN); btnTurnLeft2.setLocation(0,1,ONE_QUART); btnTurnLeft2.setTitle("Open Pin 4"); btnTurnLeft2.requireAck(false); btnTurnRight2.setId(4); btnTurnRight2.setType(BUTTON_IN); btnTurnRight2.setLocation(1,1,ONE_QUART); btnTurnRight2.setTitle("Close Pin 4"); btnTurnRight2.requireAck(false); btnStop2.setId(5); btnStop2.setType(BUTTON_IN); btnStop2.setLocation(2,1,ONE_QUART); btnStop2.setTitle("Stop Pin 4"); btnStop2.requireAck(false); // Set 3: Pin 5 btnTurnLeft3.setId(6); btnTurnLeft3.setType(BUTTON_IN); btnTurnLeft3.setLocation(0,2,ONE_QUART); btnTurnLeft3.setTitle("Open Pin 5"); btnTurnLeft3.requireAck(false); btnTurnRight3.setId(7); btnTurnRight3.setType(BUTTON_IN); btnTurnRight3.setLocation(1,2,ONE_QUART); btnTurnRight3.setTitle("Close Pin 5"); btnTurnRight3.requireAck(false); btnStop3.setId(8); btnStop3.setType(BUTTON_IN); btnStop3.setLocation(2,2,ONE_QUART); btnStop3.setTitle("Stop Pin 5"); btnStop3.requireAck(false); // Set 4: Pin 6 btnTurnLeft4.setId(9); btnTurnLeft4.setType(BUTTON_IN); btnTurnLeft4.setLocation(0,3,ONE_QUART); btnTurnLeft4.setTitle("Open Pin 6"); btnTurnLeft4.requireAck(false); btnTurnRight4.setId(10); btnTurnRight4.setType(BUTTON_IN); btnTurnRight4.setLocation(1,3,ONE_QUART); btnTurnRight4.setTitle("Close Pin 6"); btnTurnRight4.requireAck(false); btnStop4.setId(11); btnStop4.setType(BUTTON_IN); btnStop4.setLocation(2,3,ONE_QUART); btnStop4.setTitle("Stop Pin 6"); btnStop4.requireAck(false); // Set 5: Pin 7 btnTurnLeft5.setId(12); btnTurnLeft5.setType(BUTTON_IN); btnTurnLeft5.setLocation(3,0,ONE_THIRD); btnTurnLeft5.setTitle("Open Pin 7"); btnTurnLeft5.requireAck(false); btnTurnRight5.setId(13); btnTurnRight5.setType(BUTTON_IN); btnTurnRight5.setLocation(3,1,ONE_THIRD); btnTurnRight5.setTitle("Close Pin 7"); btnTurnRight5.requireAck(false); btnStop5.setId(14); btnStop5.setType(BUTTON_IN); btnStop5.setLocation(3,2,ONE_THIRD); btnStop5.setTitle("Stop Pin 7"); btnStop5.requireAck(false); } void loop() { // Controls what buttons do // Set 1: Pin 5 - Control if( btnTurnLeft1.isPressed() > 0 ) { btnTurnLeft1.ack(); servot1.write(70); delay(5); } if( btnTurnRight1.isPressed() > 0 ) { btnTurnRight1.ack(); servot1.write(100); delay(5); } if( btnStop1.isPressed() > 0 ) { btnStop1.ack(); servot1.write(90); delay(5); } // Set 2: Pin 6 - Control if( btnTurnLeft2.isPressed() > 0 ) { btnTurnLeft2.ack(); servot2.write(70); delay(5); } if( btnTurnRight2.isPressed() > 0 ) { btnTurnRight2.ack(); servot2.write(100); delay(5); } if( btnStop2.isPressed() > 0 ) { btnStop2.ack(); servot2.write(90); delay(5); } // Set 3: Pin 7 - Control if( btnTurnLeft3.isPressed() > 0 ) { btnTurnLeft3.ack(); servot3.write(70); delay(5); } if( btnTurnRight3.isPressed() > 0 ) { btnTurnRight3.ack(); servot3.write(100); delay(5); } if( btnStop3.isPressed() > 0 ) { btnStop3.ack(); servot3.write(90); delay(5); } // Set 4: Pin 8 - Control if( btnTurnLeft4.isPressed() > 0 ) { btnTurnLeft4.ack(); servot4.write(70); delay(5); } if( btnTurnRight4.isPressed() > 0 ) { btnTurnRight4.ack(); servot4.write(100); delay(5); } if( btnStop4.isPressed() > 0 ) { btnStop4.ack(); servot4.write(90); delay(5); } // Set 5: Pin 9 - Control if( btnTurnLeft5.isPressed() > 0 ) { btnTurnLeft5.ack(); servot5.write(80); delay(5); } if( btnTurnRight5.isPressed() > 0 ) { btnTurnRight5.ack(); servot5.write(100); delay(5); } if( btnStop5.isPressed()) { btnStop5.ack(); servot5.write(90); delay(5); } // Button Updates btnTurnLeft1.update(); btnTurnRight1.update(); btnStop1.update(); btnTurnLeft2.update(); btnTurnRight2.update(); btnStop2.update(); btnTurnLeft3.update(); btnTurnRight3.update(); btnStop3.update(); btnTurnLeft4.update(); btnTurnRight4.update(); btnStop4.update(); btnTurnLeft5.update(); btnTurnRight5.update(); btnStop5.update(); delay(5); }
Bluetooth Control – Further Work on the Annikken Andee