Documental sobre Arduino:
http://vimeo.com/18390711
Tonight - Elton John
http://www.youtube.com/watch?v=nfBY_xFwU50
Fuente: eltonchords.com
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
});
}
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)
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(;;)
;
}
}
Fuente: http://www.instructables.com/id/Arduino-Ethernet-Shield-Tutorial/
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:
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(;;)
;
}
}
#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);
}
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
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 Pin | ADXL345 Pin |
| 10 | CS |
| 11 | SDA |
| 12 | SDO |
| 13 | SCL |
| 3V3 | VCC |
| 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
Arduino y processing
ARDUINO Y PROCESSING
1. Instalar version 1.5.1 de Processing (LA MAS NUEVA NO FUNCIONA)
2. Con Arduino IDE, subir StandardFirmdata al arduino
3. Poner este codigo en processing:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
boolean led = false;
void setup() {
size(200, 200);
println("COM Ports");
println(Arduino.list());
println("=========");
arduino = new Arduino(this, Arduino.list()[1], 57600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
arduino.pinMode(2, Arduino.INPUT);
arduino.digitalWrite(ledPin, Arduino.HIGH);
}
void draw() {
if (arduino.digitalRead(2) == Arduino.HIGH)
println("HIGH!!");
else
println("LOW!!");
}
void mousePressed()
{
if (led)
arduino.digitalWrite(ledPin, Arduino.HIGH);
else
arduino.digitalWrite(ledPin, Arduino.LOW);
led = !led;
}
----------------------------------------------------------------------------
http://www.youtube.com/watch?v=8OHs1VqIzVU
Libreria para C# y standard firmdata
http://www.acraigie.com/programming/firmatavb/default.html
http://code.google.com/p/sharpduino/
Leer archivo de texto con processing:
http://forum.processing.org/topic/import-and-read-files
http://txapuzas.blogspot.com/2009/12/txapu-cnc-hardware.html
GCODE SENDER TO ARDUINO
http://www.contraptor.org/forum/t-287260/gcode-sender-program
1. Instalar version 1.5.1 de Processing (LA MAS NUEVA NO FUNCIONA)
2. Con Arduino IDE, subir StandardFirmdata al arduino
3. Poner este codigo en processing:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
boolean led = false;
void setup() {
size(200, 200);
println("COM Ports");
println(Arduino.list());
println("=========");
arduino = new Arduino(this, Arduino.list()[1], 57600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
arduino.pinMode(2, Arduino.INPUT);
arduino.digitalWrite(ledPin, Arduino.HIGH);
}
void draw() {
if (arduino.digitalRead(2) == Arduino.HIGH)
println("HIGH!!");
else
println("LOW!!");
}
void mousePressed()
{
if (led)
arduino.digitalWrite(ledPin, Arduino.HIGH);
else
arduino.digitalWrite(ledPin, Arduino.LOW);
led = !led;
}
----------------------------------------------------------------------------
http://www.youtube.com/watch?v=8OHs1VqIzVU
Libreria para C# y standard firmdata
http://www.acraigie.com/programming/firmatavb/default.html
http://code.google.com/p/sharpduino/
Leer archivo de texto con processing:
http://forum.processing.org/topic/import-and-read-files
http://txapuzas.blogspot.com/2009/12/txapu-cnc-hardware.html
GCODE SENDER TO ARDUINO
http://www.contraptor.org/forum/t-287260/gcode-sender-program
Smooth scrolling text en c#
1. Create a C# windows form application
2. In the Solution Explorer window, right click the project node and click Add->New Item button.
3. Select the Component Class template, rename it to MarqueeLabel.cs and click Add button
4. Replace the MarqueeLabel implementation with Fernando's codes
5. Delete the default MarqueeLabel.designer.cs file
6. Build you solution
7. In your Form designer, you will find the MarqueeLabel component in the tool box window.
8. Drag it onto your form, it will work correctly.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DeteccionPuertos
{
class MarqueeLabel : Label
{
private int CurrentPosition { get; set; }
private Timer Timer { get; set; }
public MarqueeLabel()
{
UseCompatibleTextRendering = true;
Timer = new Timer();
Timer.Interval = 25;
Timer.Tick += new EventHandler(Timer_Tick);
//Timer.Start();
}
public void Start()
{
Timer.Start();
}
public void Stop()
{
Timer.Stop();
}
void Timer_Tick(object sender, EventArgs e)
{
if (CurrentPosition > Width)
CurrentPosition = -Width;
else
CurrentPosition += 2;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.TranslateTransform((float)CurrentPosition, 0);
base.OnPaint(e);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (Timer != null)
Timer.Dispose();
}
Timer = null;
}
}
}
2. In the Solution Explorer window, right click the project node and click Add->New Item button.
3. Select the Component Class template, rename it to MarqueeLabel.cs and click Add button
4. Replace the MarqueeLabel implementation with Fernando's codes
5. Delete the default MarqueeLabel.designer.cs file
6. Build you solution
7. In your Form designer, you will find the MarqueeLabel component in the tool box window.
8. Drag it onto your form, it will work correctly.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DeteccionPuertos
{
class MarqueeLabel : Label
{
private int CurrentPosition { get; set; }
private Timer Timer { get; set; }
public MarqueeLabel()
{
UseCompatibleTextRendering = true;
Timer = new Timer();
Timer.Interval = 25;
Timer.Tick += new EventHandler(Timer_Tick);
//Timer.Start();
}
public void Start()
{
Timer.Start();
}
public void Stop()
{
Timer.Stop();
}
void Timer_Tick(object sender, EventArgs e)
{
if (CurrentPosition > Width)
CurrentPosition = -Width;
else
CurrentPosition += 2;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.TranslateTransform((float)CurrentPosition, 0);
base.OnPaint(e);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (Timer != null)
Timer.Dispose();
}
Timer = null;
}
}
}
jQuery AJAX desde PHP con jsonwrapper
Codigo del webservice:
prueba1.php
<?php
$receive=file_get_contents('php://input');
$p = json_decode($receive);
$pp[0]["prueba0"] = $p["parametro1"];
$pp[0]["prueba1"] = "abc";
$pp[0]["ss"] = "zzz";
$p = json_encode($pp);
echo $p;
?>
Codigo JS:
function invocarAjax(url_ws, param_ws, funcion_ws, async_ws)
{
if(async_ws===undefined)
async_ws = false;
jQuery.ajax({
type: "POST",
timeout: 5000,
url: url_ws + "?" + "random=" + Math.floor(Math.random()*9999999999),
data: param_ws,
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
async: async_ws,
success: function(response) {
window[funcion_ws](response, null);
},
error: function(xhr, ajaxOptions, thrownError) {
window[funcion_ws](null, xhr.responseText );
}
});
}
function getJSON(data_obj)
{
if (data_obj.d)
data_ok = data_obj.d;
else
data_ok = data_obj;
evalJson = eval("var varJSON = " + data_ok + ";");
return varJSON;
}
Código que invoca al webservice:
<script>
$(document).ready(function() {
$("#setear").click(function() {
url_ws = "prueba1.php";
param_ws = '{"parametro1": "5555", "enviar_todos": "S"}';
invocarAjax(url_ws, param_ws, "callbackConfigEmails", true);
});
});
function callbackConfigEmails(v, err)
{
if (err == null)
{
if (v[0].prueba1 != "")
{
alert("prueba0: " + v[0].prueba0);
alert("prueba1: " + v[0].prueba1);
}
} else
alert("ERROR: " + err);
}
</script>
OJO!!!!!
El codigo json_decode de jsonwrapper NO funciona, en su lugar, utilizar este:
function json_decode($json)
{
$comment = false;
$out = '$x=';
for ($i=0; $i<strlen($json); $i++)
{
if (!$comment)
{
if (($json[$i] == '{') || ($json[$i] == '['))
$out .= ' array(';
else if (($json[$i] == '}') || ($json[$i] == ']'))
$out .= ')';
else if ($json[$i] == ':')
$out .= '=>';
else
$out .= $json[$i];
} else
$out .= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\")
$comment = !$comment;
}
eval($out . ';');
return $x;
}
prueba1.php
<?php
$receive=file_get_contents('php://input');
$p = json_decode($receive);
$pp[0]["prueba0"] = $p["parametro1"];
$pp[0]["prueba1"] = "abc";
$pp[0]["ss"] = "zzz";
$p = json_encode($pp);
echo $p;
?>
Codigo JS:
function invocarAjax(url_ws, param_ws, funcion_ws, async_ws)
{
if(async_ws===undefined)
async_ws = false;
jQuery.ajax({
type: "POST",
timeout: 5000,
url: url_ws + "?" + "random=" + Math.floor(Math.random()*9999999999),
data: param_ws,
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
async: async_ws,
success: function(response) {
window[funcion_ws](response, null);
},
error: function(xhr, ajaxOptions, thrownError) {
window[funcion_ws](null, xhr.responseText );
}
});
}
function getJSON(data_obj)
{
if (data_obj.d)
data_ok = data_obj.d;
else
data_ok = data_obj;
evalJson = eval("var varJSON = " + data_ok + ";");
return varJSON;
}
Código que invoca al webservice:
<script>
$(document).ready(function() {
$("#setear").click(function() {
url_ws = "prueba1.php";
param_ws = '{"parametro1": "5555", "enviar_todos": "S"}';
invocarAjax(url_ws, param_ws, "callbackConfigEmails", true);
});
});
function callbackConfigEmails(v, err)
{
if (err == null)
{
if (v[0].prueba1 != "")
{
alert("prueba0: " + v[0].prueba0);
alert("prueba1: " + v[0].prueba1);
}
} else
alert("ERROR: " + err);
}
</script>
OJO!!!!!
El codigo json_decode de jsonwrapper NO funciona, en su lugar, utilizar este:
function json_decode($json)
{
$comment = false;
$out = '$x=';
for ($i=0; $i<strlen($json); $i++)
{
if (!$comment)
{
if (($json[$i] == '{') || ($json[$i] == '['))
$out .= ' array(';
else if (($json[$i] == '}') || ($json[$i] == ']'))
$out .= ')';
else if ($json[$i] == ':')
$out .= '=>';
else
$out .= $json[$i];
} else
$out .= $json[$i];
if ($json[$i] == '"' && $json[($i-1)]!="\\")
$comment = !$comment;
}
eval($out . ';');
return $x;
}
Configuración de EZdrummer
ABRIR LIVE COMO ADMINISTRADOR! SINO EL EZDRUMMER DA ERROR DICIENDO QUE NO ENCUENTRA LOS ARCHIVOS DE SONIDO.
ATENCION!!!!! Si no sale el sonido utilizando los drivers ASIO, conectar auriculares!!! no sale por los parlantes, sale por los auriculares!!!!
(Otra opcion es ir a las propiedades del dispositivo de salida, y en la ficha Avanzadas, desmarcar "Allow applications to take exclusive control of this device")
1. Instalar EZDrummer
2. Instalar ASIO4ALL y configurarlo:
3. Instalar Ableton Live y configurarlo:
ATENCION!!!!! Si no sale el sonido utilizando los drivers ASIO, conectar auriculares!!! no sale por los parlantes, sale por los auriculares!!!!
(Otra opcion es ir a las propiedades del dispositivo de salida, y en la ficha Avanzadas, desmarcar "Allow applications to take exclusive control of this device")
1. Instalar EZDrummer
2. Instalar ASIO4ALL y configurarlo:
3. Instalar Ableton Live y configurarlo:
5. Agregar plugin de EZDrummer en Ableton:
Para que aparezca en la lista de plugins, es necesario poner en On la opcion marcada a continuación:
6. Solucionar el problema de la latencia (configurar sonido en windows):
7. Aumentar el volumen:
8. Si se cierra la pantalla del EZDrummer, se abre de nuevo así:
Suscribirse a:
Entradas (Atom)
















