[Arduino]WiFi Shield & Motor Driver 제어
2014. 3. 17. 21:00ㆍ2018년 이전 관심사/개발관련
반응형
Step 1 : H/W
- TA8050P ( Motor Driver )
- Features
- Bidrectional DC motor driver
- Current capacity : 1.5A
- Four modes : Forward, Reverse, Stop, and Brake
- Block Diagram and Pin Layout
Pin Description
- H/W Layout
WizFi250-EVB(Wi-Fi Shield)
Feature
Arduino Pin Compatible
Single band 2.4GHz IEEE 802.11b/g/n
Intergrated RF power amplifier
Supports wiress data rates up to 65Mbit/s
1MB Flash Memory, 128KB SRAM, 1MB Serial Flash
Serial Interface : UART, SPI
EVB-Interface
EVB-Schematic
Step 2: WizFi250 Arduino Library Download
아래 주소에서 WizFi250 Library를 다운로드 한 후, RC car 예제를 이용하면 된다.
Source Code
#include <Arduino.h>
#include <SPI.h>
#include <IPAddress.h>
#include "WizFi250.h"
#include "WizFi250_udp.h"
#define SSID "kaizen_home1"
#define KEY "qwertyuiop"
#define AUTH ""
//#define DEBUG
#define LEFT_1 5
#define LEFT_2 6
#define RIGHT_1 7
#define RIGHT_2 8
#define REMOTE_PORT 5000
#define LOCAL_PORT 5000
IPAddress ip (192,168,15,1);
IPAddress gateway (192,168,15,1);
IPAddress mask (255,255,255,0);
IPAddress timeServer (0,0,0,0);
WizFi250 wizfi250;
WizFi250_UDP Udp(timeServer,LOCAL_PORT,REMOTE_PORT);
boolean Wifi_setup = false;
void setup()
{
Serial.begin(9600);
Serial.println("\r\nSerial Init");
wizfi250.begin();
wizfi250.setDebugPrint(4);
wizfi250.hw_reset();
RCpinSetup();
wizfi250.sync();
wizfi250.setDhcp();
for(int i=0; i<10; i++)
{
if( wizfi250.join(SSID,KEY,AUTH) == RET_OK )
{
Wifi_setup = true;
break;
}
}
}
void loop()
{
uint8_t cmd;
if( Wifi_setup )
{
wizfi250.RcvPacket();
if( Udp.available() )
{
cmd = Udp.recv();
if( cmd == (uint8_t)'1') // Forward
{
Serial.println("Forward");
moveForward();
}
else if( cmd == (uint8_t) '2') // Backward
{
Serial.println("Backward");
moveBackward();
}
else if( cmd == (uint8_t) '3') // Turn Right
{
Serial.println("Turn Right");
turnRight();
}
else if( cmd == (uint8_t) '4')
{
Serial.println("Turn Left");
turnLeft();
}
cmd = NULL;
}
else
{
Udp.begin();
}
}
}
void RCpinSetup()
{
pinMode(LEFT_1, OUTPUT);
pinMode(LEFT_2, OUTPUT);
pinMode(RIGHT_1, OUTPUT);
pinMode(RIGHT_2, OUTPUT);
}
void moveForward()
{
digitalWrite(LEFT_2, LOW);
digitalWrite(RIGHT_2, LOW);
delay(200);
digitalWrite(LEFT_2, HIGH);
digitalWrite(RIGHT_2,HIGH);
}
void moveBackward()
{
digitalWrite(LEFT_1, LOW);
digitalWrite(RIGHT_1, LOW);
delay(200);
digitalWrite(LEFT_1, HIGH);
digitalWrite(RIGHT_1,HIGH);
}
void turnRight()
{
digitalWrite(LEFT_1, LOW);
digitalWrite(RIGHT_2, LOW);
delay(200);
digitalWrite(LEFT_1, HIGH);
digitalWrite(RIGHT_2,HIGH);
}
void turnLeft()
{
digitalWrite(LEFT_2, LOW);
digitalWrite(RIGHT_1, LOW);
delay(200);
digitalWrite(LEFT_2, HIGH);
digitalWrite(RIGHT_1,HIGH);
}
Step 3: Demo Video
참고
- [TA8050P 그림], http://mclab.silla.ac.kr/lecture/201201/es/es-arduino-lecture-09.pdf
- [TA8050P DataSheet], http://pdf1.alldatasheet.com/datasheet-pdf/view/31394/TOSHIBA/TA8050P.html
- [WizFi250], http://wizwiki.net/wiki/doku.php?id=products:wizfi250:start
반응형
'2018년 이전 관심사 > 개발관련' 카테고리의 다른 글
[Arduino]WIZ550 ioShield-A 기반의 FTP Server 구현(SD Card 사용) (0) | 2014.08.27 |
---|---|
[Arduino] Temperature Monitoring System using Xively Server & WizFi250 (8) | 2014.03.19 |
[Python] Print 변수 출력하기 (0) | 2014.02.19 |
[Arduino Uno WiFi Shield]WizFi250과 Xively를 이용하여 온도 센서 모니터링 하기 (2/2) (0) | 2014.02.18 |
[Arduino Uno] WizFi250과 Xively를 이용하여 온도 센서 모니터링 하기 (1/2) (0) | 2014.02.18 |