Last active
April 28, 2017 02:41
-
-
Save SaraJo/794bf16682a625c6d344f71208ed2a92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2017 Jewelbots | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), | |
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
* IN THE SOFTWARE. | |
*/ | |
/* | |
* Friend Notification Example | |
* | |
* In this example, the Jewelbot is programmed to respond when a friend in the green color group is recognized. | |
* The Jewelbot will only respond the first time it sees a friend in the green color group using a boolean. | |
* In this case, the Jewelbot will buzz, show the rainbow animation, and buzz again when it first sees another | |
* Jewelbot in your green friend group. | |
* | |
* You can utilize a set of functions that return a boolean (true or false) that tell you if any friends from that | |
* friend group are around. | |
* see_red_friends() | |
* see_green_friends() | |
* see_blue_friends() | |
* see_cyan_friends() | |
* | |
* Please note that this is an early version of this functionality. Due to the nature of bluetooth, the Jewelbot might respond "as the first time" | |
* to another Jewelbot that has been nearby for a while. Similarly, the Jewelbot will respond "as the first time" when returning to showing friends | |
* after sending or receiving a message. | |
*/ | |
void setup() { | |
// Required first setup command here | |
// Set a boolean to tell the Jewelbot that Arduino code is included | |
set_arduino_coding(); | |
// put your setup code here, to run once: | |
} // setup | |
// Declare Jewelbots hardware components to use | |
Buzzer buzz; | |
Timer timer; | |
Animation animation; | |
// Declare booleans which control when you first see a friend of a particular color | |
bool first_time_red = true; | |
bool first_time_green = true; | |
bool first_time_blue = true; | |
bool first_time_cyan = true; | |
void loop() { | |
// Required command in loop to run background Jewelbots functions | |
jewelbots_run(); | |
// put your main code here, to run repeatedly: | |
// Cyan friend group: | |
if (((see_green_friends()) && (first_time_green)) && ((see_blue_friends()) && (first_time_blue))) { | |
// Put commands here when a blue friend is found | |
first_time_green = false; | |
first_time_blue = false; | |
buzz.extra_long_buzz(); | |
animation.jewelbots_logo(); | |
} else if (((!see_green_friends()) && (!first_time_green)) && ((!see_blue_friends()) && (!first_time_blue))) { | |
first_time_green = true; | |
first_time_blue = true; | |
} | |
} // loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment