smá arduino kóði sem errorar
Sent: Fim 09. Jan 2014 22:41
er bara ekki að fatta þennan error, skil hreinlega ekki hvað compilerinn er að biðja um
gætuð þið verið svo elskulegir að hjálpa mér ?
veit vel að það eru til betri aðferðir til að gera þetta, er rétt að byrja að læra á þetta
er bara búinn að vera að fikta mig í að breyta og bæta við kóða ásamt að skrifa eitthvað sjálfur
arduinoið stýrir servo og led díóðu til að búa til kaffi fyrir mig á senseo vél(fyrir þá sem nenna ekki að skoða kóðann)
arduino_with_ethernet_shield.ino: In function 'void setup()':
arduino_with_ethernet_shield:35: error: expected primary-expression before '}' token
arduino_with_ethernet_shield:35: error: expected `;' before '}' token
gætuð þið verið svo elskulegir að hjálpa mér ?
veit vel að það eru til betri aðferðir til að gera þetta, er rétt að byrja að læra á þetta
er bara búinn að vera að fikta mig í að breyta og bæta við kóða ásamt að skrifa eitthvað sjálfur
arduinoið stýrir servo og led díóðu til að búa til kaffi fyrir mig á senseo vél(fyrir þá sem nenna ekki að skoða kóðann)
arduino_with_ethernet_shield.ino: In function 'void setup()':
arduino_with_ethernet_shield:35: error: expected primary-expression before '}' token
arduino_with_ethernet_shield:35: error: expected `;' before '}' token
Kóði: Velja allt
/*
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
int led = 5;
Servo microservo;
int pos = 0;
byte mac[] = { 0x**, 0x**, 0x**, 0x**, 0x**, 0x** }; //physical mac address
byte ip[] = { 192, 168, 1, 178 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
byte gateway[] = { 192, 168, 1, 254 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(*****); //server port
String readString;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
pinMode(led, OUTPUT);
microservo.attach(7);
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
Serial.println(
}
void loop()
{
// Create a client connection
EthernetClient client = server.available();
if (client)
{
while (client.connected())
{
if (client.available())
{
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100)
{
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n')
{
//Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html; charset=utf-8");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
client.println("<TITLE>kubburs automatic coffie machine</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>kubburs automatic coffie machine</H1>");
client.println("<hr />");
client.println("<br />");
client.println("<H2>Arduino with Ethernet Shield</H2>");
client.println("<br />");
client.println("<a href=\"/?button1on\"\">Turn On LED</a>");
client.println("<a href=\"/?button1off\"\">make me a coffie NOW</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<a href=\"/?button2on\"\">make me a coffie</a>");
client.println("<a href=\"/?button2off\"\">set to 90</a><br />");
client.println("<br />");
client.println("<br />");
client.println("<a href=\"/?button3n\"\">make me 2 coffies</a>");
client.println("<a href=\"/?button4\"\">make me 3 coffies</a><br />");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
//controls the Arduino if you press the buttons
if (readString.indexOf("?button1on") > 0)
{
Serial.println("blinking led ");
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
if (readString.indexOf("?button1off") > 0)
{
Serial.println("nothing is being done");
digitalWrite(led, HIGH);
Serial.println("beginning to make coffie");
microservo.write(90);
delay(1000);
microservo.write (67);
Serial.println("turning on coffie machine");
delay(600);
microservo.write(90);
Serial.println("heating water");
delay(21000);
microservo.write(120);
Serial.println("making coffie");
delay(200);
microservo.write(90);
delay(30000);
microservo.write(67);
Serial.println("turning off coffie machine");
delay(200);
microservo.write(90);
delay(1000);
Serial.println("coffie machine is off");
digitalWrite(led, LOW);
}
if (readString.indexOf("?button2on") > 0)
{
digitalWrite(led, HIGH);
Serial.println("beginning to make coffie");
microservo.write(90);
delay(1000);
microservo.write (67);
Serial.println("turning on coffie machine");
delay(600);
microservo.write(90);
Serial.println("heating water");
delay(100000);
microservo.write(120);
Serial.println("making coffie");
delay(200);
microservo.write(90);
delay(30000);
microservo.write(67);
Serial.println("turning off coffie machine");
delay(200);
microservo.write(90);
delay(1000);
Serial.println("coffie machine is off");
digitalWrite(led, LOW);
}
if (readString.indexOf("?button2off") > 0)
{
Serial.println("turning coffie machine on/off");
microservo.write(90);
delay (1000);
microservo.write(67);
delay(1000);
microservo.write(90);
delay(1000);
}
if (readString.indexOf("?button1on") > 0)
{
Serial.println("blinking led ");
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
if (readString.indexOf("?button3") > 0)
{
digitalWrite(led, HIGH);
Serial println("order received: 2 coffie cups");
Serial.println("beginning to make coffie");
microservo.write(90);
delay(1000);
microservo.write (67);
Serial.println("turning on coffie machine");
delay(600);
microservo.write(90);
Serial.println("heating water");
delay(100000);
microservo.write(120);
Serial.println("making coffie");
delay(400);
microservo.write(90);
delay(30000);
delay(21000);
microservo.write(120);
Serial.println("making coffie");
delay(400);
microservo.write(90);
delay(30000);
microservo.write(67);
Serial.println("turning off coffie machine");
delay(200);
microservo.write(90);
delay(1000);
Serial.println("coffie machine is off");
microservo.write(90);
delay(1000);
digitalWrite(led, LOW);
}
if (readString.indexOf("?button4") > 0)
{
digitalWrite(led, HIGH);
Serial println("order received: 3 coffie cups");
Serial.println("beginning to make coffie");
microservo.write(90);
delay(1000);
microservo.write (67);
Serial.println("turning on coffie machine");
delay(600);
microservo.write(90);
Serial.println("heating water");
delay(100000);
microservo.write(120);
Serial.println("making coffie");
delay(200);
microservo.write(90);
delay(30000);
delay(21000);
microservo.write(120);
Serial.println("making coffie");
delay(400);
microservo.write(90);
delay(30000);
delay(21000);
microservo.write(120);
Serial.println("making coffie");
delay(400);
microservo.write(90);
delay(30000);
microservo.write(67);
Serial.println("turning off coffie machine");
delay(200);
microservo.write(90);
delay(1000);
Serial.println("coffie machine is off");
digitalWrite(led, LOW);
}
//clearing string for next read
readString="";
}
}
}
}
}