Introduction: Tweeting Lamp Bot
This instructable will teach you how to make a cell phone controlled Tweeting - Lamp. It is a simple a cool project that uses MIT app inventor as well as the particle coding environment to create a cell phone controlled lamp through IoT which tweets out personal tweets to a bot account.
The materials you will need:
- 4 Led lights (any number or color of led lights is fine, but we will use 4 for this tutorial)
- 8 pieces of 4 inch non stranded wire (to solder onto the led lights)
- 4 pieces of 4inch x 4inch wood (to make the box holder)
- A particle photon (you can get one here: https://store.particle.io/ )
- A breadboard
- A twitter account
- An MIT App Inventor Account
Step 1: Code Up the User Interface on MIT App Inventor
This will be what controls your lamp to turn on and off. I have provided pictures above for the block code and interface. Check out this tutorial for this step ( https://www.hackster.io/Richa1/mit-app-inventor-2-...
Step 2: Coding in the Particle Environment: Initializing Variables
Once you have your blocks set up on MIT App inventor, you can start writing your main code in the particle environment. You first need to get a particle photon and set up an account. (A link to their website where you can buy one can be found in the Introduction). Instructions on how to set up your photon can all be found in their documentation on their website. One you have set up your photon, you can start coding up the functions to have it tweet out and turn your led's on.
- The char variable will represent the message you want to tweet out. Type in the message you want to tweet out between the parentheses.
- The line where it says #define TOKEN is your twitter token you will put for the twitter account you will tweet to. (You can get the token by visiting this URL and doing step 1).
- Initialize the particle function so when it is called from your MIT App Inventor console, it will do the commands.
- You will also initialize your led lights and set them as outputs since they are not receiving any type of variable.
Step 3: Coding in the Particle Environment: Setting Up the Tweeting Function
This is the code to set up the tweeting function. You have to put it under void setup() in order for it to work.
Then, under your led Toggle command, write the code for turning on the led's from your MIT app interface.
Code retrieved from https://community.particle.io/t/tutorial-sending-t...
Step 4: Physical Components
- Solder the Wires onto the Led's (Purple for negative and red for positive)
- Put particle photon onto breadboard and wire us led wires onto corresponding pins. (Red to the D1-D4 pins and all purple to GND)
- Glue box together to hold your led's and breadboard (Then you can paint it)
- Connect your photon and flash your Code
Step 5: You Are Done!
Once you have flashed your code, you can connect your cellphone to the app on MIT app inventor and turn your led lights on command as well as tweet out at the same time.
Note: Since twitter has really weird regulations about the same thing being tweeted out multiple times, there is a wait of at least 1 minute between tweets before they are tweeted out.
We have a be nice policy.
Please be positive and constructive.