Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 4937|回復: 7
打印 上一主題 下一主題

arduino用變壓器的問題

[複製鏈接]
跳轉到指定樓層
1#
發表於 2012-1-10 16:40:56 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
各位大大,請問一下,小弟現在用arduino + ethernet shield這兩塊板子,寫一個簡單的hello world網頁,如果我用電腦的usb供電的話,都沒有問題,但如果改變壓器(DC 9V)的話,為什麼都無法動作.想請問是不是有什麼要做設定的?
2#
發表於 2012-1-10 22:52:19 | 只看該作者
Arduino獨立電源9v是對的呀,你要不要再多說明一些,這樣很難幫你看問題
3#
發表於 2012-1-11 02:40:08 | 只看該作者
電腦或9V供電是沒差的
但你是否有利用COM跟arduino 通訊
若有那當然不能用囉
電腦那條USB線除了供電以外也理所當然提供了COM連線
若拔掉改9V又要COM, 就得另外有TTL 2 RS232轉板才行

但若沒有使用COM...那就先把照片照來看看吧
理論是不用設定
但可能哪裡錯了
也可能9V那個部份是壞的哩
4#
 樓主| 發表於 2012-1-11 18:32:54 | 只看該作者
謝謝樓上的兩位大大的講解。

我現在就只有做這樣簡單的事(#define和include沒打上來,很多),就如同我上面說的,如果用電腦的usb供電的話,去連這個網頁,看的到字,但如果是用外接電源,則會連不上這個網頁。

void setup()
{
    Ethernet.begin(mac, ip, gateway, subnet);
    server.begin();
}


void loop()
{
    Client client = server.available();

    if (client)
    {
        while (client.connected())
        {
            if (client.available())
            {
                char c = client.read();
                //read char by char HTTP request
                if (readString.length() < 30)
                {
                    //store characters to string
                    readString += c;
                }//end if (readString.length() < 30)

                //output chars to serial port
                //Serial.print(c);

                //if HTTP request has ended
                if (c == '\n')
                {
                    // now output HTML data starting with standart header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println();
                    client.print("<body>");
                    //想show在網頁上的寫在這---start----
                    client.println("<h1>HTTP test routines</h1>");
                    //想show在網頁上的寫在這---end----
                    client.println("</body></html>");
                    //clearing string for next read
                    readString="";
                    //stopping client
                    client.stop();
                }//end if (c == '\n')

            }//end if (client.available())

        }//end while (client.connected())
    }//end if (client)
}
5#
發表於 2012-1-11 23:14:27 | 只看該作者
那這樣我更懷疑9V供電是壞的了

1. 先看9V給電時, 版子電源是否有亮
2. 在看給電後, 板上的5V/3.3V兩隻腳有沒有確實輸出這個電壓

wifi shield 也是從5V取電
也許你版子的電源或是變壓器根本就壞的哩
6#
發表於 2012-1-11 23:28:41 | 只看該作者
你可以試燒一下這個範例嗎?

/*
  Web Server

A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe

*/

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
          }
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}
7#
 樓主| 發表於 2012-1-13 11:15:55 | 只看該作者
miaoichi大大,用你的code一樣也不能呢.....
mzw2008大大,我想會不會是我的ethernet shield這塊板子有問題?因為我arduino uno有3片,3片都換過,一樣也是不能,看來要來去借ethernet shield這塊板子了
8#
發表於 2012-1-13 23:50:06 | 只看該作者
我的意思是...各個接頭一個一個去試
確認電壓是正確的
輸出的波形也該正確
這樣可以確認到底問題出在哪裡
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-5-3 18:35 , Processed in 0.137409 second(s), 9 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表