tailieunhanh - Practical Arduino Cool Projects for Open Source Hardware- P14
Practical Arduino Cool Projects for Open Source Hardware- P14: A schematic or circuit diagram is a diagram that describes the interconnections in an electrical or electronic device. In the projects presented in Practical Arduino, we’ve taken the approach of providing both a photograph and/or line drawing of the completed device along with a schematic. While learning to read schematics takes a modest investment of your time, it will prove useful time and time again as you develop your projects. With that in mind, we present a quick how-to in this section | CHAPTER 7 ONLINE THERMOMETER include Modify the following two lines to suit your local network configuration. The MAC and IP address have to be unique on your LAN static uint8_t myMac 6 0x54 0x55 0x58 0x10 0x00 0x24 static uint8_t myIp 4 192 168 1 15 static char baseurl http static uint16_t myPort 80 Listen port for tcp www range 1-254 It s essential that the MAC address setting be unique on your network so if you have multiple Arduinos connected you could decrement the last value 0x24 for each subsequent device. Make sure you keep track of what value you ve assigned to each one. Likewise the IP address needs to be unique on your network and you need to enter it twice once as the four elements in the myIp array and then as a string in baseurl. These values are different because the TCP IP stack needs to use the actual local IP address in the headers but the web page that is created also needs to display a form that submits to itself and the address used in your browser may be different to the actual IP address if your device is behind a NAT network address translation device such as as firewall. If you want to expose your device externally you should set the actual local IP address in the myIp variable and set the external address in the baseurl variable. The myPort value can be changed if you want your device to listen on a port other than the default port 80. However if you change it make sure you also change the baseurl variable to include the port number or the form won t work. For example if you wanted to listen on port 81 you could change those lines to the following static char baseurl http 81 static uint16_t myPort 81 Listen port for tcp www range 1-254 The program then creates two buffers used in creating the TCP IP packet and creates an instance of the EtherShield object called es as follows Set up variables for the TCP IP buffer define BUFFER_SIZE 500 static uint8_t buf BUFFER_SIZE 1 define STR_BUFFER_SIZE 22 .
đang nạp các trang xem trước