Voice Activated Couch Recliner

by ronan_agsalud in Circuits > Audio

101 Views, 1 Favorites, 0 Comments

Voice Activated Couch Recliner

25211017-cartoon-humor-concept-illustration-of-couch-potato-saying-or-proverb.jpg

Do you feel extra lazy to even press the buttons on your couch recliner? Well this project allows you to not reach over to the side of the couch to let that nice couch move up or down. With the use of a Particle Argon and some servos, the servos will press the buttons when given the command. Needs an iphone to work.

Supplies

Particle Argon

2 Servos

IOS Device

Tape

Wires

The Code

Servo myServo1;
Servo myServo2;


void setup() {
    myServo1.attach(2);
    myServo1.write(120);
    
    myServo2.attach(3);
    myServo2.write(100);
    
    Particle.function("recline", moveServo1);
    Particle.function("decline", moveServo2);
    Particle.function("reclineMore", moveServo3);
    Particle.function("declineMore", moveServo4);
    
}


void loop() { 
    
}


int moveServo1(String param){
   
    myServo1.write(180);
    delay(10000);
    myServo1.write(120);
    return 0;
}


int moveServo2(String param){
    
    myServo2.write(170);
    delay(10000);      
    myServo2.write(150);
    return 0; 
}    


int moveServo3(String param){
   
   myServo1.write(170);
   delay(3000);        
   myServo1.write(150);
   return 0; 
}


int moveServo4(String param){
   
    myServo2.write(170);
    delay(3000);      
    myServo2.write(150);
    return 0; 
}

Go to the particle website and login into the Web IDE.

Copy and paste the code above into a new code, you can name the code whatever you want.

At 'Particle.function("public function", moveServo), change the public function to the appropriate name.

Creating the Webhooks

unnamed.png
unnamed.png
unnamed.png
unnamed.png
unnamed.png

These next two steps will be a lot in order to set up a connection between the phone and the argon.

  1. Compose a link for the webhook

The link requires a DEVICE-ID and ACCESS-CODE.

For the DEVICE-ID head to the Particle Web IDE, go to the bottom left corner and click on the "Devices" tab. Then go to the top of the popped up tab and click on the arrow with the device name. The device code would pop up Copy down the code.

For the ACCESS-CODE head to this particle doc. Sign into the box if needed and scroll down to where it says "Create a Token (Browser-Based)." Enter your password and select the amount of time you want to keep the access code valid. Note: You have to replace an access code that expires. Once clicking "Create", an access code will pop up. Copy down the code.

Once getting both, create a URL link with the exact format shown below.

Name the public function to anything, but make sure that you save it.


https://api.particle.io/v1/devices/DEVICE-ID/public function/?access_token=ACCESS-CODE


Once making the URL, go to the particle console.

Click on integrations --> +ADD NEW INTERGATION --> Webhook

Fill the information in with:

  • A name of your choice
  • The [event name] (it can be of your choice)
  • The URL
  • Request Type: POST
  • Request Format: Web Form
  • Device: Any
  • Status: Enabled

----> SAVE

Repeat all this step for every webhook. A webhook would be made for every command

Make sure there's a new access code for each one.

Setting Up IOS Shortcuts

0.jpg
0.jpg
0.jpg

Go to the IOS shortcuts app

  • Make a new Shortcut
  • +Add action --> Dictate text
  • (OPTIONAL) create a list of the exact words used to activate, make sure it's exact, with an upper case first letter
  • Set up an if statement to check if that list contains the dictated text
  • Put an otherwise function with a notification command stating it's a false command
  • Create an if statement checking if the Dictate Text says a desired word/phrase
  • if true, search up "Get contents of URL" and copy and paste this: https://api.particle.io/v1/devices/events
  • Change Method type to POST
  • Add a new header
  • Key: Authorization
  • Text: Bearer ACCESS-CODE
  • Change Request Body: to Form
  • Add new field --> text
  • key: name
  • [event name]
  • Repeat the entire last bullet point for every webhook

The Hardware

0.jpg
unnamed.jpg

Make sure all the wires are put in correctly.