Loading...
  Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Mitsubishi IR AC remote decoding Problem on: March 13, 2013, 11:48:39 am
Hey,

I'm currently going through the same thing of trying to emulate an AC remote control.

I found these two blog posts which might help:

Reading the codes:
http://dduino.blogspot.in/2011/11/improved-ir-code-reciever.html

Sending the codes:
http://dduino.blogspot.in/2011/11/use-sonar-to-control-tv.html

I haven't completely tried these - so do let me know if they work!


As some very helpful posters have mentioned earlier, the buffer limit on line 112 of IRremote.h need to be increased too.

Thanks,
R
2  Topics / Home Automation and Networked Objects / Re: Arduino Controller android app on: January 30, 2013, 02:58:31 am
in thise piece of code you can set two variable with you android app.

Thanks for the explanation! The app works superbly!!! THANKS AGAIN smiley

I've set it to control a servo (which will be connected to a dimmer). I'm sharing the code below just in case anyone else wishes to control a servo with the app. The relays/switches part of the code below is still incomplete, but the servo part works perfectly. I've also applied the code change to allow 2-digit codes, so make sure they are all 01, 02, 03 in your android app settings.

Currently you have 2 buttons "dimmer down" (04) and "dimmer up" (14) that you can use to move the servo by a pre-defined angle. It also disconnects the servo after 1 second of no command, to avoid unnecessary current draw/vibrations, and also let it be freely moveable to allow manual control of the dimmer.

I've not changed anything in the checkClient() function.

Next, i'll be adding an IR control smiley

Code:
/************ Marque's Arduino Controller Example ************/
/***********  for questions: marque.l@gmail.com  ***********/
/*
http://arduino.cc/forum/index.php?topic=127770.0

In the android app settingsscreen you can set up you IP and port.
For this example you need to call prefix 1 "B" and prefix 2 "C".
*/
#include <Ethernet.h>
#include <HTTPClient.h>
#include <SPI.h>
#include <Servo.h> // servo library added

//MARQUESOFT's CODE
int RecievedString;
int valueB;
int valueC;
String readString = String(20);

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x9A, 0x4D };
EthernetServer server(80);   // port to listen on
EthernetClient client;

char content_main_top[] = "<body bgcolor=black><font color=white><center>";
char S1[] = "Globe OFF" ;
char S2[] = "Couch Lights OFF" ;
char S3[] = "Loft Lights OFF";
char S4[] = "Dim Globe";
char S5[] = "05";
char S6[] = "06";
char S11[] = "Globe ON" ;
char S12[] = "Couch Lights ON" ;
char S13[] = "Loft Lights ON";
char S14[] = "Brighten Globe";
char S15[] = "15";
char S16[] = "16";
char S404[] = "Not Found";


//DIMMER SETUP
Servo dimmerServo;  // create a servo object
int servoPin = 9;
int dimmerMax = 170; // the furthest the servo+dimmer goes anti-clockwise
int dimmerMin = 0; // the furthest the servo+dimmer goes clockwise
int dimmerIncrement = 10; // the step size for each button press
int dimmerVal = 0;
int dimmerValueShowPhone = dimmerMax - dimmerVal;
boolean detachServo = false; // note if the servo needs to be detached
long detachServoRequestTime = 0; //the millis at which detach servo was last requested

//RELAY SETUP



/************************** Setup **********************/
void setup()
{
  Serial.begin(9600);
  Serial.println("Getting IP......");
  Ethernet.begin(mac);
  Serial.print("My IP address: ");
  Ethernet.localIP().printTo(Serial);
  Serial.println();
  Serial.print("Gateway IP address is ");
  Ethernet.gatewayIP().printTo(Serial);
  Serial.println();
  Serial.print("DNS IP address is ");
  Ethernet.dnsServerIP().printTo(Serial);
  Serial.println();
}
void loop()
{
  checkclient();

  if (detachServo == true) { detachServoAfterDelay(); }
}

void checkclient()
{
  EthernetClient client = server.available();
  if (client)  
  {
    boolean sentHeader = false;
    while (client.connected())
    {
      if (client.available())
      {
        if(!sentHeader){
        client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          sentHeader = true;
        }
         char c = client.read();
         if (readString.length() < 20)
         Serial.print(c); //For debuggin in Serial Monitor window
         {readString.concat(c);}
         if (c == 'H')
         {
           Serial.println();
           int Is = readString.indexOf("/");
           int Iq = readString.indexOf("?");
           int Ib = readString.indexOf("b");
           int Ic = readString.indexOf("c");
           if(readString.indexOf("?") > 1)
           {
             if (Ib == (Iq+1))
             {
               char carray[5];
               readString.toCharArray( carray,5,(Ib+1));
               Serial.println(carray);
                valueB = atof(carray);
               Serial.print("B is now: ");
               Serial.println(valueB);
               client.print (content_main_top);
               client.print("B is now: ");
               client.print(valueB);
             }
            else if (Ic == (Iq+1))
             {
               char carray[5];
               readString.toCharArray( carray,5,(Ic+1));
               Serial.println(carray);
                valueC = atof(carray);
               Serial.print("C is now: ");
               Serial.println(valueC);
               client.print (content_main_top);
               client.print("C is now: ");
               client.print(valueC);
             }
             else
             {
               char carray[2];
               readString.toCharArray( carray,3,(Iq+1));
               RecievedString = atoi(carray);
               switch (RecievedString) {
               case 1: action(1, client);break;
               case 2: action(2, client);break;
               case 3: action(3, client);break;
               case 4: action(4, client);break;
               case 5: action(5, client);break;
               case 6: action(6, client);break;
               case 11: action(11, client);break;
               case 12: action(12, client);break;
               case 13: action(13, client);break;
               case 14: action(14, client);break;
               case 15: action(15, client);break;
               case 16: action(16, client);break;              
               default: action(404, client);
               }
             }
          delay(1);
             client.stop();
             readString="";
             client.read(); client.read();
           }
         if (Iq < 0)
         {
         action(404, client);
         delay(1);
         client.stop();
         readString="";
         client.read(); client.read();
         }
          delay(1);
         client.stop();
         readString="";
         client.read(); client.read();
       }
     }
   }
 }
}

void action(int x, EthernetClient client)
{  
  if (x == 1)
  {client.print (content_main_top);
   client.println(S1);
   Serial.println(S1);
  }
if (x == 2)
  {client.print (content_main_top);
   client.println(S2);
   Serial.println(S2);
  }
if (x == 3)
  {client.print (content_main_top);
   client.println(S3);
   Serial.println(S3);
  }
if (x == 4) // Dimmer Globe Down
  {client.print (content_main_top);
   client.println(S4);
   Serial.println(S4);
   dimmerDown();
   client.println(dimmerValueShowPhone);
  }
if (x == 5)
  {client.print (content_main_top);
   client.println(S5);
   Serial.println(S5);
  }
if (x == 6)
  {client.print (content_main_top);
   client.println(S6);
   Serial.println(S6);
  }
if (x == 11)
  {client.print (content_main_top);
   client.println(S11);
   Serial.println(S11);
  }
if (x == 12)
  {client.print (content_main_top);
   client.println(S12);
   Serial.println(S12);
  }
if (x == 13)
  {client.print (content_main_top);
   client.println(S13);
   Serial.println(S13);
  }
if (x == 14)
  {client.print (content_main_top);
   client.println(S14);
   Serial.println(S14);
   dimmerUp();
   client.println(dimmerValueShowPhone);  
  }
if (x == 15)
  {client.print (content_main_top);
   client.println(S15);
   Serial.println(S15);
  }
if (x == 16)
  {client.print (content_main_top);
   client.println(S16);
   Serial.println(S16);
  }
if (x == 404)
  {client.print (content_main_top);
   client.println(S404);
   Serial.println(S404);
  }
  
x=0;
}


void dimmerUp() {
  if (detachServo == false) { dimmerServo.attach(servoPin); } // only re-attach if its already been detached
  dimmerVal = dimmerVal - dimmerIncrement;
  if (dimmerVal < dimmerMin) { dimmerVal = dimmerMin; } // making sure it doesnt cross the minimum
  dimmerServo.write(dimmerVal);
  delay(10);   // wait for the servo to get there
  detachServo = true; // flags it to be detached after a few seconds
  detachServoRequestTime = millis();  
  dimmerValueShowPhone = dimmerMax - dimmerVal;  
}

void dimmerDown() {
  if (detachServo == false) { dimmerServo.attach(servoPin); } // only re-attach if its already been detached
  dimmerVal = dimmerVal + dimmerIncrement;
  if (dimmerVal > dimmerMax) { dimmerVal = dimmerMax; }  // making sure it doesnt cross the maximum
  dimmerServo.write(dimmerVal);
  delay(10);   // wait for the servo to get there
  detachServo = true; // flags it to be detached after a few seconds
  detachServoRequestTime = millis();
  dimmerValueShowPhone = dimmerMax - dimmerVal;
}

void detachServoAfterDelay() {   // timed detach for servo after dimmer up or dimmer down to prevent heat / fatigue / vibrations for the servo
  unsigned long currentMillis = millis();  
  if ( (currentMillis - detachServoRequestTime) > 1000 ) //time has passed
  {
    dimmerServo.detach();
    detachServo = false;
  }
}
3  Topics / Home Automation and Networked Objects / Re: Arduino Controller android app on: January 26, 2013, 08:52:50 am
SUPERB!!

Thank you Marque!!!

This is just what I needed. I just started on my room-automation project today, so I'm sure I'll come up with some suggestions soon enough smiley

I tried rating the app, but unfortunately i don't have a Google+ account as yet -- will get around to that soon!

Thanks,
R

PS - Though I've made some changes and its working great, i have no clue what the following code does. Could you please explain it to me in just a brief overview sentence or two? Thanks!
Code:
{readString.concat(c);}
         if (c == 'H')
         {
           Serial.println();
           int Is = readString.indexOf("/");
           int Iq = readString.indexOf("?");
           int Ib = readString.indexOf("b");
           int Ic = readString.indexOf("c");
           if(readString.indexOf("?") > 1)
           {
             if (Ib == (Iq+1))
             {
               char carray[5];
               readString.toCharArray( carray,5,(Ib+1));
               Serial.println(carray);
                valueB = atof(carray);
               Serial.print("B is now: ");
               Serial.println(valueB);
               client.print (content_main_top);
               client.print("B is now: ");
               client.print(valueB);
             }
            else if (Ic == (Iq+1))
             {
               char carray[5];
               readString.toCharArray( carray,5,(Ic+1));
               Serial.println(carray);
                valueC = atof(carray);
               Serial.print("C is now: ");
               Serial.println(valueC);
               client.print (content_main_top);
               client.print("C is now: ");
               client.print(valueC);
             }
4  Forum 2005-2010 (read only) / Troubleshooting / Re: 168 Programmer not responding on: January 28, 2007, 01:59:56 pm
Quote
Ya, I have the same problem. I tried burning the bootloader to a 168 with the microcontroller option set to 8 and it just returned a bunch of errors (no surprise). Do I need a new hex file or something?

Amsmnptarks,

I am an absolute newbie, and havent successfully flashed a microcontroller yet (which i am desperately tryng to! (atmel168))

But heres the little i know with regards to your question -
    Yes, you DO need a different .hex file.
    Secondly, i dont think you can just use the arduino IDE to flash a 168 on the 8 setting because of "fuses". (Fuses are the little settings on the chip "the closest thing a microcontroller has to a config file") eg. They enable you to select whether the chip uses an external oscillator or the internal oscillator. And my clueless guess is that they are at different memory addresses on different chips (atmega8 vs 168).
   Hence..you cannot fool the IDE to put a bootloader onto the 168 instead of the 8 just by replacing the .hex file.

Heres a really useful site which has helped me understand this a lot better - http://wolfpaulus.com/journal/embedded/arduino2.html - it also has a link to the .hex file for the 168.

cya
R
5  Forum 2005-2010 (read only) / Troubleshooting / Re: 168 Programmer not responding on: January 27, 2007, 07:55:52 pm
Quote
thanks for the fast reply! Most of the AVR-ISP's I found looked much more expensive than buidling the parallelprogrammer so I think I'll take that route. My (first of many) question is will the ICSP pins on the USB board still work with the 168? If not, can I just put it on a bread board and wire it up to the correct pins myself? Hopefully that's it. Thanks again!

Oh, but wait!

I tried doing this day before, but as soon as i switched the setting in the IDE from atmega8 to atmega168, the options for bootloading the chip (via programmer or Parallel port interface) both got greyed out!!

What am i missing?

Thanks,
R
6  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: From Atmega8 to Atmega168 on: March 04, 2007, 11:03:36 pm
notstarman,

You can only use that cable to upload the bootloader to the atmega8 and not the 168 through the IDE the last time i checked!

cya
R
7  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: From Atmega8 to Atmega168 on: February 07, 2007, 12:55:03 am
kzwin,

I assume you have physically replaced the atmega8 with the atmega168 chip on your arduino board, and then selected the atmega168 in the IDE and are still having problems.

Q: Have you just bought the atmega168 from an online website? (in which case it will NOT have the arduino bootloader on it, which is essential).

Getting the bootloader on the chip is a painful and/or expensive thing to do for beginners. I would suggest you buy a pre-bootloaded 168, you will find some links on the forum

cya
R
8  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: motors with accurate position and speed contro on: January 28, 2007, 09:55:34 pm
Quote
a modded hitec hs-300 servo motor, and while it delivers continuous rotation and accurate enough positioning, the speed control is quite limited.

Hey,

Sadly i dont have any more suggestions than Daniel - a stepper or a rotary encoder seem to be your best bets.

Perhaps you can tell us a little more about the application, and we could suggest a better system (for eg. putting a rotary encoder on the object the motor is turning instead of on the motor driveshaft)

Also, could you please give me some more information as to how the servo was hacked...the more detailed the better!

thanks,
R
9  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: arduino bluetooth on: January 18, 2007, 06:14:18 pm

No mention of current status or possible launch date?  :-[

cya
R
10  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: arduino bluetooth on: January 09, 2007, 05:48:48 am

So in another post on the forum i found a link to Massimo's blog which has a bit about the arduinoBT (http://tinker.it/now/2006/11/24/arduino-bluetooth-demos/).

I guess it is based on the ATmega168 fyi.

And more news and updates (especially on when it is likely to be available) from the powers that be would be most welcomed!

cya
R

ps - Also great to see that a S60 cellphone (Nokia 6630 - same one that i have!) is being used. Now i just have to learn python...seems like a straightforward language...!
11  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: arduino bluetooth on: January 05, 2007, 03:07:39 pm
Hi,

I am really keen on buying an arduino as well (probably the mini), but i am considering sacrificing size and weight in order to be able to flash it via bluetooth as the controller will probably be within a flying object... smiley-grin

As per this thread >> http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1165363464  (reply #4)
The whereabouts of the elusive arduinoBT should have been a little clearer quite some time ago... ?

I was just hoping that the Forum Admin could give us a little more information on -
1. Size of the board
2. # of Analog In pins
3. # of PWM pins
4. Will the board be able to send serial out to the computer / recieve from the computer while the program is running?
5. Rough date of availability
6. Rough pricing / pricerange?

Thanks a lot!
cya
R
12  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Basic stamp components on: January 10, 2007, 08:54:49 am
Hi Nabisco,

I am a newbie myself, but since you havent got any replies i will try and give you an answer....(should be fairly true i hope!)


From what i know, any sensor should work with any microcontroller (ie its not like a mac program wont run on a PC).
All sensors usually output in one or the other common forms such as resistive output, analog voltage out, digital out, serial out etc etc

If you need more specific clarification you could post a link to the exact sensor/part you are talking about...

cya
R
13  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 9v >> 5v On the MINI  & Atmega8 standalone Qs on: January 07, 2007, 11:49:49 am

I guess you guys can leave out Q6 as i got the answer here -

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1163418637

cya
R
14  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: 9v >> 5v On the MINI  & Atmega8 standalone Qs on: January 07, 2007, 10:36:50 am
Thanks a ton guys,

@brainfart - i am starting off by putting a gyro on a cheap heli and modulating the tailrotor to keep it from yawing - (http://www.ehirobo.com/shop/product_info.php?products_id=3307) and then will proceed to add on things from there.

@Daniel - Thanks for the info. Good point on the low dropout voltage regulator! thnx. I have a stupid Q regarding the crystal (see #6 below)

@Neilzero - Thanks for that page. It REALLY helped me get a better understanding of most of the concepts of standalone atmega, and a lot of the links on the page were useful too!


Here are a few more Qs i had -

6. Heres the stupid Q - if i use the atmega's internal crystal/oscillator, which i have read is equivalent to 1Mhz, would that mean my atmega will be running at 1/16th the speed compared to if i used an external 16MHz crystal? (So in a sense a 16MHz external cryztal is "overclocking" it?)

7. Mellis mentioned that you can use a Wiring board (which i have) as an AVR-ISP (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1158265039/5) Where could i find info on that ?

8. If i program the atmega168 via wiring board, will it be able to put a bootloader on as well as upload the program i write? or will it only do the bootloader and i will have to put it in my arduinoNG to upload the program ?

9. Any useful links of people using gyros with their own microcontrollers in helicopters? or for anything else?

10. Would i be correct to assume that a gryo will only show a rate of change if there is rotational movement about its axis, and not if it is moved around on a horizontal plane without any rotation?

And also, if you guys could help with Q1 & 2 from the original post  smiley-grin
Once i have that figured i will buy my mini! (also would like to buy one of these!! > http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1167665675)

Thanks a lot,
Really appreciate the help,
RB

15  Forum 2005-2010 (read only) / Frequently-Asked Questions / 9v >> 5v On the MINI  & Atmega8 standalone Qs on: January 05, 2007, 03:43:48 pm

Hi there,

Im planning to use an arduino mini on a RC helicopter.

1. Would it be possible to run the mini power from a 7.2V battery pack to the +9V of the mini ?
2. Would the arduino mini then output a regulated +5v at any pin so i can run a 5v sensor? (possibly the +5v pin at the top or bottom??)



Also, on another note,
3. if i buy an arduinoNG and flash the program to it, then remove the atmega8 chip can i just connect the corresponding pins as i would the arduinoNG pins ? (ie no need for any other hardware / ?bootloader? etc etc)

4. Does the standalone ATmega8 need exactly 5v to run?
5. And, finally, does just the standalone atmega8 have the ability to convert 7.2V to 5v ? (unlikely eh)

Thanks a lot,
cya
R
Pages: [1]