lee gun julee jung bin고영웅
Published © Apache-2.0

선풍기

전원을 연결하면 모터가 돌아가서 선풍기의 형태를 갖추는것을 보여준다.

BeginnerProtip1 hour7
선풍기

Things used in this project

Story

Read more

Schematics

ㅅㅍㄱ

Code

선풍기

C/C++
/*
SparkFun Inventor's Kit for Arduino
Example sketch 12

SparkFun Motor Driver

Use the SparkFun Motor Driver to control the speed and direction of a motor

This sketch was written by SparkFun Electronics,
with lots of help from the Arduino community.
This code is completely free for any use.
Visit http://learn.sparkfun.com/products/2 for SIK information.
Visit http://www.arduino.cc to learn more about Arduino.
*/

//define the two direction logic pins and the speed / PWM pin
const int DIR_A = 5;
const int DIR_B = 4;
const int PWM = 6;

void setup()
{
//set all pins as output
pinMode(DIR_A, OUTPUT);
pinMode(DIR_B, OUTPUT);
pinMode(PWM, OUTPUT);
}

void loop()
{
 //drive forward at full speed by pulling DIR_A High
 //and DIR_B low, while writing a full 255 to PWM to 
 //control speed
 digitalWrite(DIR_A, HIGH);
 digitalWrite(DIR_B, LOW);
 analogWrite(PWM, 255);

 //wait 1 second
 delay(1000);

 //Brake the motor by pulling both direction pins to 
 //the same state (in this case LOW). PWM doesn't matter
 //in a brake situation, but set as 0.
 digitalWrite(DIR_A, LOW);
 digitalWrite(DIR_B, LOW);
 analogWrite(PWM, 0);

 //wait 1 second
 delay(1000);

 //change direction to reverse by flipping the states
 //of the direction pins from their forward state
 digitalWrite(DIR_A, LOW);
 digitalWrite(DIR_B, HIGH);
 analogWrite(PWM, 150);

 //wait 1 second
 delay(1000);

 //Brake again
 digitalWrite(DIR_A, LOW);
 digitalWrite(DIR_B, LOW);
 analogWrite(PWM, 0);

 //wait 1 second
 delay(1000);
 }

Credits

lee gun ju

lee gun ju

1 project • 0 followers
lee jung bin

lee jung bin

1 project • 0 followers
고영웅

고영웅

1 project • 0 followers

Comments