Monday, March 12, 2012

Control your old fan.....From a SONY tv remote

It's really nice when you have the control of your fan in your hands....specially in a cold morning..that you do not like to getup form the bed. I will post the details of the schematic later. but its nothing much just replace your regular fan switch with 2/3 relays.
give the relay control to the Arduino board. I have connected 2 relays to the pins 5 and 7 of the Arduino board. and pin 4 for a buzzer. attach the IR sensor head to Pin 11
include IRremote library with the code
*************** source code for Arduino *******************************

// example 32.2 - IR receiver code translator
// for Sony IR codes (ignores 2nd and 3rd signal repeat)
// http://tronixstuff.com/tutorials > chapter 32
// based on code by Ken Shirriff - http://arcfn.com

#include <IRremote.h> // use the library for IR
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;

void setup()
{
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
pinMode(4, OUTPUT); // beeper
pinMode(5, OUTPUT); // speed 1
pinMode(7, OUTPUT); // speed 2
}

void translateIR()
// takes action based on IR code received
// describing Sony IR codes on LCD module
{
switch(results.value)
{
//case 0x37EE: Serial.println(" Favourite "); break;
//case 0xA90: Serial.println(" Power button "); break;
//case 0x290: Serial.println(" mute ");
// Serial.println(" mute hi ");
// beep();

//break;
case 0x52E9: Serial.println(" one ");
speed1();
beep();
break;
case 0x32E9: Serial.println(" two ");
speed2();
beep();
break;
case 0x12E9: Serial.println(" three ");
off();
break;
//case 0xC10: Serial.println(" four "); break;
//case 0x210: Serial.println(" five "); break;
//case 0xA10: Serial.println(" six "); break;
//case 0x610: Serial.println(" seven "); break;
//case 0xE10: Serial.println(" eight "); break;
//case 0x110: Serial.println(" nine "); break;
//case 0x910: Serial.println(" zero "); break;
//case 0x490: Serial.println(" volume up "); break;
//case 0xC90: Serial.println(" volume down "); break;
//case 0x90: Serial.println(" channel up "); break;
//case 0x890: Serial.println(" channel down "); break;
default: Serial.println(" other button ");
}
delay(500);

}

void beep()
{
digitalWrite (4, HIGH);
delay (50);
digitalWrite (4, LOW);
}

void speed1()
{
digitalWrite (7, LOW);
digitalWrite (5, HIGH);
}
void speed2()
{
digitalWrite (5, LOW);
digitalWrite (7, HIGH);
}

void off()
{
digitalWrite (5, LOW);
digitalWrite (7, LOW);
}

void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
for (int z=0; z<2; z++) // ignore 2nd and 3rd signal repeat
{
irrecv.resume(); // receive the next value
}
}
}

******************************************************************************








Thursday, March 1, 2012

Controlling your Scanner over the Internet

if you want to control your scanner over the internet & if it doesn't have any serial port to control, then this is for you.
Things you need
1. one Arduino board (for the Ethernet Shield)
2. one Ardino board for the scanner interface
3. IIS server running on Windows 7 with PHP
4. PHP interface
5  Port forwarding knowledge
6. Audio streaming server 

we have to use some sort of power saving to control the PC running the servers. and we should be able to boot up the PC remotely. that's why we have to use  one Arduino with Ethernet shield for this purpose.

first we have to install the IIS server in windows 7 with PHP.

First of all, you need PHP (obviously). Go to the PHP download page and grab the latest non-thread-safe ZIP archive for Windows. As of writing this, the package is called "PHP 5.2.8 Non-thread-safe zip package". Unzip the archive to a folder on your hard disk (I use C:\php5) and create a copy of php.ini-recommended (or php.ini-production in recent PHP versions) called php.ini. There, add the following configuration setting:

cgi.force_redirect = 0

This is the minimum setting you need to change to make PHP work with IIS. You may also want to use cgi.fix_pathinfo = 1, fastcgi.impersonate = 1, and set extension_dir appropriately.

Then it's time to install IIS. You need at least the "Business" version of Windows 7, but the currently available beta 1 is Windows 7 Ultimate anyway. Go to Start/Control Panel/Programs/Turn Windows Features on or off and check on the Internet Information Services entry. Activate the World Wide Web Services/Application Development Features/CGI node and also Web Management Tools/IIS Management Console (the latter not shown in the figure).
Now, start the IIS Management Console; just open up the start menu, enter inetmgr and hit Enter. There, navigate to the Sites/Default Web Site/Handler Mappings node and double-click on the "Handler Mappings" entry.

As a result of this, the Actions panel on the right hand side changes. You now see an option called Add Module Mapping. Clicking on it opens up a dialog which you fill out as you can see in the following figure (you may need to adapt the path used to your local system).

If you do not see the FastCgiModule entry, you probably forgot to check the CGI node when installing IIS. Otherwise, close the Add Module Mapping dialog by clicking on OK. You need to confirm that you want to create a FastCGI application; click Yes.




Finally, create a .php script and put it in the root folder of the IIS site (by default C:\Inetpub\wwwroot; note that you may need additional rights to write into that directory), e.g. phpinfo.php with a simple phpinfo() call in it. Call this script using http://localhost/phpinfo.php, and you are done!

Put following code in phpinfo.php file


and finally since you are going to control this over the internet you need to bind your PHP web page with the port that you are going to forward. to do that go to controlpanel<<administrative tools<<IIS manager. on the left pane expand site and click bindings on right pane.Enter the port and IP of  the PC you are forwarding


To be Continued............