Library Example:
'via Blog this'
6/05/2014
6/03/2014
Explain Arduino Mega 2560 R3 pins
Arduino Mega 2560
Input and Output
Each of the 54 digital pins on the Arduino 2560 Mega can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.
In addition, some pins have specialized functions:
Serial: 0 (RX) and 1 (TX);
Serial 1: 19 (RX) and 18 (TX);
Serial 2: 17 (RX) and 16 (TX);
Serial 3: 15 (RX) and 14 (TX).
Used to receive (RX) and transmit (TX) TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip.
External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.
PWM: 2 to 13 and 44 to 46. Provide 8-bit PWM output with the analogWrite() function.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI communication using the SPI library. The SPI pins are also broken out on the ICSP header, which is physically compatible with the Uno, Duemilanove and Diecimila.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.
TWI: 20 (SDA) and 21 (SCL). Support TWI communication using the Wire library. Note that these pins are not in the same location as the TWI pins on the Duemilanove or Diecimila.
The Mega2560 has 16 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and analogReference() function.
There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.
5/25/2014
UIPEthernet EchoServer example and test
Below example code. from UIPEthernet library.
/*
* UIPEthernet EchoServer example.
*
* UIPEthernet is a TCP/IP stack that can be used with a enc28j60 based
* Ethernet-shield.
*
* UIPEthernet uses the fine uIP stack by Adam Dunkels <adam@sics.se>
*
* -----------------
*
* This Hello World example sets up a server at 192.168.1.6 on port 1000.
* Telnet here to access the service. The uIP stack will also respond to
* pings to test if you have successfully established a TCP connection to
* the Arduino.
*
* This example was based upon uIP hello-world by Adam Dunkels <adam@sics.se>
* Ported to the Arduino IDE by Adam Nielsen <malvineous@shikadi.net>
* Adaption to Enc28J60 by Norbert Truchsess <norbert.truchsess@t-online.de>
*/
#include
// The connection_data struct needs to be defined in an external file.
#include
#include
EthernetServer server = EthernetServer(1000);
void setup()
{
Serial.begin(9600);
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
IPAddress myIP(192,168,1,177);
Ethernet.begin(mac,myIP);
server.begin();
}
void loop()
{
size_t size;
if (EthernetClient client = server.available())
{
if (client)
{
while((size = client.available()) > 0)
{
uint8_t* msg = (uint8_t*)malloc(size);
size = client.read(msg,size);
Serial.write(msg,size);
client.write(msg,size);
free(msg);
}
}
}
}
Testing.
$ telnet 192.168.1.177 1000
Trying 192.168.1.177...
Connected to 192.168.1.177.
Escape character is '^]'.
( typing keyboard ... for test )
5/24/2014
Arduino pro mini 3.3v 8MHz or 5V 16 MHz - ENC28J60 SPI wire pin map.
ENC28J60 SPI
Arduino pro mini 3.3v - VCC no ohm.
Arduino pro mini 5v = VCC 10 ohm
| Mini Ethernet Module | Arduino Pro Mini |
| GND | GND |
| 3.3V | 3.3V ( 250 mA, VDD = 3.45V, FCLK =10 MHz, SO = open ) |
| RESET | not connected - or connect. |
| CLKOUT | not connected |
| INT | PIN 3 |
| W0L | not connected |
| S0 | PIN 12 |
| SI | PIN 11 |
| SCK | PIN 13 |
| CS | PIN 8 or PIN 10 |
| --- | --- |
피드 구독하기:
덧글 (Atom)
