Im really hoping someone can help me here - I am due to show a piece of work at a museum opening tomorrow and my installation has stopped working!
Im using the original version of the wifly shield from sparkfun to connect to a local server. The piece has been working perfectly for a number of years, but recently I had to transfer everything server side onto a new machine with a new ip address - this should be easy to handle with the arduino!
However the code was written pre-arduino 1 and some of the libraries/syntax are no longer supported.
Ive tried downloading old IDEs and also to update the code to the new arduino 1.0.4 im running but I cant get any success
Please help!
Here is the original code:
#include <NewSoftSerial.h>
// (Based on Ethernet's WebClient Example)
#include "WiFly.h"
#include "Credentials.h"
#define rxPin 6
#define txPin 7
NewSoftSerial printer = NewSoftSerial(rxPin, txPin);
const byte command = 0x1B;
const byte fullcut = 0x69;
byte server[] = {
192,168,0,10 }; // Google
//Client client(server, 80);
Client client("192.168.0.10", 80);
int pot = A1;
int searchButton = 2;
int potVal = 0;
int buttonVal = 0;
String web;
char c;
int index = 0;
void setup() {
pinMode(pot, INPUT);
pinMode(searchButton, INPUT);
pinMode(12, OUTPUT);
printer.begin(9600);
Serial.begin(9600);
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
}
void printOnPrinter(char text[]) {
printer.print(text);
}
void feed() {
printer.println("");
printer.println("");
printer.println("");
}
void cut() {
printer.print(command, BYTE);
printer.print(fullcut, BYTE);
}
void loop() {
buttonVal = digitalRead(searchButton);
if(buttonVal == 1){
digitalWrite(12, HIGH);
delay(3000);
digitalWrite(12, LOW);
int potVal = analogRead(pot);
potVal = map(potVal, 0, 950, 1, 5);
Serial.println(potVal);
if(potVal==1) {
web = "GET /nameTest1.php HTTP/1.0";
}
if(potVal==2) {
web = "GET /nameTest2.php HTTP/1.0";
}
if(potVal==3) {
web = "GET /nameTest3.php HTTP/1.0";
}
if(potVal==4) {
web = "GET /nameTest4.php HTTP/1.0";
}
if(potVal==5) {
web = "GET /nameTest5.php HTTP/1.0";
}
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println(web);
client.println();
}
else {
Serial.println("connection failed");
}
do{
char c = client.read();
if(c == '
And here Ive tried to modernise it without any joy:
#include <SoftwareSerial.h>
//#include <NewSoftSerial.h>
// (Based on Ethernet's WebClient Example)
#include "WiFly.h"
#include "Credentials.h"
#define rxPin 6
#define txPin 7
SoftwareSerial printer = SoftwareSerial(rxPin, txPin);
const byte command = 0x1B;
const byte fullcut = 0x69;
byte server[] = {
192,168,0,10 }; // Google
//Client client(server, 80);
Client client("192.168.0.10", 80);
int pot = A1;
int searchButton = 2;
int potVal = 0;
int buttonVal = 0;
String web;
char c;
int index = 0;
void setup() {
pinMode(pot, INPUT);
pinMode(searchButton, INPUT);
pinMode(12, OUTPUT);
printer.begin(9600);
Serial.begin(9600);
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
}
void printOnPrinter(char text[]) {
printer.print(text);
}
void feed() {
printer.println("");
printer.println("");
printer.println("");
}
void cut() {
printer.print(byte (command));
printer.print(byte (fullcut));
}
void loop() {
buttonVal = digitalRead(searchButton);
if(buttonVal == 1){
digitalWrite(12, HIGH);
delay(3000);
digitalWrite(12, LOW);
int potVal = analogRead(pot);
potVal = map(potVal, 0, 950, 1, 5);
Serial.println(potVal);
if(potVal==1) {
web = "GET /nameTest1.php HTTP/1.0";
}
if(potVal==2) {
web = "GET /nameTest2.php HTTP/1.0";
}
if(potVal==3) {
web = "GET /nameTest3.php HTTP/1.0";
}
if(potVal==4) {
web = "GET /nameTest4.php HTTP/1.0";
}
if(potVal==5) {
web = "GET /nameTest5.php HTTP/1.0";
}
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println(web);
client.println();
}
else {
Serial.println("connection failed");
}
do{
char c = client.read();
if(c == '
){
break;
}
if(index == 540){
printer.print(c);
}
else{
index++;
}
}
while( c != '
And here Ive tried to modernise it without any joy:
§DISCOURSE_HOISTED_CODE_1§
);
if (client.connected()) {
digitalWrite(12, LOW);
Serial.println();
Serial.println("disconnecting.");
client.stop();
feed();
feed();
cut();
feed();
feed();
// feed();
index = 0;
// for(;;);
}
}
}
And here Ive tried to modernise it without any joy:
§_DISCOURSE_HOISTED_CODE_1_§
){
break;
}
if(index == 540){
printer.print(c);
}
else{
index++;
}
}
while( c != '
){
break;
}
if(index == 540){
printer.print(c);
}
else{
index++;
}
}
while( c != '
And here Ive tried to modernise it without any joy:
§_DISCOURSE_HOISTED_CODE_1_§
);
if (client.connected()) {
digitalWrite(12, LOW);
Serial.println();
Serial.println("disconnecting.");
client.stop();
feed();
feed();
cut();
feed();
feed();
// feed();
index = 0;
// for(;;);
}
}
}
And here Ive tried to modernise it without any joy:
§DISCOURSE_HOISTED_CODE_1§
);
if (client.connected()) {
digitalWrite(12, LOW);
Serial.println();
Serial.println("disconnecting.");
client.stop();
feed();
feed();
cut();
feed();
feed();
// feed();
index = 0;
// for(;;);
}
}
}
){
break;
}
if(index == 540){
printer.print(c);
}
else{
index++;
}
}
while( c != '
And here Ive tried to modernise it without any joy:
§DISCOURSE_HOISTED_CODE_1§
);
if (client.connected()) {
digitalWrite(12, LOW);
Serial.println();
Serial.println("disconnecting.");
client.stop();
feed();
feed();
cut();
feed();
feed();
// feed();
index = 0;
// for(;;);
}
}
}
And here Ive tried to modernise it without any joy:
§_DISCOURSE_HOISTED_CODE_1_§