Jason WilkieRishi Patel
Published

Alexa Controlled Fan

Alexa Controlled Fan is perfect for anyone that simply doesn't want to leave bed or whatever they're doing to turn the fan on.

BeginnerFull instructions provided2 hours1,020
Alexa Controlled Fan

Things used in this project

Hardware components

Photon
Particle Photon
×2
Breadboard (generic)
Breadboard (generic)
×2
LED (generic)
LED (generic)
×1
Servo Module (Generic)
×1

Software apps and online services

Alexa Voice Service
Amazon Alexa Alexa Voice Service
Particle

Story

Read more

Code

Code flashed on Photon with motor

C/C++
Servo myservo;

int pos = 0;


void setup() {
    myservo.attach(D0);
    
    Particle.function("toggleLights", toggleLights);

    
}

int toggleLights(String command){
        if (command == "toggleLights"){
        
       for(pos = 0; pos < 90; pos += 1)  

      {  delay(50);
    
       myservo.write(pos);            
  }
 
        }

}

void loop() {

}

Code flashed on Photon with LED

C/C++
int led1 = D0; 


void setup() {

  pinMode(led1, OUTPUT);
  digitalWrite(led1, LOW);
  Particle.subscribe("toggleLights", flash, "Device ID of photon being subscribed to");
  
}

void flash(const char *event, const char *data){
    
     digitalWrite(led1, HIGH);
     delay(2000);
     digitalWrite(led1, LOW);
}


void loop() {
    

}

Credits

Jason Wilkie
1 project • 0 followers
UNCC Mechanical Engineering Student
Contact
Rishi Patel
1 project • 0 followers
Contact
Thanks to John McAlpine.

Comments

Please log in or sign up to comment.