Pauly, Asynclabs
I had a play as I had an lcd and power supply to hand.
Its not just tweeting that causes the problem.
Ive included my sketch below.
It should serve a hello world page with a hit count and display the Wifi connection status and hit count on the lcd.
I hooked up a 2x16 lcd using the liquidcrystal library and a modified simpleserver example.
Using the wiserver option in apps-conf.h
I got the garbage on the lcd until I started changing the pins about for the lcd.
LiquidCrystal lcd(0, 1, 4, 5, 6, 7, 8);
This works and displays on the LCD anything you print from setup() and serves up a web page.
But nothing is being printed to the lcd from within loop().
and some strange characters get printed at random locations on the lcd.
If I used pins 2 or 3 it just put garbage on the lcd so the Wishield is using these.
10 - 13 are used for the spi interface.
I have the interrupt jumper set to Int0 so that is why pin2 cant be used.
Ive used pin8 for data bus 7 on the lcd, so the jumper is isolating that pin.
Why pin3 is a problem, I dont know, the schematic on the Async wiki doesnt show it connected to anything.
Is it being referenced in the libraries when it shouldnt be?
I hooked up an additional 5v supply for the LCD to test to see if its the power consumption.
Same result, nothing on the lcd from within the loop and some strange characters.
So something to do with the Wishield or Wishield library is interfering with the LiquidCrystal library
after WiServer.server_task() is called.
Is pin3 a clue?
Are there other pins referenced by mistake maybe and conflicting with the liquid crystal library pins?
I hope this helps AsyncLabs.
Gordon
/*
* A simple sketch that uses WiServer to serve a web page
* and an lcd to show status and hits
*/
#include <WiServer.h>
#include <LiquidCrystal.h>
// initialize with the numbers of the interface pins
LiquidCrystal lcd(0, 1, 4, 5, 6, 7, 9);
// page hit count
int count = 0;
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,231}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"ssid"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"xxxxxxxxxx"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------
// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
// Check if the requested URL sets bleeper on
if (strcmp(URL, "/") == 0) {
// Use WiServer's print and println functions to write out the page content
WiServer.print("<html>");
WiServer.print("Hello world
");
WiServer.print(count);
WiServer.print(" Hits");
WiServer.print("</html>");
count++;
return true;
}
// URL not found
return false;
}
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Connecting");
// Initialize WiServer and have it use the sendMyPage function to serve pages
WiServer.init(sendMyPage);
// display connected on the lcd
lcd.setCursor(0, 0);
lcd.print("Connected!");
lcd.setCursor(0, 1);
// print the number of hits
lcd.print(count);
lcd.print(" Hits");
// Enable Serial output and ask WiServer to generate log messages (optional)
Serial.begin(57600);
WiServer.enableVerboseMode(true);
}
void loop(){
// Run WiServer
WiServer.server_task();
//Serial.print("Loop");
// This is not working with the wishield
lcd.setCursor(0, 1);
// print the number of hits
lcd.print(count);
}