[#VS2012] HowTo: Find the connected internet IP Address


image

Buenas,

After a couple of minutes searching the internet a Code Snippet that allows me to find out the IP address with which I am connected to the internet, I realized that I don’t actually have to search from my computer to the outside, but from the outside inwards (quiet that I have not yet made anything).

There are many places that when you connect, tell you the IP address with which these emerging Internet, and some are as simple as http://icanhazip.com/ . This site only gives you your IP address, so we can process your output with the following code:

   1: public static string GetInternetIpAddress()
   2: {
   3:     var client = new WebClient();
   4:     var ip = client.DownloadString("http://icanhazip.com/");
   5:     return ip;
   6: }

Simplest impossible!

Disclaimer: there are other ways it, however if these under many levels and layers of IPs addresses, this option is the fastest ;)

 

Saludos @ La Finca

El Bruno

image image image

[#NETMF] HowTo: Create a motion sensor (II)


image

Buenas

in the yesterday’s post I commented on an accessory to detect movements using. Net Gadgeteer . Today we will see how with a couple of lines of code more, we can activate the camera when motion is detected, you take a picture and show it in the graphic display.

For this example we will use

With the following diagram

image

And then in the code to see that

  • When motion is detected tells the camera to take a photo (line 21)
  • When the camera takes a photo, it is shown in the graphic display
   1: using System;

   2: using GT = Gadgeteer;

   3:  

   4: namespace GadgeteerApp15

   5: {

   6:     public partial class Program

   7:     {

   8:         void ProgramStarted()

   9:         {

  10:             motion_Sensor.Motion_Sensed += MotionSensorMotionSensed;

  11:             camera.PictureCaptured += CameraPictureCaptured;

  12:         }

  13:  

  14:         void CameraPictureCaptured(GT.Modules.GHIElectronics.Camera sender, GT.Picture picture)

  15:         {

  16:             display_T35.SimpleGraphics.DisplayImage(picture, 5, 5);

  17:         }

  18:  

  19:         void MotionSensorMotionSensed(GT.Modules.GHIElectronics.Motion_Sensor sender, GT.Modules.GHIElectronics.Motion_Sensor.Motion_SensorState state)

  20:         {

  21:             camera.TakePicture();

  22:         }

  23:     }

  24: }

In the next posts to see how to send this information to a processor of movements, and even… well as mount with a model client / server.

Saludos @ Home

El Bruno

image image image

[#NETMF] HowTo: Crear un sensor de movimientos (II)


image

Buenas

en el post de ayer comenté sobre un accesorio para detectar movimientos utilizando .Net Gadgeteer. Hoy veremos como con un par de líneas de código más, podemos activar la cámara para que en el momento que se detecta movimiento, saque una foto y la muestre en el display gráfico.

Para este ejemplo utilizaremos

 

Con el siguiente diagrama

image

Y luego en el código veremos que

  • - cuando se detecta movimiento se indica a la cámara que saque una foto (línea 21)
  • - cuando la cámara saca una foto, la misma se muestra en el display gráfico
   1: using System;

   2: using GT = Gadgeteer;

   3:  

   4: namespace GadgeteerApp15

   5: {

   6:     public partial class Program

   7:     {

   8:         void ProgramStarted()

   9:         {

  10:             motion_Sensor.Motion_Sensed += MotionSensorMotionSensed;

  11:             camera.PictureCaptured += CameraPictureCaptured;

  12:         }

  13:  

  14:         void CameraPictureCaptured(GT.Modules.GHIElectronics.Camera sender, GT.Picture picture)

  15:         {

  16:             display_T35.SimpleGraphics.DisplayImage(picture, 5, 5);

  17:         }

  18:  

  19:         void MotionSensorMotionSensed(GT.Modules.GHIElectronics.Motion_Sensor sender, GT.Modules.GHIElectronics.Motion_Sensor.Motion_SensorState state)

  20:         {

  21:             camera.TakePicture();

  22:         }

  23:     }

  24: }

En los próximos posts veremos como enviar esta información a un procesador de movimientos, e inclusive … pues como montarlo con un modelo cliente / servidor.

Saludos @ Home

El Bruno

image image image

[#NETMF] HowTo: Create a movements sensor (I)


image

Buenas

today’s example does not attempt to replace a Kinect, or much less. However shows us that with a small hardware little more than €12, can create a sensor’s movements when it detects movements, begin to record the input from a camera.

On this basis, we started with the following hardware for example, where we will see the simple which can be create a Motion Detector

with these three elements, we connect the same guided by the following scheme

image

At this point, with the connected sensor we work with it is pretty simple.

Line 10 shows us that we have an event Motion_Sensed () that is activated when the sensor detects motion.

   1: using Gadgeteer.Modules.GHIElectronics;

   2: using Microsoft.SPOT;

   3:  

   4: namespace GadgeteerApp14

   5: {

   6:     public partial class Program

   7:     {

   8:         void ProgramStarted()

   9:         {

  10:             motion_Sensor.Motion_Sensed += MotionSensorMotionSensed;

  11:         }

  12:  

  13:         void MotionSensorMotionSensed(Motion_Sensor sender, Motion_Sensor.Motion_SensorState state)

  14:         {

  15:             Debug.Print("motion detected !");

  16:             // also check >> motion_Sensor.SensorStillActive

  17:         }

  18:     }

  19: }

Well, we can subscribe to this event or can change the focus and do a PULL of the status of the sensor. For this second case we check the Boolean value of the property SensorStillActive (line 15).

The sensor is quite small and has a range of about 7 meters according to official indications that we can readhere .

image

In the next post, add a camera and keep the contents of it on an SD card.

Saludos @ Home

El Bruno

image image image

[#NETMF] HowTo: Crear un sensor de movimientos (I)


image

Buenas

el ejemplo de hoy no intenta reemplazar a un Kinect, ni mucho menos. Sin embargo nos muestra que con un pequeño hardware de poco más de €12, podemos crear un sensor de movimientos que cuando detecte movimientos, comience a grabar el input de una cámara.

Sobre esta base comenzamos con el siguiente hardware para el ejemplo, donde veremos lo simple que puede ser crear un Motion Detector

con estos 3 elementos, conectamos los mismos guiados por el siguiente esquema

 

image

En este punto, con el sensor conectado vemos que el trabajo con el mismo es bastante simple.

La línea 10 nos muestra que tenemos un evento Motion_Sensed() que se activa cuando el sensor detecta movimiento.

   1: using Gadgeteer.Modules.GHIElectronics;

   2: using Microsoft.SPOT;

   3: namespace GadgeteerApp14

   4: {

   5:     public partial class Program

   6:     {

   7:         void ProgramStarted()

   8:         {

   9:             motion_Sensor.Motion_Sensed += MotionSensorMotionSensed;

  10:         }

  11:  

  12:         void MotionSensorMotionSensed(Motion_Sensor sender, Motion_Sensor.Motion_SensorState state)

  13:         {

  14:             Debug.Print("motion detected !");

  15:             // also check >> motion_Sensor.SensorStillActive

  16:         }

  17:     }

  18: }

Pues bien, podemos suscribirnos a este evento o podemos cambiar el enfoque y hacer un PULL del estado del sensor. Para este segundo caso debemos verificar el valor booleano de la propiedad SensorStillActive (línea 15).

El sensor es bastante pequeño y tiene un rango de unos 7 metros según las indicaciones oficiales que podemos leer aquí.

image

En el próximo post, le agregamos una cámara y guardamos el contenido de la misma en una tarjeta SD.

 

Saludos @ Home

El Bruno

image image image

[#NETMF] Installing .net Gadgeteer to work with Visual Studio 2012 (hard stuff!)


image

Buenas

after a couple of days at the beach with friends of Gusenet , let’s get updates to cholon in laptop.

Note:I not forget to thank all those who participated and coordinated the eventazo #YoNodeTuXaml. There was a lot of cracks and the truth that pass a great time. Tomorrow I will write a post about (to see if @jc_quijano happens to me some photo)

Today are going to what we, uninstall Visual Studio 2010 and step work with. Net Gadgeteer only with Visual Studio 2012 (that’s the idea I mentioned yesterday )).

Here is a chronicle of the steps I have followed, including the ostias and banging that I hit on the way to work.

1. Uninstall previous versions. But with care, do not uninstall the SDK (although it should do you lack if you don’t have HW, do me case)

image

2. Download and run .NET Gadgeteer Core 2.42.700 from https://gadgeteer.codeplex.com/releases/view/105366

image

3. 2 minutes later it is all OK

image

4. Now if I open Visual Studio 2012 and I can see new types of project for Gadgeteer

image

5. Go with a new project of type NETMF 4.2… Oyster

—————————
Microsoft Visual Studio
—————————
The project file ‘C:\Users\ < user > \AppData\Local\Temp\xnrmsqxj.xek\Temp\GadgeteerApp8.csproj’ cannot be opened.

There is a missing project subtype.
Subtype: ‘{b69e3092-b931-443c-abe7-7e7b65f2a37f}’ is unsupported by this installation.
—————————
OK Help
—————————

6. On the edge of the teeth, that pain! and I do not understand very well why. Good in reality if it has been the following:

A prerequisite for this version of. Net Gadgeteer for Visual Studio 2012 is .net Micro Framework 4.3. I have no plan to upgrade my hardware with what I thought that with NETMF 4.2 reached me, but no. I have download NETMF 4.3 SDK from http://netmf.codeplex.com/downloads/get/500745 and launch the installer.

image

7. Inside it see that it has any “previous” version of NETMF

image

8 So forward!

image

9 And now if I can already create new project

10 Escrivir a Hello World!

11 AND… It works :D

In the case of. Net Gadgeteer it is something like putting the following elements

With the following diagram

image

and the following code pair turn on and turn off the led on the button when you press the same

   1: using Gadgeteer.Modules.GHIElectronics;

   2:  

   3: namespace GadgeteerApp12

   4: {

   5:     public partial class Program

   6:     {

   7:         void ProgramStarted()

   8:         {

   9:             button.ButtonPressed += ButtonButtonPressed;

  10:         }

  11:  

  12:         void ButtonButtonPressed(Button sender, Button.ButtonState state)

  13:         {

  14:             button.ToggleLED();

  15:         }

  16:     }

  17: }

Saludos @ La Finca

El Bruno

image image image

[#NETMF] Instalando .Net Gadgeteer para Visual Studio 2012 (menudas ostias !!!)


image

Buenas,

después de un par de días en la playita con los amigos de Gusenet, vamos a meter las actualizaciones a cholón en el laptop.

Nota: No me olvido de agradecer a todos los que participaron y coordinaron el eventazo #YoNodeTuXaml. Hubo un montón de cracks y la verdad que pase un rato genial. Mañana escribiré un post al respecto (a ver si @jc_quijano me pasa alguna foto)

Hoy vamos a lo que vamos, desinstalo Visual Studio 2010 y paso a trabajar con .Net Gadgeteer solamente con Visual Studio 2012 (esa es la idea que comenté ayer).

 

Aquí dejo una crónica de los pasos que he seguido, incluidas las ostias y golpazos que me pegué en el camino para que funcione.

1. Desinstalar versiones anteriores. Aunque con cuidado, no desinstales el SDK (aunque no debería hacerte falta si no haces HW, hazme caso)

image

2. Descargar y ejecutar .NET Gadgeteer Core 2.42.700 desde https://gadgeteer.codeplex.com/releases/view/105366

image

3. 2 minutos después ya está todo OK

image

4. Ahora si, abro Visual Studio 2012 y puedo ver los nuevos tipos de proyecto para Gadgeteer

image

5. Vamos con un new project del tipo NETMF 4.2 y … ostion

    —————————
    Microsoft Visual Studio
    —————————
    The project file ‘C:\Users\<user>\AppData\Local\Temp\xnrmsqxj.xek\Temp\GadgeteerApp8.csproj’ cannot be opened.

    There is a missing project subtype.
    Subtype: ‘{b69e3092-b931-443c-abe7-7e7b65f2a37f}’ is unsupported by this installation.
    —————————
    OK   Help  
    —————————

6. En el canto de los dientes, que dolor! y no entiendo muy bien porqué. Bueno en realidad si, ha pasado lo siguiente:

Un prerequisito para esta versión de .Net Gadgeteer para Visual Studio 2012 es .Net Micro Framework 4.3. Yo no tengo pensado actualizar mi hardware con lo que pensé que con NETMF 4.2 me alcanzaba, pero no. Me toca descargar NETMF 4.3 SDK desde http://netmf.codeplex.com/downloads/get/500745 y lanzar el instalador.

image

7. Dentro del mismo veo que tiene todas las versiones “anteriores” de NETMF

image

8. Asi que para adelante!

image

9. Y ahora si ya puedo crear nuevo proyecto

10. Escrivir un Hola Mundo!

11. Y … Funciona :D

En el caso de .Net Gadgeteer es algo así como poner lo siguientes elementos

 

Con el siguiente diagrama

image

y el siguiente código par encender y apagar el led del button cuando se presiona el mismo

   1: using Gadgeteer.Modules.GHIElectronics;

   2:  

   3: namespace GadgeteerApp12

   4: {

   5:     public partial class Program

   6:     {

   7:         void ProgramStarted()

   8:         {

   9:             button.ButtonPressed += ButtonButtonPressed;

  10:         }

  11:  

  12:         void ButtonButtonPressed(Button sender, Button.ButtonState state)

  13:         {

  14:             button.ToggleLED();

  15:         }

  16:     }

  17: }

Saludos @ Home

El Bruno

image image image

[#NETMF] .net Gadgeteer, HowTo: display a chart in a display


image

Buenas

After 2 days in Paris where I could write little and learn a lot; Today we are going with a pure and simple code example

How to paint a chart in a display pixel to pixel with. Net Gadgeteer .

In this example we will use the following

Organized with the following schema:

image

I must emphasise the application code

  • line 19, at the press of the Button in addition to stop and start the timer, turn on and turn off the LED of the button
  • line 32, the routine that draws the chart is the most simple, increases a counter between 20 and 40 and then it decreases. There is also a second flag to control the vertical advance
   1: using GT = Gadgeteer;

   2:  

   3: namespace GadgeteerApp6

   4: {

   5:     public partial class Program

   6:     {

   7:         private uint _axisX = 20;

   8:         private uint _axisY = 20;

   9:         private GT.Timer _timer;

  10:         private bool _modeUp = true;

  11:  

  12:         void ProgramStarted()

  13:         {

  14:             button.ButtonPressed += ButtonButtonPressed;

  15:             _timer = new GT.Timer(200);

  16:             _timer.Tick += TimerTick;

  17:         }

  18:  

  19:         void ButtonButtonPressed(GT.Modules.GHIElectronics.Button sender, GT.Modules.GHIElectronics.Button.ButtonState state)

  20:         {

  21:             button.ToggleLED();

  22:             if (_timer.IsRunning)

  23:             {

  24:                 _timer.Stop();

  25:             }

  26:             else

  27:             {

  28:                 _timer.Start();

  29:             }

  30:         }

  31:  

  32:         void TimerTick(GT.Timer timer)

  33:         {

  34:             _axisY++;

  35:             if (_axisY + 10 > display_T35.SimpleGraphics.Height)

  36:             {

  37:                 display_T35.SimpleGraphics.Clear();

  38:                 _axisY = 20;

  39:             }

  40:             if (_modeUp && _axisX > 40)

  41:             {

  42:                 _modeUp = false;

  43:             }

  44:             if (!_modeUp && _axisX < 20)

  45:             {

  46:                 _modeUp = true;

  47:             }

  48:             if (_modeUp)

  49:             {

  50:                 _axisX++;

  51:             }

  52:             else

  53:             {

  54:                 _axisX--;

  55:             }

  56:             display_T35.SimpleGraphics.SetPixel(GT.Color.Green, _axisX, _axisY);

  57:             for (uint i = 1; i < 15; i++)

  58:             {

  59:                 display_T35.SimpleGraphics.SetPixel(GT.Color.Red, _axisX + i, _axisY);

  60:             }

  61:         }

  62:     }

  63: }

 

And already tomorrow to Santa Pola to show these things live with friends of GuseNet .

Saludos @ Santa Pola

El Bruno

image image image

[ELBRUNO] .Net Gadgeteer, HowTo: Mostrar un chart en un display


image

Buenas

Después de 2 días en Paris donde pude escribir poco y aprender mucho; hoy vamos con un ejemplo de código puro y duro

Cómo pintar pixel a pixel un chart en un display con .Net Gadgeteer.

En este ejemplo utilizaremos los siguientes elementos

Organizados con el siguiente esquema:

image

Del código de la aplicación debo resaltar

  • linea 19, en el press del Button además de detener e iniciar el timer, enciendo y apago el LED del boton
  • línea 32, la rutina que dibuja el chart es de lo más simple, incrementa un contador entre 20  40 y luego lo decrementa. También hay un segundo flag para controlar el avance vertical

 

   1: using GT = Gadgeteer;

   2:  

   3: namespace GadgeteerApp6

   4: {

   5:     public partial class Program

   6:     {

   7:         private uint _axisX = 20;

   8:         private uint _axisY = 20;

   9:         private GT.Timer _timer;

  10:         private bool _modeUp = true;

  11:  

  12:         void ProgramStarted()

  13:         {

  14:             button.ButtonPressed += ButtonButtonPressed;

  15:             _timer = new GT.Timer(200);

  16:             _timer.Tick += TimerTick;

  17:         }

  18:  

  19:         void ButtonButtonPressed(GT.Modules.GHIElectronics.Button sender, GT.Modules.GHIElectronics.Button.ButtonState state)

  20:         {

  21:             button.ToggleLED();

  22:             if (_timer.IsRunning)

  23:             {

  24:                 _timer.Stop();

  25:             }

  26:             else

  27:             {

  28:                 _timer.Start();

  29:             }

  30:         }

  31:  

  32:         void TimerTick(GT.Timer timer)

  33:         {

  34:             _axisY++;

  35:             if (_axisY + 10 > display_T35.SimpleGraphics.Height)

  36:             {

  37:                 display_T35.SimpleGraphics.Clear();

  38:                 _axisY = 20;

  39:             }

  40:             if (_modeUp && _axisX > 40)

  41:             {

  42:                 _modeUp = false;

  43:             }

  44:             if (!_modeUp && _axisX < 20)

  45:             {

  46:                 _modeUp = true;

  47:             }

  48:             if (_modeUp)

  49:             {

  50:                 _axisX++;

  51:             }

  52:             else

  53:             {

  54:                 _axisX--;

  55:             }

  56:             display_T35.SimpleGraphics.SetPixel(GT.Color.Green, _axisX, _axisY);

  57:             for (uint i = 1; i < 15; i++)

  58:             {

  59:                 display_T35.SimpleGraphics.SetPixel(GT.Color.Red, _axisX + i, _axisY);

  60:             }

  61:         }

  62:     }

  63: }

Para muestra nada mejor que un video

Y ya mañana para Santa Pola a mostrar estas cositas en vivo con los amigos de GuseNet.

 

Saludos @ Home

El Bruno

image image image

[#NETMF] HowTo: Change the color of a LED with a Timer and a Button


image

Buenas

today’s example is a little more complicated than a Hello World, but you gives more joys. It’s used a button and a multi-color LED to change the color of it with a timer.

In this example we will use

with the following diagram

image

And again, with less than 50 lines of code source we can deploy our application.

   1: using Gadgeteer.Modules.GHIElectronics;

   2: using GT = Gadgeteer;

   3:  

   4: namespace GadgeteerApp5

   5: {

   6:     public partial class Program

   7:     {

   8:         private GT.Timer _timer;

   9:  

  10:         void ProgramStarted()

  11:         {

  12:             button.ButtonPressed += ButtonButtonPressed;

  13:             _timer = new GT.Timer(1000);

  14:             _timer.Tick += TimerTick;

  15:         }

  16:  

  17:         void ButtonButtonPressed(Button sender, Button.ButtonState state)

  18:         {

  19:             if (!_timer.IsRunning)

  20:             {

  21:                 _timer.Start();

  22:             }

  23:             else

  24:             {

  25:                 _timer.Stop();

  26:                 multicolorLed.TurnOff();

  27:             }

  28:         }

  29:  

  30:         private void TimerTick(GT.Timer timer)

  31:         {

  32:             var color = multicolorLed.GetCurrentColor();

  33:  

  34:             if (color == GT.Color.Blue)

  35:             {

  36:                 color = GT.Color.Green;

  37:             }

  38:             else if (color == GT.Color.Green)

  39:             {

  40:                 color = GT.Color.Red;

  41:             }

  42:             else

  43:             {

  44:                 color = GT.Color.Blue;

  45:             }

  46:  

  47:             multicolorLed.TurnColor(color);

  48:         }

  49:     }

  50: }

Interesting application data

  • Line 13, special implementation of timer for.Net Gadgeteer. Or try to use the timer of. Net, you will die between terrible suffering
  • Line 19, in the implementation of the button, the Timer starts and shuts off the LED when the timer is stopped
  • Line 29, shows how simple that is to use LEDs, a GetCurrentColor() to get the current color and then a TurnColor() to set the color of the LED

The video http://www.youtube.com/watch?feature=player_embedded&v=yEwqQTdRc2c

Saludos @ La Finca

El Bruno

image image image