This year there have been a few attempts at connecting your smartphone to your Arduino. (see Amarino, Adafruit’s BlueFruit UART) Thanks to the MakerHive I recently had a chance to play with the 1Sheeld and come up with a demo project for it.
The 1Sheeld is a board that plugs into an Arduino Uno (thus the misspelling of “shield”) and redirects the UART to Bluetooth so it can send/receive information to/from a smartphone. The PCB is a bit expensive at over $50, but it’s a complete solution that is really simple to program. It is seriously easier than the already-simple Arduino it rides on.
Once the 1Sheeld PCB is plugged into the Arduino and powered up it can communicate with the 1Sheeld app on a smartphone. Once connected, the app let’s you select from a number of “virtual shields.” Check out the list of possibilities. http://1sheeld.com/shields/
As a demo project, I made a talking HAL button for the MakerHive. The bot is supposed to greet visitors when the arrive and say good-bye when they left. It will also take a picture of the person and tweet it (the twitter feed will of course be chrome-casted to the TV in the Hive.) Check out the code and video below as well as the Hackster.io page for this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
/* Hospitality HAL code using 1Sheeld and Arduino Uno By Michael Sizemore 5/14/2015 Hardware consists of Big Red Dome Button from sparkfun and a box of your choosing Arduino simply controls the LED in the Big Red Dome Button to make it look like HAL is talking */ #include <OneSheeld.h> const int pinLED = 9; bool isConnected = false; bool buttonPressed = false; String name = ""; void setup() { OneSheeld.begin(); pinMode(pinLED, OUTPUT); randomSeed(analogRead(0)); } void action() { TextToSpeech.say("Welcome"); HALspeaks(1000); OneSheeld.delay(1000); TextToSpeech.say("Okay, switch to the Voice Recognition shield and tell me your name"); OneSheeld.delay(500); HALspeaks(3400); while((!VoiceRecognition.isNewCommandReceived()) && (OneSheeld.isAppConnected())){ OneSheeld.delay(10); } name = VoiceRecognition.getLastCommand(); TextToSpeech.say("Good to see you" + name + ", Are you arriving or leaving?"); HALspeaks(3000); while((!VoiceRecognition.isNewCommandReceived()) && (OneSheeld.isAppConnected())){ OneSheeld.delay(10); } if (!strcmp("arriving",VoiceRecognition.getLastCommand())) { TextToSpeech.say("Great! Welcome to the MakerHive"); HALspeaks(2000); Camera.frontCapture(); OneSheeld.delay(3000); // Twitter.tweetLastPicture(name + " just got to the MakerHive!", 0); Twitter.tweetLastPicture(name + " just got to the MakerHive!", 0); } else if (!strcmp("leaving",VoiceRecognition.getLastCommand())){ TextToSpeech.say("Ok " + name +", see you next time!"); HALspeaks(2000); Camera.frontCapture(); // Twitter.tweetLastPicture("L8RS", 0); OneSheeld.delay(3000); Twitter.tweetLastPicture("Thanks for coming " + name, 0); } else TextToSpeech.say("I didn't catch any of that. Disconnect and try again."); } void HALspeaks (unsigned long duration) { // Make the button LED pulse as if it were talking unsigned long startTime = millis(); while ((millis()-startTime)<duration) { //HAL is talking int attackTime = random(0,300); int fadeTime = random(0,200); // ramp LED up for (int i = 0; i<attackTime; i++) { int j = map(i, 0, attackTime, 0, 255); analogWrite(pinLED, j); OneSheeld.delay(1); } // ramp LED down for (int i = fadeTime; i>1; i--) { int j = map(i, 0, fadeTime, 0, 255); analogWrite(pinLED, j); OneSheeld.delay(1); } } analogWrite(pinLED, 0); } void HALwaits () { // Make the button LED pulse as if it were talking int attackTime = 500; int fadeTime = 500; unsigned long startTime = millis(); // ramp LED up for (int i = 0; i<attackTime; i++) { int j = map(i, 0, attackTime, 0, 120); analogWrite(pinLED, j); OneSheeld.delay(1); } // ramp LED down for (int i = fadeTime; i>0; i--) { int j = map(i, 0, fadeTime, 0, 120); analogWrite(pinLED, j); OneSheeld.delay(1); } //HAL fades out analogWrite(pinLED, 0); } void loop() { if (OneSheeld.isAppConnected()) { if (!isConnected){ isConnected = true; OneSheeld.delay(5000); action(); } } else { isConnected = false; HALwaits(); } } |