Name: Alexa Semaphore Flags
Introduction: Alexa is great for keeping track of time through alarms and timers, but sometimes you’re gaming with a headset on, or cooking using a loud extractor fan; and according to a 2012 study of US adults (https://www.cdc.gov/nchs/data/series/sr_10/sr10_260.pdf), approximately 15% of people have some trouble hearing. These things can make it harder to use Alexa. I have a friend with hearing difficulties and she would often miss alarms that she had set using Alexa when she was cooking which meant her food would often get burnt, so my real aim here was to make something that could help her out. People are generally very good at detecting movement, even out the corner of their eyes so I realised that having some flags indicate when Alexa was doing things could be really helpful if you can’t hear it.
Description: The Mindstorms device has two flags on it, the smaller blue flag indicates when Alexa has heard you, and the red flag indicates when alarms, reminders or timers are ringing on the device. The flag will go to different angles to show different things.
You can test it is working by saying Alexa, and the small blue flag will move around. The red flag will move to indicate timers, reminders and alarms.
Mindstorms Code: https://github.com/FrogletApps/Alexa_Semaphore_Flags
Skill Code: No Alexa skill is needed for this project
Mindstorms Building Instructions: https://github.com/FrogletApps/Alexa_Semaphore_Flags/blob/master/Lego%20Semaphore%20Design.pdf
Bricks needed: https://github.com/FrogletApps/Alexa_Semaphore_Flags/blob/master/Lego%20Semaphore%20Parts%20List.xlsx
- Build the Mindstorms device using the instructions here: https://github.com/FrogletApps/Alexa_Semaphore_Flags/blob/master/Lego%20Semaphore%20Design.pdf
- Put EV3DEV onto the Mindstorms brain using these instructions: https://www.ev3dev.org/docs/getting-started/
- I think the easiest way to load files onto the Mindstorms brain is by setting up a development environment (however you can skip this step if you want to do it another way): https://www.hackster.io/alexagadgets/lego-mindstorms-voice-challenge-setup-17300f
- You will also need to register as an Alexa developer and set up your Mindstorms model as an Alexa device, you can do that by following the instructions here: https://www.hackster.io/alexagadgets/lego-mindstorms-voice-challenge-mission-1-f31925#toc-register-an-alexa-gadget-in-the-alexa-developer-console-1
- Get the Python code from the GitHub repository https://github.com/FrogletApps/Alexa_Semaphore_Flags/blob/master/alexaMindstorm.py
- You’ll need to create a .ini file where the name of the file matches the name of your Python code. Copy and paste the code from the bottom of these instructions to get it to work
- Load the Python code and .ini file onto the Mindstorms brain, you can do this inside Visual Studio Code by pressing the download button once you’ve connected to the device.
- Once your code is on the device you find the file in the Mindstorms file browser and then click run. Once the code is running you can go to your Alexa app and pair the device by going to the settings in the Alexa app and selecting “Pair Alexa Gadget”
- Pick your Mindstorms device in the list
- It will make 2 quick beeps when it connects, then 3 more beeps when it’s connected. You can test it is working by saying Alexa, and the small blue flag will move around. The red flag will move to indicate timers, reminders and alarms.
Once this setup is complete the devices will pair automatically and it needs no prompting or manual intervention to work.
How I created it: I started off by building the device. I really wanted both arms to be able to pivot through the same point, so I worked through a few designs. I started by searching for similar designs, many had complicated gearboxes, these allowed for the whole device to run off of one motor but didn’t allow the arms to move independently. I designed my version from scratch in the end, the two axles can go through one point by using a mini turntable (parts 99009 https://www.bricklink.com/v2/catalog/catalogitem.page?P=99009and 99010 https://www.bricklink.com/v2/catalog/catalogitem.page?P=99010). This design worked brilliantly for what I needed so this is what I settled on.
In this 3D render (from Step 10 of my instructions) you can see the black axle is running from the bottom motor, but the black gear that runs around it is being driven by the top motor. This allows me to run two arms around the same axis.
I initially wrote some test code just to spin the motors to make sure that everything worked correctly, then I started on my project. I started with the code from the first demo project provided as part of the instructions for this challenge as it did some of the things I wanted my final design to do. I then adjusted this by adding functionality like detecting alarms, timers and reminders and customising it to work how I needed it to.
This screenshot shows how the code that checks for the different Alexa states works. Once this code recieves a new state it runs through the if statements and checks to see if any of the values match, then if they do it will see if it is active or has been cleared and will then move the arms and play a noise accordingly.
I also had to adjust the angle that the red motor is moved by as although the motor thinks it may be moving a certain amount, the arm won't move as far as the gears are different sizes. To adjust for this I added a function that takes the normal input and adjust the figure by the right amount.
Things for the future: At the moment there is no reset for the flags, this isn’t so important for the red flag (although this will get out of sync over time due to the Lego motors movements not being especially precise), but as the blue flag needs the gears which unfortunately aren’t the same size the movements are slightly less precise and it will get out of sync over time. In future I would like to add a reset using the ultrasound or laser sensor so you can detect the position of the flags and reset their position over time
I would also like to add a clock mode, so it can display the time
As well as this I would like to add a skill so it can be used as an educational tool for children, so they can ask the skill what 3:00 looks like, and the hands move to that position, and the skill could contain a quiz where it asks what time it is currently showing. I would need to be able to reset the flag positions to get this to work properly.
Paste the code below into your .ini file
amazonId = **YOUR AMAZON ID HERE**
alexaGadgetSecret = **YOUR SECRET CODE HERE**
Alexa.Gadget.StateListener = 1.0 - wakeword, timers, alarms, reminders, timeinfo