Justin Kim
Published © GPL3+

Just make it!! BT Smart Fan :)

You can make Bluetooth Fan!!

BeginnerFull instructions provided5,172
Just make it!! BT Smart Fan :)

Things used in this project

Hardware components

WIZwiki-W7500
WIZnet WIZwiki-W7500
×1
Arduino Motor Shield
×1
YWROBOT Easy Module Shield V1
×1
HC-06 Bluetooth Module
×1
Servos (Tower Pro MG996R)
×1
DC motor (generic)
×1

Hand tools and fabrication machines

mbed Web Compiler

Story

Read more

Schematics

All stacking position

just stacking

Code

BTSmartFan_WIZwiki-W7500

C/C++
BTSmartFan_WIZwiki-W7500
/**
 ******************************************************************************
 * @project  Smart BT Fan
 * @author  Justin Kim
 * @version V1.0.0
 * @date    29-JUN-2015
 * @brief   Main program body
*******************************************************************************
**/
 
/* Includes ------------------------------------------------------------------*/
#include "mbed.h"
#include "Servo.h"
 
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
Serial pc(USBTX, USBRX);
Serial bt(PA_14, PA_13);
Servo myservo(D14);
PwmOut Motor(D3);
DigitalOut direction(D12);
 
/* Private function prototypes -----------------------------------------------*/
 
/* Private functions ---------------------------------------------------------*/
/**
   * @brief     Main Function
   * @param  None
   * @retval    None
   */
int main(void)
{
    char ch;
    pc.baud(115200);
    bt.baud(115200);
    pc.printf("Hello World!\n\r");
    bt.printf("Hello World!\r\n");
    
    direction.write(1);
    Motor.period_ms(1);
    
    while(1)
    {
        if(bt.readable())
        {
            ch=bt.getc();
            pc.printf("%c",ch);
            bt.printf("%c",ch);
                                  
            if(ch == '*')
            {
                myservo = 0.5;
            }
            else if(ch == '+')
            {
                myservo = myservo + 0.1;
            }
            else if(ch == '-')
            {
                myservo = myservo - 0.1;
            }     
            else if(ch == '@')
            {
                Motor.write(0.8);
            }
            else if(ch == '!')
            {
                Motor.write(0);
            }
        }
        
        else if(pc.readable())
        {
            ch=pc.getc();
            bt.printf("%c",ch);
            pc.printf("%c",ch);            
                        
            if(ch == '*')
            {
                myservo = 0.5;
            }
            else if(ch == '+')
            {
                myservo = myservo + 0.1;
            }
            else if(ch == '-')
            {
                myservo = myservo - 0.1;
            }
            else if(ch == '@')
            {
                Motor.write(0.8);
            }
            else if(ch == '!')
            {
                Motor.write(0);
            }
        }
    }
}

Credits

Justin Kim
6 projects • 7 followers
Contact

Comments

Please log in or sign up to comment.