Category Archives: Arduino Smart Car

Webduino Smart Car

Webduino Smart 自走車

 

Smart 自走車 ( 組裝步驟 )

Smart 自走車是 Webduino 自主研發的產品,專為 Smart 開發板量身打造,輕巧、方便又環保!不僅能 DIY 動手玩創意,還能輕鬆學習程式邏輯概念,實作出一台具個人特色的自走車。

https://tutorials.webduino.io/zh-tw/docs/useful/example/smart-robot-car-assembly.html

支援無線控制,隨心所欲、輕鬆把玩

 

Smart 自走車 ( 網頁遙控器操控 )

Smart 自走車是 Webduino 自主研發的產品,專為 Smart 開發板量身打造,輕巧、方便又環保!這個範例我們會實作如何透過網頁遙控器 ( 電腦、平板、手機皆可 ),就能操控自走車。

https://tutorials.webduino.io/zh-tw/docs/useful/example/smart-robot-car-remote-control.html

只要搭配 Webduino 雲端平台,就能輕鬆實現多種絕佳應用,最棒的是手機、平板 ( IOS / Android )、電腦都能使用!

Smart 自走車 – 網頁操控,積木程式範例:https://goo.gl/432ZRW

超音波傳感器避障小車

Webduino Smart 自走車可以搭配超過 10 種以上的傳感器, 發展出各式各樣驚奇的功能,例如無線遙控車、避障車、溫濕度感測車、無人車等多項應用,自己玩創意。

下圖為結合基礎套件裡頭的超音波傳感器,自製避障小車,當偵測到障礙物就能自動後退並改道!超音波避障車,積木程式教學範例:https://goo.gl/CXzuYT

 Smart 溫濕度感測車

這是加入「溫濕度傳感器」及 「Google 試算表」的應用,實現隨時隨地將環境溫濕度資料儲存在雲端,實作一台 Smart 溫濕度感測車,積木程式教學範例:https://goo.gl/CXzuYT

WeMos Smart Car Motor Shield

学園祭のため、IoTぼいのスマート車を作る。

しかし、注文したMotor Shield とは、違うもの(base only)が来たので、急遽自作する。

そのためのコントロールするAppも作りたいが、時間がなくって、ネットからWebページでコントロールするものを探して、沢山手直して、動くようになった。

車数台用意して、各車のIPは固定にしたいので、WiFiManager使わない方法をとった。

Webページでコントロールするから、遅延は目たつ。

時間があったら、ちゃんとアクセルペダルなど追加して、アプリの形にしたい。

// include libraries
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

#define motor_lf D3
#define motor_lb D4
#define motor_rf D6
#define motor_rb D5

// configure server
ESP8266WebServer server(80);
const char *form = "<!DOCTYPE HTML>"
"<meta name='viewport' content='width=device-width'>"
"<html>"
"<center><form action='/'>"
"<button name='dir' type='submit' value='4'>Forward</button><p>"
"<button name='dir' type='submit' value='1'>Left</button> "
"<button name='dir' type='submit' value='2'>Right</button><p>"
"<button name='dir' type='submit' value='3'>Reverse</button><p><p>"
"<button name='dir' type='submit' value='5'>Stop</button>"
"</form></center>"
"</html>";
void stop(void)
{
    analogWrite(motor_lf, 0);
    analogWrite(motor_lb, 0);
    analogWrite(motor_rf, 0);
    analogWrite(motor_rb, 0);
}
void forward(void)
{
    analogWrite(motor_lf, 1023);
    analogWrite(motor_lb, 0);
    analogWrite(motor_rf, 1023);
    analogWrite(motor_rb, 0);
}
void backward(void)
{
    analogWrite(motor_lf, 0);
    analogWrite(motor_lb, 1023);
    analogWrite(motor_rf, 0);
    analogWrite(motor_rb, 1023);
}
void left(void)
{
    analogWrite(motor_lf, 0);
    analogWrite(motor_lb, 0);
    analogWrite(motor_rf, 1023);
    analogWrite(motor_rb, 0);
}
void right(void)
{
    analogWrite(motor_lf, 1023);
    analogWrite(motor_lb, 0);
    analogWrite(motor_rf, 0);
    analogWrite(motor_rb, 0);
}
void handle_form()
{
    // only move if we submitted the form
    if (server.arg("dir"))
    {
        // get the value of request argument "dir"
        int direction = server.arg("dir").toInt();
        // chose direction
        switch (direction)
        {
            case 1:
                left();
                break;
            case 2:
                right();
                break;
            case 3:
                backward();
                break;
            case 4:
                forward();
                break;
            case 5:
                stop();
                break;
        }
        // move for 300ms, gives chip time to update wifi also
        delay(300);
    }
    
    // in all cases send the response
    server.send(200, "text/html", form);
}
void setup()
{
    // connect to wifi network
    WiFi.begin("uislab003", "**password**");
    // static ip, gateway, netmask
    WiFi.config(IPAddress(192,168,11,10), IPAddress(192,168,11,1), IPAddress(255,255,255,0));
    // connect
    while (WiFi.status() != WL_CONNECTED)
    {
        delay(200);
    }
  
    // set up the callback for http server
    server.on("/", handle_form);
    // start the webserver
    server.begin();
    pinMode(motor_lf, OUTPUT); // 
    pinMode(motor_lb, OUTPUT); // 
    pinMode(motor_rf, OUTPUT); // 
    pinMode(motor_rb, OUTPUT); // 

}
void loop()
{
    // check for client connections
    server.handleClient();
}