Exemplo n.º 1
0
void setup() {
  // Init the WiServer with our sendPage function that we defined above
  Serial.begin(9200);
  Serial.println("Loading..");
  
  // Output some bits and peices to screen
  lcd.init();
  lcd.clear();
  lcd.cursorTo(1,0);
  lcd.printIn("Wireless LCD Shield");
  lcd.cursorTo(2,0);
  lcd.printIn("MilesBurton.com 2009");
  lcd.cursorTo(3,0);
  lcd.printIn("Powered by WiShield");
  lcd.cursorTo(4,0);
  lcd.printIn("Loading...");
  
  // Initalise and connect Wifi
  WiServer.init(sendPage);  

  // Confirm we're finished loading
  Serial.println("Finished loading...");
  // Update the LCD
  lcd.cursorTo(4,0); 
  lcd.printIn("Ready...");
}
Exemplo n.º 2
0
/*
 * We'll have the WiServer call this function whenever a resource needs to be sent
 * @param URL null-terminated URL of the resource to send
 */
boolean sendPage(char* URL) {
  Serial.println(URL);
  // Request for the main page (checked last because other URL's also start with '/')
  if (strcmp(URL, "/") == 0) {
    WiServer.print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
    WiServer.print("<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-gb\" xml:lang=\"en-gb\">");
    WiServer.print("<head>");
    WiServer.print("</head><body>"); 
    WiServer.print("<script src=\"http://download.milesburton.com/Arduino/WiServer/htmlScript.js\" type=\"text/javascript\"></script>");
    WiServer.print("</body></html>");
    return true;   
  }
  else{
    // Consider a URL to be a request to output to a URL
    // Each forward slash represents a new line (4 lines max)
    
    int j = 1; // Start at char 1 of the URL (ignore the first /)
    lcd.clear(); // Clear LCD
    Serial.println("Writing to LCD");
    
    int len = strlen(URL);
    // Loop through each line
    for(int i=1;i<5;i++)
    {
      Serial.print("Writing to line");
      Serial.print(i);
      Serial.print('\n');


      lcd.cursorTo(i,0); // Move to line
      
      // Read next page of URL
      
      for(j=j;j<len;j++)
      {
        if(((j+2)<=len) && URL[j]=='%' && URL[j+1]=='2' && URL[j+2]=='0')
        {
          lcd.print(' ');
          j+=2;
          continue;
        }  
        
         
        if(URL[j]=='/')
        {
          j++;
          break; // If the current char is a /, break out read for the next line
        }
        lcd.print(URL[j]); // Write out char in URL to LCD
        Serial.print(URL[j]); // Send to Serial also
      }
       Serial.print('\n'); // Write a new line for easy reading
    }
    
    Serial.println("...Waiting for next command...");
    return true; // Return 200 to page
  }
}
Exemplo n.º 3
0
void loop() {  
  val = analogRead(potPin);
  
  if (val != valOld)
    {
       lcd.cursorTo(1, 10); 
       sprintf(buffer,"%4d",val);
       lcd.printIn(buffer);
    }
      valOld= val;
  
   /***** sending the dmx signal *****/
  // sending the break (the break can be between 88us and 1sec)
  digitalWrite(sig, LOW);

  delay(val);

  // sending the start byte
  shiftDmxOut(sig, 0);

  for (int count = 1; count <= 512; count++)
  {
    shiftDmxOut(sig, value[count]);
  }
  /***** sending the dmx signal end *****/

  value[1] += valueadd[1];
  if ((value[1] <= 0) || (value[1] >= 250))
  {
    valueadd[1] *= -1;
  }
 
 
 value[2] += valueadd[2];
  if ((value[2] <= 0) || (value[2] >= 250))
  {
    valueadd[2] *= -1;
  }

 
 value[3] += valueadd[3];
  if ((value[3] <= 0) || (value[3] >= 250))
  {
    valueadd[3] *= -1;
  }
   
 
 value[4] += valueadd[4];
  if ((value[4] <= 0) || (value[4] >= 250))
  {
    valueadd[4] *= -1;
  }
  
}
Exemplo n.º 4
0
void setup() { 
  pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat
  pinMode(sig, OUTPUT);
  lcd.init();
  //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
  //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)
       lcd.clear();
       val = analogRead(potPin);
       sprintf(buffer,"%4d",val);
       lcd.printIn("Poti:");
       lcd.cursorTo(1, 10); 
       lcd.printIn(buffer);
}
Exemplo n.º 5
0
// writes msg to required line
void lcd_print(byte line, char *msg)
{
  byte i;
  lcd.cursorTo(line + 1, 0);
  lcd.printIn(msg);
}