Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Mouse.move() problem or my coding? on: July 30, 2013, 06:10:38 pm
Code:
for(int i; i > -2000; i -= 120){
    Mouse.move(-120, -120, 0);
  }
}

You aren't using "i" in the Mouse.move so you may as well go from 0 to 17 as Arrch said.

yep, done. thanks.
2  Using Arduino / Programming Questions / Re: Mouse.move() problem or my coding? on: July 30, 2013, 10:43:43 am
Fair enough.
i learned that the hard way, heh

anyway, i changed all the loops to have "int x = 0" and it works perfectly now. thanks so much.
3  Using Arduino / Programming Questions / Re: Mouse.move() problem or my coding? on: July 30, 2013, 10:01:43 am

You're initializing i with a random value. It may be 0, it may not be. Don't assume it is. Also, if you're not using i anywhere in your block of code below the for statement, then why both defining some crazy stop and increment parameters? Assuming i has an initial value of zero, the function will run 17 times, so why not simplify it to:

Code:
for (int i=0; i<17; i++)
{
  Mouse.move(-120, -120, 0);
}
good point, thanks.
Quote
Since there is no delay, why bother sending 17 different commands? Why not simplify it it a single command?

Code:
Mouse.move(-2040, -2040, 0);

What is the point of the for loops?
because Mouse.move() uses a signed char, so anything over 126 or below -126 doesn't work.

thanks for the post, it helps to have another set of eyes on the code
4  Using Arduino / Programming Questions / Mouse.move() problem or my coding? on: July 30, 2013, 09:08:36 am
when i try calling a subroutine with Mouse.move(2,0,0) followed by Mouse.move(0,2,0), the mouse moves along the x axis only.

code:

mouseHome():
Code:
void mouseHome(){
  for(int i; i > -2000; i -= 120){
    Mouse.move(-120, -120, 0);
  }
}

this works:
Code:
void mouseGoToIcon(){
  
  mouseHome();
  
  mouseGoToIconX();
  
  mouseGoToIconY();
}

void mouseGoToIconX(){
  for(int x; x < 350; x += 2){
    Mouse.move(2, 0, 0);
  }
}

void mouseGoToIconY(){ 
  for(int y; y < 200; y += 2){
    Mouse.move(0, 2, 0);
  }
}

and this doesn't work (mouse only moves in x direction):
Code:
void mouseGoToIcon(){
 
  mouseHome();
 
  for(int x; x < 350; x += 2){
    Mouse.move(2, 0, 0);
  }
 
  for(int y; y < 200; y += 2){
    Mouse.move(0, 2, 0);
  }
}

and each time i'm calling mouseGoToIcon(). i'm not sure what the issue is. the code is working right now, it just takes a few extra lines is all. any insight would be appreciated.
5  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Link Activity on External LED? on: April 25, 2013, 09:00:12 am
never mind: i found it.

the led's have separate pins on the bottom of the board. i found that they're switched ground, so i used each one to drive a transistor (and consequently an led). easy.


and for having no other use for this thread other than reference, here's an entertaining .gif

6  Using Arduino / Networking, Protocols, and Devices / Ethernet Link Activity on External LED? on: April 24, 2013, 07:51:11 am
i'm putting a mega + ethernet shield in an enclosure with one of these:



the thing is i want to be able to see the link activity led's from the outside of the enclosure:

these ones:


mounting the board up against the outside won't work, so i'd like to extend the connection/link led's to the front panel... any ideas?

(ps- all my searches yield "controlling led over ethernet" which is not what i want)
7  Topics / Home Automation and Networked Objects / Re: LAN server without refreshing on: January 11, 2013, 10:53:12 am
thank you! perfect. now i just need to get it to work with buttons in lieu of links.
8  Topics / Home Automation and Networked Objects / Re: LAN server without refreshing on: January 11, 2013, 08:48:00 am
yeah, the ip address is what i use around here. it works, so i'm not worried.

what you suggest sounds good. i'll look up some info on it, but would you happen to have any links or examples you could point me to? like i said, i'll be searching as well. thanks a bunch
9  Topics / Home Automation and Networked Objects / Re: LAN server without refreshing on: January 10, 2013, 11:38:59 am
nothin'? so it's just a way of life, then?
10  Using Arduino / Networking, Protocols, and Devices / Re: Arduino + Ethernet. A page long loading on: January 10, 2013, 11:33:19 am
soooo... any progress? any thoughts on what is causing the slow loading? i have pretty much the same issue.

anyone?
11  Topics / Home Automation and Networked Objects / Re: LAN server without refreshing on: November 28, 2012, 01:17:10 pm
places for 8 "robots" each with 4 functions. each robot is different, and the controlls are all different (they all have power, standby, up, and down, but how each controll is opperated is different)

Code:
//updated 2012-11-28

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
  192, 1, 1, 102 };
byte gateway[] = {
  192, 1, 1, 1 };
byte subnet[] = {
  255, 255, 255, 0 };


int rControl[8][4] = {
  {
    02,03,05,06        }
  ,
  {
    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        }
};


//make sure this list matches the switch/case below!!!
String rName[8] = {
  "BOB","BOBBY","JACK","empty","empty","empty","empty","empty"};
String rFunc[4] = {
  "POWER","STANDBY","UP","DOWN"};
String rPower[8] = {
  "off","off","off","off","off","off","off","off"};

String tempStr;

int intQuestion;
int intEquals;

String inString = String(35);

String Led;

EthernetServer server(80);
String data;

void setup()
{
  Serial.begin(9600);

  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac, ip,gateway,subnet);
  server.begin();

  for (int r = 0; r < 8; r++){
    for (int c = 0; c < 4; c++){
      pinMode(rControl[r][c], OUTPUT);
    }
  }

  //initial power state (BOB=LOW; JACK=HIGH;)
  digitalWrite(rControl[0][0], LOW);
  digitalWrite(rControl[1][0], LOW);
  digitalWrite(rControl[2][0], HIGH);
  digitalWrite(rControl[3][0], HIGH);
  digitalWrite(rControl[4][0], LOW);
  digitalWrite(rControl[5][0], LOW);
  digitalWrite(rControl[6][0], HIGH);
  digitalWrite(rControl[7][0], HIGH);

  Serial.println("Serial READY");
  Serial.println("Ethernet READY");
  Serial.println("Server READY");
}

void loop()
{
  EthernetClient client = server.available();

  if(client){
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {

      if(client.available()) {

        char cl = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (inString.length() < 35) {
          inString.concat(cl);
        }
        if (cl == '\n' && current_line_is_blank) {

          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html><head><title>TINY robot control</title></head><body bgcolor=#000099><form method=get>");
          client.println("<div id=\"container\">");
          client.println("<div id=\"header\" style=\"background-color:#000099;\">");
          client.println("<font size=10 face=\"britannic bold\" style=\"color:#eeee00;margin-bottom:0;\"><center><i>The TITle goes here.</i></center></font>");
          client.println("<font face=\"arial\" style=\"color:#dddd00;\"><center>lots of robots, so little time</center></font><br></div>");

         
          client.println("<div id=\"content\" style=\"background-color:#EEEEEE;float:left;width:100%;\">");

          client.println("<center><br><table border=\"1\">");

          Serial.println(inString);
          //entire loop starts here
          for (int r = 0; r < 8; r++){
            client.println("<tr>");
            client.println("<td>"+String(rName[r])+"</td>");
            for (int c = 0; c < 4; c++){

              intQuestion = inString.indexOf("?") +1;
              intEquals = inString.indexOf("=");
              //check the incomming string for control number
              if(inString.substring(intQuestion,intEquals) == String(rControl[r][c])){
                Serial.println(rControl[r][c]);
                //Serial.println(inString.substring(intQuestion,intEquals) + "vvvv");

                //match the control functions to the individual radars
                if(rName[r] == "BOB"){
                  //check if it's the power button
                  if(c == 0){
                    //power button switch
                    if(rPower[r] == "off"){
                      digitalWrite(rControl[r][c], HIGH);
                      rPower[r] = "ON";
                    }
                    else if(rPower[r] == "ON"){
                      digitalWrite(rControl[r][c], LOW);
                      rPower[r] = "off";
                    }
                  }
                  else{
                    digitalWrite(rControl[r][c], HIGH);
                    delay(50);
                    digitalWrite(rControl[r][c], LOW);
                  }
                }
                else if(rName[r] == "BOBBY"){
                  //check if it's the power button
                  if(c == 0){
                    //power button switch
                    if(rPower[r] == "off"){
                      digitalWrite(rControl[r][c], HIGH);
                      rPower[r] = "ON";
                    }
                    else if(rPower[r] == "ON"){
                      digitalWrite(rControl[r][c], LOW);
                      rPower[r] = "off";
                    }
                  }
                  else{
                    digitalWrite(rControl[r][c], HIGH);
                    delay(50);
                    digitalWrite(rControl[r][c], LOW);
                  }
                }
                else if(rName[r] == "JACK"){
                  //check if it's the power button
                  if(c == 0){
                    //power button switch
                    if(rPower[r] == "off"){
                      digitalWrite(rControl[r][c], LOW);
                      rPower[r] = "ON";
                      delay(50);
                      digitalWrite(rControl[r][c], HIGH);
                      delay(9500);
                      digitalWrite(rControl[r][c], LOW);
                      delay(50);
                      digitalWrite(rControl[r][c], HIGH);
                    }
                    else if(rPower[r] == "ON"){
                      digitalWrite(rControl[r][c], LOW);
                      rPower[r] = "off";
                      delay(5000);
                      digitalWrite(rControl[r][c], HIGH);
                    }
                  }
                  //check if it's the standby button
                  else if(c == 1){
                    digitalWrite(rControl[r][c-1], LOW);
                    delay(70);
                    digitalWrite(rControl[r][c-1], HIGH);
                    delay(70);
                    digitalWrite(rControl[r][c], HIGH);
                    delay(70);
                    digitalWrite(rControl[r][c], LOW);
                  }
                  else{
                    digitalWrite(rControl[r][c], HIGH);
                    delay(50);
                    digitalWrite(rControl[r][c], LOW);
                  }
                }

              }             
              client.println("<td><input type=submit name="+String(rControl[r][c])+" value="+String(rFunc[c])+"></td>");
            }
            if(rPower[r] == "ON"){
              client.println("<td bgcolor=#00ff00 width=30><center>"+rPower[r]+"</center></td>");
            }
             else{
              client.println("<td bgcolor=#ff0000 width=30><center>"+rPower[r]+"</center></td>");
             }
            client.println("</tr>");
          }
          //entire loop ends here

          client.println("</table></center><br>");
          client.println("</div>");
          client.println("<div id=\"footer\" style=\"background-color:#000099;color:#eeee00;clear:both;text-align:center;\"><br><font face=\"arial\">footer placeholder</face></div>");

          client.println("</div></from></html></body>");
          break;
        }
        if (cl == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        }
        else if (cl != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    inString = "";
    client.stop();
  }
}
12  Topics / Home Automation and Networked Objects / LAN server without refreshing on: November 28, 2012, 11:34:47 am
the setup:
network shield on top, mega on the bottom, 32 i/o ports in-use (as outputs)

the dilemma:
every time a button on the "webpage" is pressed to control an i/o port, the entire page is refreshed/reloaded. normally that wouldn't be an issue, but my network seems to act weird. i have a video server that works like it should; streaming in real-time. but each time the arduino webpage is loaded, it's a crap shoot weather the whole thing loads all the way or not. in ie, it'll load some and stop loading after showing some code on-screen. on firefox, it times out with an error message mostly. on chrome, it loads what it can; sometimes just the head, sometimes the whole thing. i can still use the functions, but it's not what i programmed it to do.
(also: locally, it works perfectly. remotely, it has the problems)

i'll get code up in a bit. any alternatives to keeping the connection open full-time, or making sure the whole page always loads?
13  Using Arduino / Project Guidance / Re: making of a cluster on: November 28, 2012, 11:18:11 am
"instrument cluster" is what i think he meant.

encoders are not as rugged as motors, as they don't fair well under the hood of a car.

i've made a dash board before, and the code is out there. look at the datasheet for the digital-analog converter for basic circuit ideas. also, look into a frequency-to-voltage converter. using that, you could tie into the existing coil ignitor circuit. no moving parts at all.
14  Using Arduino / Networking, Protocols, and Devices / Re: LAN Server Questions on: June 28, 2012, 07:39:59 am
so after playing around a bit, i now know that it does work. thanks everyone for pointing me in the right dirrection.
15  Using Arduino / Networking, Protocols, and Devices / Re: LAN Server Questions on: June 27, 2012, 11:30:41 am
so if i set it up like this (snippet):

Code:
...
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(191,11,1,1);
EthernetServer server(80);

void setup()
{
   Ethernet.begin(mac, ip);
...

without specifying gateway or subnet, it should work, regardless of what type (lan/wan) network i use?
Pages: [1] 2