Posts Tagged ‘tutorial’
18
feb

Hi nerdz,
today i’ll show you how to easily control remotely your room with a stupid motion detector, a piro sensor (or you can use other sensors, like ultrasonic, infrared, light sensor, pressure, etc etc…) and two lines of PHP code and C.

* Useful if you want to know if anyone enter in your room and the time that remains there! *


You can get this sensor from AirWick deo! :)

How it works?
Your piro sensor, when detect a motion, notify arduino, that was programmed to send to serial port a value (“m” or “n”).
These value are interpreted by a serial reader (c# program, objective-c, java, c++, or somethig else) that call a PHP page that send email if is enabled sending mode.
Second php page, permit you to control arduino (enable/disable/show logs/clear all).

Steps:
Connect your piro sensor to arduino, easy way, like this:
Arduino Connecting Piro Sensor

After that, write your simple arduino code:

Continue reading “[Arduino] Room Spy Email Notificator” »

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , , , ,

31
mar

Hi all,
simple way to control the speed of a DC Motor!

This is the first step to control a car!!!

You can turn potentiometer to control speed of your dc motor. When motor is too fast, RED led will light on!!



Here the scheme:
Arduino with DC Motor and Potentiometer

Components:
– 1 DC Motor
– 1 Potentiometer 10k
– 1 TIP120
– 1 diode (1N4001)
– 1 10kohm resistor
– 2 100ohm resistor
– 1 red led
– 1 green led
– arduino
– wires

Here a demo video:



Ref: albertopasca.it

Here the code:

Continue reading “[Arduino] Speed control with DC Motor and Pot” »

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , , , , ,

27
mar

Great!
A TV Remote Control that controls my LED or something else…!!!




Ref: albertopasca.it





FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , ,

26
mar

Hi all,
as my first experiment, an arduino connected to COM9 to recognize incoming mails from google mail (gmail)!!
Very easy to do!!!





As experiment I connected Arduino board to a breadboard with a GREEN LED and a PIEZO SPEACKER in this way:


Arduino Gmail Notifier

Rif: albertopasca.it

I connected the LED to Arduino pin 13 and speacker to arduino pin 12.

The code sended to Arduino ATMEGA328 chip was this:
-It was programmed to read serial port data (sended from server by C# app)-

Arduino CODE (C):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* green led*/
const int ledPin = 13;

/* piezo */
const int beepPin = 12;

/* check gmail mails :D */
int mail = LOW;
int val;

void setup()
{
  /* setup pin iniziale */
  pinMode(ledPin, OUTPUT);      
  pinMode(beepPin, OUTPUT);
 
  Serial.begin(9600);
 
  mail = HIGH;
}

void loop()
{
  /* loop gmail check mails */
  val = Serial.read();
  Serial.println(val, BYTE);

  if (val == 110) { // "n" = 110 in dec from ascii
    mail = HIGH;
  } else if (val == 109) { //109 = "m" in dec from ascii
    mail = LOW;

    /* accendo il led*/
    digitalWrite(ledPin, HIGH);

    /* fischio avviso mail
        tipo fischio di fine
        partita di calcio */

    digitalWrite(beepPin, HIGH);
    delay(500);
    digitalWrite(beepPin, LOW);
    delay(200);
    digitalWrite(beepPin, HIGH);
    delay(500);
    digitalWrite(beepPin, LOW);
    delay(200);
    digitalWrite(beepPin, HIGH);
    delay(3000);

    /* rimetto tutto a posto */
    digitalWrite(beepPin, LOW);
    digitalWrite(ledPin, LOW);
  }  
}

After that Arduino code was uploaded to chip and programmed successfully, I make a C# app that loop on “while true” to check google mails every 10 seconds.
If there is a new incoming mail, it send to serial port (COM9, 9600) a char, “m” for new mail and “n” for NO mail that are interpreted from arduino respectly to 109 and 110 in DEC format.
Arduino CODE recognize the DEC (ascii code, m||n) and executed code relatively condition.
If there was a “m” code, it send an HIGH signal (1) to GREEN LED and an HIGH to speacker (temporized).
Until you don’t read your message, it beeps every 10 seconds!!




To do all of this tricks, you need to create a C# Windows || Console app and run on COM9 listening arduino.

This is C# code (VS2010 – C#4.0):

/* SEND / READ SERIAL PORT COM9 DATA */

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
try {
  SerialPort port = new SerialPort( "COM9", 9600, Parity.None, 8, StopBits.One );
  port.Open();

  string Unreadz = "0";
  while ( true ) {
    Unreadz = CheckMail();
    Console.WriteLine( "Unread Mails: " + Unreadz );

    if ( !Unreadz.Equals( "0" ) ) port.Write( "m" );
    else port.Write( "n" );

    Thread.Sleep( 10000 );
  }
} catch ( Exception ee ) { Console.WriteLine( ee.Message ); }

This ones check mails:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
private string CheckMail() {
    string result = "0";

    try {
      var url = @"https://gmail.google.com/gmail/feed/atom";
      var USER = "your.user.name";
      var PASS = "youRp@ssw0rd";

      var encoded = TextToBase64( USER + ":" + PASS );

      var myWebRequest = HttpWebRequest.Create( url );
      myWebRequest.Method = "POST";
      myWebRequest.ContentLength = 0;
      myWebRequest.Headers.Add( "Authorization", "Basic " + encoded );

      var response = myWebRequest.GetResponse();
      var stream = response.GetResponseStream();

      XmlReader reader = XmlReader.Create( stream );
      while ( reader.Read() )
        if ( reader.NodeType == XmlNodeType.Element )
          if ( reader.Name == "fullcount" ) {
            result = reader.ReadElementContentAsString();
            return result;
          }
    } catch ( Exception ee ) { Console.WriteLine( ee.Message ); }
    return result;
  }
}

…and last one, text convertion:

1
2
3
4
5
public static string TextToBase64( string sAscii ) {
  System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
  byte[] bytes = encoding.GetBytes( sAscii );
  return System.Convert.ToBase64String( bytes, 0, bytes.Length );
}

Now, upload code to arduino, press PLAY to C# project… and send you a mail to your gmail address!!!

enjoy beeping!

Rif: albertopasca.it





FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , , , , , , ,

25
mar

Hi all,
this is the first post about Arduino!

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.


Arduino Uno

www.arduino.cc

It’s learning time… stay tuned for Videos and Tutorials!!






Rif: albertopasca.it

FacebookTwitterDeliciousLinkedInGoogle BookmarksNetlogGoogle GmailMySpaceGoogle ReaderShare

, , , , , , , , ,

Switch to our mobile site