Programar ATtiny85 con Arduino

1. Programador

Para utilizar un arduino (UNO en este ejemplo) como programador del Attiny85, este es el pinout:


El capacitor que se debe usar es de 10 uF


2. Configuración del IDE de Arduino

Para version 1.8.9 de Arduino IDE:

1. File/Preferences/Additional Boards Manager URL:
https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

2. Tools/Board/Boards Manager/Buscar attiny e instalarlo

3. Quitar el shield que tiene el socket del attiny antes del siguiente paso [ESTO ES SOLAMENTE SI SE VA A CONFIGURAR EL ARDUINO PROGRAMADOR POR PRIMERA VEZ]

4. Tools / Board / Arduino UNO
    Tools / Programmer / AVRISP mkII
    Abrir File/Examples/ArduinoISP
    Subirlo al Arduino UNO

5. Conectar el shield

6. Tools / Board / Attiny25/45/85
    Processor: Attiny85
    Clock: Internal 8MHZ
    Programmer: Arduino as ISP

7. Si es la primera vez que se va a usar el attiny85, hay que cambiarle el reloj a 8Mhz: para esto: Tools/Burn Bootloader

8. Subir codigo al Attiny85


Para poder utilizar la librería MANCHESTER, no sirve el del link anterior, hay que bajar el de este link:
https://drive.google.com/?authuser=0#folders/0B8buGbwpnmSkWkNIT1N3TUJmTGM
y seleccionar el que dice ATtiny85 @ 8Mhz



Fuentes:
http://hlt.media.mit.edu/?p=1706
http://tronixstuff.wordpress.com/2011/11/23/using-an-attiny-as-an-arduino/
http://www.youtube.com/watch?v=30rPt802n1k
http://hlt.media.mit.edu/?p=1695




En este caso se utilizará la versión de arduino 1.6.0

Por defecto, en la lista de boards no van a aparecer los Attiny's
Para que aparezcan hay que copiar la carpeta que está en este link (o disponible en Drive también, dentro de _ARDUINO/_BACKUP ARDUINO 1.6.0/hardware, carpeta attiny)
a la ubicación Arduino\hardware

https://github.com/damellis/attiny/archive/ide-1.6.x.zip

Luego de reiniciar el IDE, aparece un menú dentro de "Board" llamado Attiny
Elegirlo, y luego seleccionar 8Mhz en el menú Clock, luego Attiny85 en el menú Processor.
En el menú Programmer, elegir "Arduino as ISP" (el programador por defecto es AVRISP mkII)

3. Configuración del reloj del Attny85 a 8Mhz

Por defecto, los Attiny85 vienen configurados a 1Mhz.
Para pasarlos a 8Mhz:

Configuring the ATtiny to run at 8 MHz (for SoftwareSerial support)

By default, the ATtiny’s run at 1 MHz. To use the SoftwareSerial library, you need to do an extra step and configure the microcontroller to run at 8 MHz. Once you have the microcontroller connected, select “8 MHz (Internal)” from the Tools > Clock menu. (In Arduino 1.0.x, select the appropriate 8 MHz clock option from the main Tools > Board menu.) Warning: make sure you select “internal” not “external” or your microcontroller will stop working (until you connect an external clock to it). Then, run the “Burn Bootloader” command from the Tools menu. This configures the fuse bits of the microcontroller so it runs at 8 MHz. Note that the fuse bits keep their value until you explicitly change them, so you’ll only need to do this step once for each microcontroller. (Note this doesn’t actually burn a bootloader onto the board; you’ll still need to upload new programs using an external programmer.)
ATENCION!!! EL BURN BOOTLOADER SE DEBE HACER ELIGIENDO EL ATtiny85 (internal 8mhz...) y no el que dice ATtiny85 @ 8Mhz

Configuración de password de ADSL en ThinkVantage

1. Locations / Manage Profiles...
2. Elegir el perfil y luego Edit...
3. Wireless Settings
4. En Wireless security type elegir: Use Wi-Fi Protected Access - Pre Shared Key(WPA-PSK)
5. Dentro de properties... en Access point authentication elegir WPA2-PSK, en Data encryption: AES
6. Ingresar la password  en la caja de texto de mas abajo.

Leer archivos XML con JQuery

Este es un ejemplo que no utiliza la funcion parseXML. Esta función sólo está disponible en jQuery mayor a 1.5 Igual se puede adaptar, cambiando la linea: por Un ejemplo que funciona: Attributes.xml

L293D Motor Drive Shield Expansion Board for Arduino

Este shield es compatible con el: Adafruit Motor Shield

Referencia:

http://learn.adafruit.com/downloads/pdf/afmotor-library-reference.pdf

Para utilizar un servo, conectarlo y luego usar el ejemplo que viene con AFMotor.
IMPORTANTE: alimentar con 9v el arduino para que los servos funcionen!!







Código:


// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#include <AFMotor.h>

// Stepper motor on M1+M2 48 steps per revolution
AF_Stepper stepper(200, 1);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
}

int i;

void loop() {
  for (i=0; i<255; i++) {
    stepper.step(1, FORWARD, INTERLEAVE);
    delay(3);
 }

  for (i=255; i!=0; i--) {
    stepper.step(1, BACKWARD, INTERLEAVE);
    delay(3);
 }

  for (i=0; i<255; i++) {
    delay(3);
    stepper.step(1, FORWARD, DOUBLE);
 }

  for (i=255; i!=0; i--) {
    stepper.step(1, BACKWARD, DOUBLE);
    delay(3);
 }
}




Driver para stepper motors Keyes L298N

Fuente:


Para motores DC

http://www.instructables.com/id/Arduino-Modules-L298N-Dual-H-Bridge-Motor-Controll/?ALLSTEPS

Voltaje en VMS: Hasta 35V



Para Steppers


Conexiones:

ENA  connected to Arduino's digital pin 2
IN1    connected to Arduino's digital pin 3
IN2    connected to Arduino's digital pin 4
ENB   connected to Arduino's digital pin 5
IN3    connected to Arduino's digital pin 6
IN4    connected to Arduino's digital pin 7

Fuente externa:

VMS  +5v
GND  Ground

Código 1: Sin Stepper library:

int ENA=2;//connected to Arduino's port 2
int IN1=3;//connected to Arduino's port 3
int IN2=4;//connected to Arduino's port 4
int ENB=5;//connected to Arduino's port 5
int IN3=6;//connected to Arduino's port 6
int IN4=7;//connected to Arduino's port 7

void setup()
{
 pinMode(ENA,OUTPUT);
 pinMode(ENB,OUTPUT);
 pinMode(IN1,OUTPUT);
 pinMode(IN2,OUTPUT);
 pinMode(IN3,OUTPUT);
 pinMode(IN4,OUTPUT);
 digitalWrite(ENA,HIGH);//enablae motorA
 digitalWrite(ENB,HIGH);//enable motorB
}
void loop()
{
 int d = 1;

 digitalWrite(IN1,LOW);
 digitalWrite(IN2,HIGH);
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);
 delay(d);
 digitalWrite(IN1,LOW);
 digitalWrite(IN2,HIGH);
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);
 delay(d);
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,HIGH);
 delay(d);
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,LOW);
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,LOW);
 delay(d);    
}


Para entender la secuencia:




Código 2: Con Stepper library:

#include <Stepper.h>
const int stepsPerRevolution = 200;  

Stepper myStepper(stepsPerRevolution, 3,4,6,7);            
void setup() {
   myStepper.setSpeed(150);
   int ENA=2;//connected to Arduino's port 2
   int ENB=5;//connected to Arduino's port 5  
   
   digitalWrite(ENA,HIGH);//enablae motorA
   digitalWrite(ENB,HIGH);//enable motorB 
}
void loop() {
  //horario
  myStepper.step(stepsPerRevolution);
  delay(500);
  
  // antihorario  
  myStepper.step(-stepsPerRevolution);
  delay(500); 
}





Conexiones:



Tonight - Elton John

http://www.youtube.com/watch?v=nfBY_xFwU50

Fuente: eltonchords.com


TONIGHT

Year:  1976
Album:  BLUE MOVES
Writers:  Elton John\ Bernie Taupin

(Dm  Bb  Gm7 Bb\F)*  A7 A7 A7 A7

(Dm  Bb  Gm7 Bb\F)*  Gmdim7\A  Bbmdim7\A  Emdim7\A  Gmdim7\A


(Cm  Cm  Db Eb Fm

Cm  Cm  Cm  Cm)**

Eb\G Fm\Ab Eb\Bb  Fm\C Eb Fm  Gm Ab Bb  Cm Db Eb Dm

(Dm  Bb  Gm7 Bb\F)*  A7 A7 A7 A7


(Dm  Bb  Gm7 Bb\F)*  Gmdim7\A  Bbmdim7\A  Emdim7\A  Gmdim7\A


(Cm  Cm  Db Eb Fm

Cm  Cm  Cm  Cm)**


Eb\G Fm\Ab Eb\Bb  Fm\C Eb Fm  Gm Ab Bb  Cm Db Eb E


Dm  Dbm  Cm  Bm  Bb  Bb  Am  Abm  G  G7

Ab  Ab Bb  Cm  Cm  G\C  G\C  Cm

Ab  Cm\G G

  Cm
Tonight

Cm       Bb
Do we have to fight again

  Ab
Tonight

Ab     Ab      Ab\G  F
I just want to go to sleep

Bb   Cm  Bb\D Eb
Turn out the  light

Eb      Eb\F    Eb\G  Ab
But you want to carry grudges

Ab    Ab\G   F
Nine times out of ten

    Bb
I see the storm approaching

Bb       Ab      Cm\G G
Long before the rain starts falling


  Cm
Tonight

Cm         Bb
Does it have to be the old thing

  Ab
Tonight

Ab       Ab Ab\G    F
It's late,  too late

F      Cm      Bb\D        Eb 
To chase the rainbow that you're after

    Eb     Eb\F   Eb\G  Ab
I'd like to find a compromise

    Ab      Ab\G    F
And place it in your hands

F     Bb
My eyes are blind, my ears can't hear

Bb        Ab   Cm\G G
And I cannot find the time


  Cm    G\C  Cm
Tonight

     Cm          Dm
Just let the curtains close in silence

  Gm7
Tonight

        Cm    Cm\Bb F\A
Why not approach with less defiance

    F\A         G\B
The man who'd love to see you smile

      G\B
Who'd love to see you smile

  Cm    G\C  Cm  Bb  Eb\Bb Bb  
Tonight

Ab  Ab Ab Ab\G F  

Bb  Ab  Cm\G  G


  Cm    G\C  Cm
Tonight

     Cm          Dm
Just let the curtains close in silence

  Gm7
Tonight

        Cm    Cm\Bb F\A
Why not approach with less defiance

    F\A         G\B
The man who'd love to see you smile

         Ab    
The man who'd love to see you smile

G         Ab
The man who'd love to see you smile

Bb Eb
To-night


(Dm  Bb  Gm7 Bb\F)*  A7 A7 A7 A7

(Dm  Bb  Gm7 Bb\F)*  Gmdim7\A  Bbmdim7\A  Emdim7\A  Gmdim7\A

(Dm)***



*The chording is like this in actuality:

RH: Dm  Dm C  Dm  C  Dm  Bb  
LH: D             

Bb  Bb F  Bb  F  Bb  F  
Bb

Gm7  Bb Dm  Bb  Dm  C  F  
Gm     F


**These are the single notes for the right hand:

RH: c d eb  d  c c d eb eb d  c d eb  d  Db Eb Fm
LH: C        C          Db Eb F

c d eb d c d eb d c d eb
C     C        C      


***These are the notes played in the right hand, sixteenth notes, with a D in the bass:

d f a f a d a d f d f a f a d a d f d f a f a d a d f 

ritard.
f c# d g# a e f c# d g# a e f g g# c# Dm(arp) (D bass octave)

JSONP en servidor Arduino - CrossDomain

Uso: Un sitio web alojado en el dominio X quiere obtener datos de un Arduino con Ethernet Shield alojado en el dominio Y.
JSONP es la forma de implementar llamados AJAX Cross Domain:

Referencias:
      http://api.jquery.com/jQuery.ajax/
      http://json-p.org/
      http://www.funcion13.com/2012/04/12/como-realizar-peticiones-ajax-cross-domain-jsonp-jquery/

Test.php:


<html>

<head>
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="js/funciones.js"></script>
</head>

<body>

<input id="detectar" type="button" value="Detectar...">

</body>

<script>
$(document).ready(function() {

$("#detectar").click(function() {
invocarAjax();
});
});

</script>

</html>

funciones.js


function arduinoEthernetComCallback(data)
{
alert("data es!!: " + data);


var j = eval('(' + data + ')');

alert(j["A5"]);

}

function invocarAjax()
{
rnd = '&random=' + Math.floor(Math.random()*9999999999);

$.ajax({
 url : 'http://192.168.0.200:93?rnd='+rnd,
 dataType : 'jsonp',
 crossDomain : true
});
}

Sketch:

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,200);
char callback[27] = "arduinoEthernetComCallback";
EthernetServer server(93);
void setup()
{
  Ethernet.begin(mac, ip);
  server.begin();
}
void loop()
{
  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 (c == '\n' && currentLineIsBlank) {
          
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: application/json");
          client.println("Connection: close");     
          client.println();

          client.print(callback);
          client.print("('{");
          for (int i=0; i<6; i++) {
            client.print("\"A");
            client.print(i);
            client.print("\": ");
            client.print(i*10);
            if (i != 5) {
              client.print(",");
            }
          }
          
          client.println("}')");
          break;
        }
        if (c == '\n') {
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }

    delay(1);

    client.stop();
  }


Modulos RF 433 con arduino

http://www.pjrc.com/teensy/td_libs_VirtualWire.html

Compra en ebay:
10Pcs 433Mhz RF transmitter and receiver link kit for Arduino/ARM/MCU WL

(Ver especificaciones técnicas al final de este post)

MAC ADDRESS: Ver este link para generarla aleatoriamente:
https://nicegear.co.nz/blog/autogenerated-random-persistent-mac-address-for-arduino-ethernet/

Atencion!!! para mejorar NOTORIAMENTE la señal, agregar una antena en el emisor, un cable multihilo de 20cm de largo.
Para que virtualwire funcione en la version 1.0.1 de Arduiono IDE:

en VirtualWire.h

sustituir:

#include <stdlib.h>
#include <wiring.h>

por esto:

#include <stdlib.h>
#if ARDUINO >= 100
  #include <Arduino.h>
#else
  #include <wiring.h>
#endif

-----------------------------------------------------

En virtualwire.cpp

reemplazar

#include "WProgram.h"
por
#include "Arduino.h"

----------------------------------------------------

Ejemplo de emisor y receptor que funcionan:

Modelo de RF utilizado:

10Pcs 433Mhz RF transmitter and receiver link kit for Arduino/ARM/MCU WL


Cableado:

Se precisan 2 arduinos, uno para el emisor y otro para el receptor.

Emisor (el que tiene tres pines)
      GND -> tierra de arduino
      VCC -> 3V3 de arduino (o 5v)    [Investigar porque a mayor voltaje mayor es la intensidad, hasta 12v]
      ATAD -> digital pin 12 de arduino

Receptor (el que tiene 4 pines)
     GND -> tierra de arduino
     VCC -> 5v de arduino
     Datos (pin que esta al lado de GND) -> digital pin 11 de arduino

Sketch:

(Para probarlo, abrir la consola del arduino receptor)

//---------- TRANSMISOR ------------


#include <VirtualWire.h>

const int led_pin = 11;
const int transmit_pin = 12;
const int receive_pin = 2;
const int transmit_en_pin = 3;

void setup()
{
  // Initialise the IO and ISR
  vw_set_tx_pin(transmit_pin);
  vw_set_rx_pin(receive_pin);
  vw_set_ptt_pin(transmit_en_pin);
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000); // Bits per sec
}

byte count = 1;

void loop()
{
  //char msg[7] = {'h','e','l','l','o',' ','#'};
  char msg[7] = {'h','e','l','l','o'};

  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}




-----------------------------------------------------------------------------------------------

//---------- RECEPTOR ------------
//---------- para tener un feedback visual, poner un led en el pin 2 con una resistencia de 10k
//---------- cada vez que se recibe la palabra "hello", se enciende y apaga el led.


//------- RECEPTOR ---------

#include <VirtualWire.h>

const int led_pin = 6;
const int transmit_pin = 12;
const int receive_pin = 11;
const int transmit_en_pin = 3;

String str = "";
 
void setup()
{  
    delay(1000);
    Serial.begin(9600); // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000); // Bits per sec

    vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
int i;

        digitalWrite(led_pin, HIGH); // Flash a light to show received good message
// Message with a good checksum received, print it.
Serial.print("Got: ");

        str = "";
for (i = 0; i < buflen; i++)
{
   Serial.print(buf[i], HEX);
            str += char(buf[i]);
            Serial.print(" ");
}

        Serial.println("");
        Serial.println("Texto recibido: " + str);


        Serial.println("Texto recibido: " + str);

        if (str.indexOf("hello") >= 0)
        {
            digitalWrite(2, HIGH);
            delay(1000);
            digitalWrite(2, LOW);
            delay(1000);
        }


        digitalWrite(led_pin, LOW);
    }
}


-----------------------------------------------------------------------------------------

Especificaciones técnicas


TX Technical Specifications:
A. Working voltage: 3V~12V
B. Working current: max≤40mA (12V), min≤9mA(3V)
C. Resonance mode: sound wave resonance (SAW)
D. Modulation mode: ASK /OOK
E. Working frequency: 315MHz-433.92MHz, customized frequency is available.
F. Transmission power: 25mW (315MHz at 12V)
G. Frequency error: +150kHz (max)
H. Velocity: ≤10Kbps
I. Self-owned codes: negative

RX Technical Specifications:
A. Working voltage: 5.0VDC +0.5V
B. Working current:≤5.5mA (5.0VDC)
C. Working principle: single chip superregeneration receiving
D. Working method: OOK/ASK
E. Working frequency: 315MHz-433.92MHz, customized frequency is available.
F. Bandwidth: 2MHz (315MHz, having result from testing at lowing the sensitivity 3dBm)
G. Sensitivity: excel –100dBm (50Ω)
H. Transmitting velocity: <9.6Kbps (at 315MHz and -95dBm)

Ethernet Shield

Listado de proveedores DDNS:

http://dnslookup.me/dynamic-dns/



Pasos para hacer funcionar el ethernet shield accediendo desde internet:

Hardware:
        Arduino UNO
        Ethernet shield con chip W5100

Pasos:

1. Conectar el ethernet shield al arduino

2. Conectar el cable de red y el usb del arduino al pc

3. Para saber la ip que se le asigno al ethernet shield, abrir el sketch Archivo / Ejemplos / Ethernet / DhcpAddressPrinter

4. Cargarlo al arduino y luego abrir el monitor serial. Va a aparecer algo así:

                   My IP address: 192.168.0.101

Esta dir es la que le dio el DHCP, pero luego en el sketch se puede indicar una IP fija.


5. Cargar este sketch (prueba básica):


#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[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(192,168,0,200); //<<< Esta es la dir fija que le quiero dar al arduino!!!

// 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) {
    client.println("prueba");
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}


6. Para poder acceder fuera de la LAN (desde internet):

      a. Entrar en el router, ir a Forwarding
      b. Agregar uno nuevo de esta forma:

Ojo!!! para que luego se pueda configurar el www.no-ip.com, elegir una ip que esté fuera del rango de DHCP
Para saber cual elegir, entrar a la opción DHCP y fijarse el ultimo numero:

En este caso, podría utilizar la 192.168.0.200, porque la 192.168.0.199 es la máxima dir. que puede asignar el DHCP.

      c. Averiguar la ip pública que tiene el router, ir a http://www.whatismyip.com/

      d. En un pc cualquiera, poner http://la-direccion-publica-del-router

[EL QUE TIENE LA IP PUBLICA ES EL ROUTER, LUEGO HAY QUE REDIRECCIONAR CON EL PORT FORWARDING EL TRAFICO HACIA LOS DISPOSITIVOS - PC - ETHERNET SHIELD, ETC, ETC]

DynDNS

Dado que las ip's son dinámicas y se renuevan, se pueden hacer dos cosas
1. Se configura el servicio de DynDNS en el router.
2. Se agrega código al arduino para que haga lo mismo que hace el router (ver si la ip cambió y si lo hizo, enviar el cambio)

1. Para hacerlo mediante el router:


2. Para hacerlo desde arduino:

Utilizar este código (para proveedor no-ip.com):

NOTA: En este caso se puso: 
                             GET /nic/update?hostname=crusso.no-ip.org HTTP/1.0
Si se pone: 
                             GET /nic/update?hostname=crusso.no-ip.org&myip=176.32.98.166 HTTP/1.0
Se puede redirigir a una página específica. Si no se pone el parámetro myip, se asignará la ip actual del dispositivo (la que se puede ver en whatismyip.com).


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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //mac address
byte ip[] = { 192,168,0,200 }; //dirección ip del arduino
byte server[] = {8,23,224,120}; //dynupdate.no-ip.com

EthernetClient client;

void setup() {
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("Conectando...");

  if (client.connect(server, 80)) {
    Serial.println("Conexión establecida");

    client.println("GET /nic/update?hostname=crusso.no-ip.org HTTP/1.0");
    client.println("Host: dynupdate.no-ip.com");
    client.println("Authorization: Basic Y2FybG9zLnJ1c3NvQGdtYWlsLmNvbTphYmMxMjM=");   //es el mail:password de no-ip, codificado en base64
                                                                                       //para codificarlo: http://www.ludegljive.com/functions/Encode-string-to-base64.aspx

    client.println("User-Agent: arduino_ethernet/1.0 carlos.russo@gmail.com");

    client.println();
  }
  else
  {
      Serial.println("Error, no se puede conectar");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("Desconectado");
    client.stop();

    for(;;)
      ;
  }
}


Utilizar este código (para proveedor dnsdynamic.org):


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

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  //mac address
byte ip[] = { 192,168,0,200 }; //dirección ip del arduino
byte server[] = {84,45,76,100}; //dnsdynamic.org

EthernetClient client;

void setup() {
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("Conectando...");

  if (client.connect(server, 80)) {
    Serial.println("Conexión establecida");
    //client.println("GET /api/?hostname=crusso.fe100.net&myip=176.32.98.166 HTTP/1.0");
    client.println("GET /api/?hostname=crusso.fe100.net HTTP/1.0");
   
    client.println("Host: dnsdynamic.org");
    client.println("Authorization: Basic Y2FybG9zLnJ1c3NvQGdtYWlsLmNvbTphYmMxMjM=");   //es el mail:password de no-ip, codificado en base64
                                                                                       //para codificarlo: http://www.ludegljive.com/functions/Encode-string-to-base64.aspx

    client.println("User-Agent: arduino_ethernet/1.0 info@gmail.com");

    client.println();
  }
  else
  {
      Serial.println("Error, no se puede conectar");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("Desconectado");
    client.stop();

    for(;;)
      ;
  }
}

Luego, el resultado es este:







Fuente: http://www.instructables.com/id/Arduino-Ethernet-Shield-Tutorial/



360 Servo con Arduino

Conexiones:

Servo 360
    -Negro: a GND de pilas y GND de arduino
    -Rojo: a +6V de pilas (tienen que ser 6v y tiene que ser una alimentacion externa, no la de arduino)
    -Blanco: a digital 2 de arduino

Sketch:

Tener en cuenta que:
    myservo.write(90);    detiene el servo
    myservo.write([valor menor a 90]);    lo hace girar en sentido antihorario
    myservo.write([valor mayor a 90]);    lo hace girar en sentido horario

Cuanto mas grande es el valor, mayor es la velocidad (por ej, un valor de 180 hace girar el servo en sentido horario lo mas rapido posible, 91 lo hace girar en sentido horario lo mas lento posible)


#include <Servo.h>

Servo myservo;

void setup()
{
  myservo.attach(2);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  //notar que en cada velocidad va a estar 5 segundos girando, no es necesario hacer loops!
  myservo.write(110); 
  delay(5000); 
  myservo.write(180); 
  delay(5000);
  myservo.write(90); 
  delay(5000);
}

Acelerometro arduino

Link ebay:

http://www.ebay.com/itm/Triple-Axis-Accelerometer-ADXL335-for-Arduino-/230743987457?pt=LH_DefaultDomain_0&hash=item35b969d501

Fuente: https://www.sparkfun.com/tutorials/240


Arduino PinADXL345 Pin
10CS
11SDA
12SDO
13SCL
3V3VCC
Gnd
GND



No se pueden agregar filas a un DataGridView bound a una lista

Para que aparezca el asterisco y la fila vacía en el DataGridView bindeado con una List, es necesario que los objetos que componen la lista tengan su constructor por defecto definido. Ejemplo: y luego Para que aparezca la nueva fila, es necesario que exista el constructor