Search for Timeout in Topics

555 timeout troubles?

Evening all,  This is most likely a very basic problem but for the life of me I can't find the solution. The project: auto folding wing mirrors (see below);=attach&section;=attach&attach;_id=6108 The problem: for some reason my alarm logic is the opposite way round, most likely due to the removal of my motion sensor due to it tripping my alarm when locked. Now I have modified the circuit shown in the PDF to remove TR2 and R4 so the I/P to the 555 is kept high by the 12v alarm signal. I have a pot between pin 2 and ground so I can adjust the pull down point as the alarm signal only drops to 9.7V and, obviously, the 555 needs logic high or low. So, having adjusted the pull down point, I find that the 5 second timeout, which worked when I first built the circuit as per the PDF, no longer switches the O/P off.  So so what am I doing wrong or is it just best to us a picaxe to do all of this as I code write up the code in half an hour or so. thanks

Question by LED Maestro    |  last reply

I cannot get into Etsy- this is a problem!

Everytime I try to get to my store, or even the main page, i get a connection timeout response. But everything else is working fine, i clearly am connected to the internet. I tried upgrading my Firefox, tried deleting my cookies, and nothing works. I really need to do work on my etsy, and this is not helping! Anyone? Thank you! this is the msg- "Connection Interrupted The connection to the server was reset while the page was loading. The network link was interrupted while negotiating a connection. Please try again."

Topic by gildedpeach  

Extend logged in time to at least a week

If at all feasible, could you please extend the logged in timeout to be at least a week? I get the newsletter once a week and I click on links to the articles I'd like to read more. I then go back and read them only to find I have to log in and then refresh every article I want to read. I'm sure the refreshing takes up more bandwidth and memory than keeping my session in place for seven days or so. I have checked the 'keep me logged in' option but it only works for a couple of days. Thanks!

Topic by tchansen    |  last reply

Constantly being logged out of instructables

Ubuntu linux 11.10 Chrome browser version 18.0.1025.168 How long is the timeout before you have to sign in to instructables again? I log in, have a look around, head off for a short while (as little as an hour in the last case) and I am forced to log in again. Why not allow "Log in forever"? It can't be for security reasons as autocomplete has my information and I just click login anyway, I would just rather not be forced to click login when I go to a new page, which takes me back to the homepage and forces me to go  [<-] back, [<-] back, [F5] refresh, and then click on the link I clicked in the first place.

Topic by gregoryfenton    |  last reply

Arduino Mega 2560 timeout? Answered

I have tried uploading the simple "Blink" sketch onto a 5v Mega Pro from Spakrfun using their 5v FTDI programmer. Despite my best efforts I have kept getting this error... Binary sketch size: 1,632 bytes (of a 258,048 byte maximum) avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_getsync(): timeout communicating with programmer I have know I am using the correct COM port and I have the right board selected. I have tried to re-install the driver but to no avail. Nothing I have found online has worked.

Question by GenAap    |  last reply

What is the duration of Instructibles login sessions

Hello, I visit the Instructables website about 2-3 times per month (every 10 days or so), and it seems like EVERY time I do I need to login again. Even "Amazon" - and they're a commercial site - is better at "remembering me than Instructables. This is not actually a technical problem, but more of a question about Instructables policy (and also, it's a site complaint). (I can almost guarantee someone's going to misread my question so I'll say again... NOT a request for help. Yes I have cookies and JS on, and yes I'm using a good browser, Chrome.) It seems like I have to login every 4-7 days, possibly sooner, which is fracking annoying. If  there a better place to post site feedback, please be gentle, I did not find it before posting.  Thanks. (And despite my complaint, I love love love this website, it's in my top 5 favorites).

Topic by scottinnh    |  last reply


What they said, "Something Like The Power Failed" Binary, "000000000000000000100000000000000000"  t00 many Zeros. Religion,"Our Revered Deities Unloaded On Us Members" Members, "Lithium Rain posted" splazem & dombeef Cooked ;-D Blog Robot, "The Robot Was Sick Due to Bad Lube" New Owner "First clumsy effort to install pay per view sadw" Conspiracy "Inscrutable's Turn for Gov Spy Ware Install Day" K'nexers,  "Working Together Inserted Room Sized Router in Dallas" Technical, "It Was The Customer's Fault" Customers, "It Was The Company's Fault" Electrical, "Supply Redundant 10A Feeds To a 12A User ???!!!??" Goth, "Too Much UV Light" Mechanical, "Micro Quakes Let Dust Seep Into Card Edge Separating Mated Electrical Contacts" Shaving Creme, "Road Apples Came Down to Sting UP The Place" Wiring, "Temporary Fix Rewired as Technically Permanent Fix" BUGS, "Finally They Added" ATS, "Could Be Repaired (They do Fail) Replacement Safety Is Paramount" 503, "Was The Correct Error of The Wrong Day" Path, "Our Collective TAO Had a Gopher's Holiday Trip" Attack, "A Mythbusters Tack Was Found further Along The way" Don't Ever Believe the Simple ! Anything Else, "Sure Missed Some Bad Ones Sorry" Please Give The Reason You Believe It Was ? A

Topic by iceng    |  last reply runs slow - Server problems?

I noticed that is running quite slow for some days now. I also receive tons of timeouts - is this a (known) server problem?  Many thanks in advance! NrDesign

Topic by nrdesign    |  last reply

clicking on links in email from instructables causes timeouts and lockups

I love getting the email from Instructables showing new things I can build. Unfortunately clicking on the links from within the email sends my computer into a tizzy. My computer locks up. If I wait long enough, part of the page shows up and then it blanks out completely and tells me the page couldn't be found. Ocassionally another website shows up instead!!? Perhaps it's because my connection is slow, though I don't have this problem with other links in my email. And I don't have this problem if I go to Instructables directly. Still, I try everytime I get your email. Most of the time, I have to go directly to and search for the topic on the email. Most of the time I find it within several minutes (it takes longer if there are more than one that match my search) I don't have this problem with links in my usual email. Just from Instructables. I've run several anti virus scanners - AVG and Norton - they both show I'm clean. Is anyone else having this problem? Or is it just me? Thanks, Joan

Topic by jroco    |  last reply

Serin command with picaxes? Answered

Well i noticed that with the serin command that if it doesn't receive anything it just hangs their on the command. and i was wondering if anyone knows how to set some sort of timeout.

Question by wee_man    |  last reply

Problems downloading a class pdf?

It has come to our attention that some of our class PDF's are broken due to an internal timeout during the process requesting the assets to build the pdf with since it is requesting all lesson material at once.known problem class pdf:Wearable-Electronics-Classif you are experiencing this issue with a class pdf not downloading properly and you recieving a zero byte file, please try downloading the lessons individually.

Topic by mmmelroy    |  last reply

Comments unavailable.

When I try and make comments, or reply to comments, the comments box doesn't appear. Instead, I get a faint grey 503 message, and the processing icon overlaying it and not stopping for several minutes (at which point I get bored and hit the back button). (And while I tried to post a screen-shot, I twice got the error 504 Gateway Timeout) Edit: see also

Topic by Kiteman    |  last reply

How can I make a transmitter time-out timer?

 I am a ham, and would like to make a circuit that will alert me when my transmission has gone for about 2 minutes and 45 seconds, so that I can reset before the repeater's timeout does. I should be able to get the button press from my headset easily. How can I build a circuit like this that will start when I press the ptt and reset when I release?

Question by The Nate Dawg    |  last reply

What is the best way to control a computer by mouse from approx. 10-15 ft away? Is it possible? Answered

I've been looking for a way to use my mouse to control an old computer that I was looking to hook up to my tv. I had taken a look at using the mouse over ethernet cable, but according to discussion on that instructable, mouse won't work at that distance due to a timeout issue. WHat is the best way to control the computer by my tv, by mouse, from my couch?

Question by RCS82    |  last reply

Help starting out with nrf24L01+ transceiver and arduino

Recently I bought 6 nrf24L01+ boards like this with the intention of experimenting with them to potentially be embedded in some projects as a low cost solution to wireless communication. so far I've had some luck but nothing consistent. the test set up right now is an arduino uno and a arduino on a bread board. most of the information I used is from here. so far I get mostly failed communication and timeouts pretty much the same as what is listed here. I feel like this is a one sided issue where one arduino will send out information but it won't read it back in even if something is sent back. hopefully someone can help shed some light on this dilemma because it seems like a reacquiring problem with no solution. Thanks for any help in advance.

Question by Nman120    |  last reply

Arduino & Android UDP communications?

I have an arduino running a UDP server program and it works fine. I have been able to confirm it receives data and responds with a string by using an app which sends & receives UDP messages. I am trying to run a UDP client on an android tablet through Eclipse (java). I have imported and and Eclipse does not show any errors with the code. The software seems to timeout after a long period when the following line is executed: Socket mySkt = new Socket("",8888); .......even though this is the IP address and port I am able to confirm through the app. Does anyone have any ideas or very easy sample code to get this to work? Or are there any ways of testing the socket connection? Thanks,

Question by anth_trace    |  last reply

Missing Instructable and time out issues

As usual i'm still having problems with my session timing out after about 15 to 20 minutes on Win XP and Google chrome. Now one of my instructables is not showing up anywhere other then my profile. It was posted on the 15th, featured minutes later as was on the main page on the 16th. Now it doesn't show up on the technology main page or the USB sub page like it should. I've done all the usual things of clearing the cache, restarting the browser and all of that. Still the timeout issues persists. At work i don't seem to have this problem with session timing out. But i'm on Win 7 systems running fire fox. I would be running Chrome but have been unable to install it on the work PCs. 

Topic by mpilchfamily    |  last reply

Problem editing steps

Hi there. I'm having difficult recently trying to edit my instructable. When I try to edit any of the steps, it goes to save the intro even though I didn't edit it and the screens fades a bit to save. I can see the progress wheel turning, but it never stops. I pulled up the Error console and it gave me this: JavaScript - Inline script compilation Syntax error while loading: line 6 of inline script at : Expected token: ')' aterials that I used:Building supplies" Cardboard (thick) Make sure it is rigid" Cardboard (thin)" -------------------------------------------------^ JavaScript - Timeout thread: delay 10 ms Error: name: SyntaxError message: Statement on line 495: Syntax error stacktrace: n/a; see  opera:config#UserPrefs|Exceptions Have Stacktrace I have no idea what any of this means. I tried on Safari,  Firefox and Opera and all three gave me the same problems. The instructable in questions is: Thanks for looking into this.

Topic by Incrxtc    |  last reply

why i get the following error 'QTR_NO_EMITTER_PIN' was not declared in this scope?

Here is my code: #include #define NUM_SENSORS   1     // number of sensors used #define TIMEOUT       2500  // waits for 2500 us for sensor outputs to go low #define DETECT_LEVEL  150   // Sensor needs to change this amount for detection #define TRIGGER_COUNT 10    // Wait n successive readings valid detection // Create instance of sensors. We are only using one sensor connected to pin 12 PololuQTRSensorsRC qtrrc((unsigned char[]){12}, NUM_SENSORS,TIMEOUT,QTR_NO_EMITTER_PIN); unsigned int sensorValues[NUM_SENSORS]; unsigned int sensorValuesBase[NUM_SENSORS]; unsigned int detect_count[NUM_SENSORS];    // Number of successive times sensor                                            // has detected a drop in value. If                                            // this is greater than trigger_count                                            // then white line detected // Setup pins for SN754410 Motor chip int lf = 6;      // Left motor Forward int lr = 5;      // Left motor Reverse int rf = 11;     // Right motor Forward int rr = 10;     // Right motor Reverse int led = 3;    // LED and resistor across pins 2 and 3 int led_gnd = 2; unsigned char line_detect=1; unsigned char do_turn=0; void setup()  {   pinMode(led, OUTPUT);   pinMode(led_gnd, OUTPUT);     digitalWrite(led_gnd, LOW);    // LED ground     pinMode(13, OUTPUT);   digitalWrite(13, HIGH);        // turn on Sensor   //Read and store the baseline values;    sensorValuesBase[0] = sensorValues[0];    } void loop()  {     if(line_detect==1){       // Line Detect is enabled;     if(sensorValues[0] < (sensorValuesBase[0]- DETECT_LEVEL)) {       // Detected drop on value - brighter object detected       detect_count[0]++;   // incerment count       if(detect_count[0] >= TRIGGER_COUNT) {         // White Line detected         detect_count[0]=0;          // Reset count         do_turn=1;                  // Start the turn         digitalWrite(led, HIGH);    // turn on LED              line_detect=0;              // Turn off detection until turn complete               // Come to s stop         analogWrite(lf, 0);                 analogWrite(rf, 0);         analogWrite(lr, 0);                 analogWrite(rr, 0);              delay(200);            }      }     else {       detect_count[0]=0;     }    }   if(do_turn==1){     //Turn right a bit to avoid obstacle     analogWrite(lr, 0);         analogWrite(rf, 0);     analogWrite(lf, 200);     analogWrite(rr, 200);           delay(500);                // Turn for half a second     line_detect=1;             // turn line_detect back on     do_turn=0;                 // turn off     digitalWrite(led, LOW);    // turn off Led   }   else {     // go forward until we detect something     // Forward     analogWrite(lr, 0);             analogWrite(rr, 0);     analogWrite(lf, 250);             analogWrite(rf, 250);       } } i add the library and it appear in sketch import library?

Question by hayhackerall    |  last reply

ITEADLIB_Arduino_WeeESP8266 android response

Im planing to do a project that using Arduino+esp8266 with android device, at first my code was something like this. #include #define DEBUG true SoftwareSerial esp8266(9,10); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.                          // This means that you need to connect the TX line from the esp to the Arduino's pin 2                          // and the RX line from the esp to the Arduino's pin 3 void setup() {   Serial.begin(9600);   esp8266.begin(9600); // your esp's baud rate might be different   pinMode(11,OUTPUT);   digitalWrite(11,LOW);   pinMode(12,OUTPUT);   digitalWrite(12,LOW);   pinMode(13,OUTPUT);   digitalWrite(13,LOW);   pinMode(10,OUTPUT);   digitalWrite(10,LOW);   sendCommand("AT+RST\r\n",2000,DEBUG); // reset module   sendCommand("AT+CWMODE=1\r\n",1000,DEBUG); // configure as access point   sendCommand("AT+CWJAP=\"Arsalan Wifi\",\"arsalan123\"\r\n",3000,DEBUG);   delay(10000);   sendCommand("AT+CIFSR\r\n",1000,DEBUG); // get ip address   sendCommand("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections   sendCommand("AT+CIPSERVER=1,8080\r\n",1000,DEBUG); // turn on server on port 80   Serial.println("Server Ready"); } void loop() {   if(esp8266.available()) // check if the esp is sending a message   {     if(esp8266.find("+IPD,"))     {      delay(1000); // wait for the serial buffer to fill up (read all the serial data)      // get the connection id so that we can then disconnect      int connectionId =; // subtract 48 because the read() function returns                                        // the ASCII decimal value and 0 (the first decimal number) starts at 48      esp8266.find("pin="); // advance cursor to "pin="      int pinNumber = (; // get first number i.e. if the pin 13 then the 1st number is 1      int secondNumber = (;      if(secondNumber>=0 && secondNumber<=9)      {       pinNumber*=10;       pinNumber +=secondNumber; // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number      }      digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin         String content;      content = "چراغ ";      content += pinNumber;      content += " is ";      if(digitalRead(pinNumber))      {        content += "ON";      }      else      {        content += "OFF";      }      sendHTTPResponse(connectionId,content);      // make close command      String closeCommand = "AT+CIPCLOSE=";      closeCommand+=connectionId; // append connection id      closeCommand+="\r\n";      sendCommand(closeCommand,1000,DEBUG); // close connection      Serial.print(connectionID);     }   } } /* * Name: sendData * Description: Function used to send data to ESP8266. * Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no) * Returns: The response from the esp8266 (if there is a reponse) */ String sendData(String command, const int timeout, boolean debug) {     String response = "";     int dataSize = command.length();     char data[dataSize];     command.toCharArray(data,dataSize);     esp8266.write(data,dataSize); // send the read character to the esp8266     if(debug)     {       Serial.println("\r\n====== HTTP Response From Arduino ======");       Serial.write(data,dataSize);       Serial.println("\r\n========================================");     }     long int time = millis();     while( (time+timeout) > millis())     {       while(esp8266.available())       {         // The esp has data so display its output to the serial window         char c =; // read the next character.         response+=c;       }      }     if(debug)     {       Serial.print(response);     }     return response; } /* * Name: sendHTTPResponse * Description: Function that sends HTTP 200, HTML UTF-8 response */ void sendHTTPResponse(int connectionId, String content) {      // build HTTP response      String httpResponse;      String httpHeader;      // HTTP Header      httpHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n";      httpHeader += "Content-Length: ";      httpHeader += content.length();      httpHeader += "\r\n";      httpHeader +="Connection: close\r\n\r\n";      httpResponse = httpHeader + content + " "; // There is a bug in this code: the last character of "content" is not sent, I cheated by adding this extra space      sendCIPData(connectionId,httpResponse); } /* * Name: sendCIPDATA * Description: sends a CIPSEND=, command * */ void sendCIPData(int connectionId, String data) {    String cipSend = "AT+CIPSEND=";    cipSend += connectionId;    cipSend += ",";    cipSend +=data.length();    cipSend +="\r\n";    sendCommand(cipSend,1000,DEBUG);    sendData(data,1000,DEBUG); } /* * Name: sendCommand * Description: Function used to send data to ESP8266. * Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no) * Returns: The response from the esp8266 (if there is a reponse) */ String sendCommand(String command, const int timeout, boolean debug) {     String response = "";     esp8266.print(command); // send the read character to the esp8266     long int time = millis();     while( (time+timeout) > millis())     {       while(esp8266.available())       {         // The esp has data so display its output to the serial window         char c =; // read the next character.         response+=c;       }      }     if(debug)     {       Serial.print(response);     }     return response; } but then i chose to use library code for esp8266 and i use this link ITEADLIB_Arduino_WeeESP8266 now i have problem that i dont know how can i get a response message back to my android device, also this is my code using library, (i know its really noobish code cuz im new but... it work atleast :D ) #include #include "ESP8266.h" #include #include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //moshakhas kardane pin haye LCD SoftwareSerial mySerial(7, 8); // moshakhas kardane pin haye wifi ESP8266 wifi(mySerial); String msg; #define SSID        "Arsalan Wifi"  //UserName wifi #define PASSWORD    "arsalan123"  //Password wifi String pinnum; int count= 0; void setup() {   lcd.begin(20, 4);       Serial.begin(9600);   pinMode(9,OUTPUT);   digitalWrite(9,HIGH);   String IP;   Serial.print("setup begin\r\n");   lcd.print("Connecting to Wifi");   delay(3000);   Serial.print("FW Version: ");   //  Serial.println(wifi.getVersion().c_str());         if (wifi.setOprToStation()) {         Serial.print("to station ok\r\n");     } else {         Serial.print("to station err\r\n");     }     if (wifi.joinAP(SSID, PASSWORD)) {         Serial.print("Join AP success\r\n");         Serial.print("IP: ");               Serial.println(wifi.getLocalIP().c_str());         IP = wifi.getLocalIP().c_str();         lcd.setCursor(0, 1);         lcd.print("Join AP success");         lcd.setCursor(0, 2);         lcd.print("IP: "+IP);     } else {         Serial.print("Join AP failure\r\n");         lcd.setCursor(0, 1);         lcd.print("Join AP failure");         lcd.setCursor(0, 2);         lcd.print("Contact Administrator");     }      if (wifi.enableMUX()) {         Serial.print("multiple ok\r\n");     } else {         Serial.print("multiple err\r\n");     }     if (wifi.startTCPServer(80)) {         Serial.print("start tcp server ok\r\n");         lcd.setCursor(0, 3);         lcd.print("Server Ready");     } else {         Serial.print("start tcp server err\r\n");         lcd.setCursor(0, 3);         lcd.print("Server Setup Fail");     }     if (wifi.setTCPServerTimeout(10)) {         Serial.print("set tcp server timout 10 seconds\r\n");     } else {         Serial.print("set tcp server timout err\r\n");     }           Serial.print("setup end\r\n"); } void loop() {    uint8_t buffer[128] = {0};     uint8_t mux_id;     uint32_t len = wifi.recv(&mux;_id, buffer, sizeof(buffer), 100);     if (len > 0) {         Serial.print("Status:[");         Serial.print(wifi.getIPStatus().c_str());         Serial.println("]");                 Serial.print("Received from :");         Serial.print(mux_id);         Serial.print("[");         for(uint32_t i = 0; i < len; i++) {             Serial.print((char)buffer[i]);             msg = "";             msg += ((char)buffer[i]);                         if (msg == "p")             {               count=1;                                         }                          if (msg != "p" & count ==1)             {               if(msg =="i")               {                                 count++;               }               else               {                                 count = 0;               }             }             if (msg !="i" & count ==2)             {               if (msg =="n")               {                 count++;               }               else               {                 count = 0;               }             }             if (msg !="n" & count ==3)             {               if(msg=="=")               {                 count++;                               }               else               {                 count = 0;               }             }             if (msg != "=" & count==4)             {               Serial.print(msg);               pinnum =msg;               count = 0;             }                     }         Serial.print(pinnum);         Serial.print("]\r\n");         int pin = pinnum.toInt();         Serial.print(pin);         digitalWrite(pin, !digitalRead(pin)); // toggle pin            String content;      content = "چراغ ";      content += pinnum;      content += " is ";           if(digitalRead(pin))      {        content += "ON";      }      else      {        content += "OFF";      }                 if(wifi.send(mux_id, buffer, len)) {             Serial.print("send back ok\r\n");         } else {             Serial.print("send back err\r\n");         }                 if (wifi.releaseTCP(mux_id)) {             Serial.print("release tcp ");             Serial.print(mux_id);             Serial.println(" ok");         } else {             Serial.print("release tcp");             Serial.print(mux_id);             Serial.println(" err");         }                 Serial.print("Status:[");         Serial.print(wifi.getIPStatus().c_str());         Serial.println("]");     }   }

Question by Arsalan Ahmadi    |  last reply

instructables Email Newsletter: Links will not work.

For the past three email newsletters that I've received from intructables, the links will not work properly. In the past, I've always been able to click on a link and have it appear fine in my Internet Explorer 7 using Windows XP. All updates/patches have been applied to the system I use as it is a Department of Defense computer. Here is an example link: attempting to connect for about 10 seconds ("Connecting...") this message appears:Network Access Message: The website cannot be found Explanation: There was no response to the name resolution request. As a result the IP address for the website you requested could not be found. Try the following: Refresh page: Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion. Check spelling: Check that you typed the Web page address correctly. The address may have been mistyped. Access from a link: If there is a link to the page you are looking for, try accessing the page from that link. If you are still not able to view the requested page, try contacting your administrator or Helpdesk. Technical Information (for support personnel) Error Code 11002: Host not found Background: This error indicates that the gateway could not find an authoritative DNS server for the website you are trying to access. Date: 11/6/2008 3:27:10 PM [GMT] Server: Source: DNS problemPlease advise. Thanks!

Topic by brendangillespie  

Error 500 when posting a comment

Hi there, I tried to post a comment for a recent multitouch instructable.I wrote my message and clicked submit. After a while, I got a page about error 500.The error text was:ERROR 500: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch updateThe Exception text was:Exceptionorg.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.handledNonSpecificException( at org.hibernate.exception.SQLStateConverter.convert( at org.hibernate.exception.JDBCExceptionHelper.convert( at org.hibernate.jdbc.AbstractBatcher.executeBatch( at org.hibernate.jdbc.AbstractBatcher.prepareStatement( at org.hibernate.jdbc.AbstractBatcher.prepareStatement( at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement( at org.hibernate.persister.entity.AbstractEntityPersister.insert( at org.hibernate.persister.entity.AbstractEntityPersister.insert( at org.hibernate.action.EntityInsertAction.execute( at org.hibernate.engine.ActionQueue.execute( at org.hibernate.engine.ActionQueue.executeActions( at org.hibernate.engine.ActionQueue.executeActions( at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions( at org.hibernate.event.def.DefaultFlushEventListener.onFlush( at org.hibernate.impl.SessionImpl.flush( at org.hibernate.impl.SessionImpl.managedFlush( at org.hibernate.transaction.JDBCTransaction.commit( at com.instructables.transaction.TransactionHandler.invoke( at $Proxy4.addComment(Unknown Source) at com.instructables.webapp.edit.PostCommentAction.process( at com.instructables.servlet.ActionServlet.process( at com.instructables.servlet.ActionServlet.doPost( at com.instructables.webapp.edit.EditServlet.doPost( at javax.servlet.http.HttpServlet.service( at com.instructables.servlet.InstructHttpServlet.service( at javax.servlet.http.HttpServlet.service( at com.caucho.server.dispatch.ServletFilterChain.doFilter( at com.instructables.filter.SecurityFilter.doFilter( at com.caucho.server.dispatch.FilterFilterChain.doFilter( at com.instructables.filter.HibernateSessionRequestFilter.doFilter( at com.caucho.server.dispatch.FilterFilterChain.doFilter( at com.caucho.server.webapp.WebAppFilterChain.doFilter( at com.caucho.server.dispatch.ServletInvocation.service( at com.caucho.server.http.HttpRequest.handleRequest( at at com.caucho.util.ThreadPool.runTasks( at at by: java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transaction at com.mysql.jdbc.ServerPreparedStatement.executeBatch( at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch( at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( at org.hibernate.jdbc.AbstractBatcher.executeBatch( ... 35 moreJust FYI :)

Topic by nolodude  

Serial communication between PC and picaxe 28X2

Hi, I am having problem in communicating with PC with Picaxe 28x2. Please help me in solving this problem as it is a very important project My aim is to send the values of w1 and w2 variables ( values of the ultrasonic range sensors 1 and 2 ) to the PC and display them with the help of VB my picaxe code is ..., #picaxe 28x2 main: pulsout C.1,2 pulsin C.1,1,w1 pause 10 pulsout C.2,2 pulsin C.2,1,w2 pause 10 sertxd(#w1,#w2) pause 100 goto main and my VB code is , Imports System.IO Imports Strings = Microsoft.VisualBasic Public Class Form1 Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer) Dim WithEvents serialPort As New IO.Ports.SerialPort Dim PicaxeRegisters(0 To 1) As Byte Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Timer1.Enabled = True Timer1.Interval = 5000 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Call SerialTxRx() End Sub Sub SerialTxRx() Dim labelstring As String = "" Label1.Text = "" If serialPort.IsOpen Then serialPort.Close() End If Try With serialPort .PortName = "COM1" .BaudRate = 9600 .Parity = IO.Ports.Parity.None .DataBits = 8 ' 8 bits .StopBits = IO.Ports.StopBits.One .ReadTimeout = 1000 .Open() .Read(PicaxeRegisters, 0, 2) .Close() End With For i = 0 To 1 labelstring = labelstring + " " + Str(PicaxeRegisters(i)) Next Label1.Text = labelstring Catch ex As Exception MsgBox(ex.ToString) Label1.Text = "Timeout" End Try End Sub End Class I have not included the write command, since I have not included qualifiers in the picaxe code. The Picaxe chip is sending the values ( I used the terminal in picaxe programming editor to realise this) but the visual basic is not displaying me the actual values sent by the picaxe chip. It is showing random values instead ... So i think that there is an error in the VB code. PLEASE HELP AS SOON AS POSSIBLE .. Thank You 

Topic by santhoshR  

Stepper motor working with nrf51dk (problem with timer i think)

Hello everyone, I am trying to make a program that makes work a stepper motor 28BYJ-48, my stepper motor is well connected to the ULN2003 and the ULN2003 is well connected to my nrf51dk, here is a picture of my setup : foloowed this tutorial and it worked with my Arduino, so I guess the problem is not coming from there.I am now making a program using the nrf51dk, I am using nrf51_sdk_10.0.0 and the ble_app_uart as an example, my project is to control the motor via Bluetooth.But for the moment I just would like to make the motor I follow the same principe of code as in the tutorial for making it work.I need a timer, so I also followed the "Application timer tutorial" from nordic is my code that I Added to the ble_app_uart project ://At the top I define the differents gpios that I will have to use//and step_number that is a variable use to navigate threw the differents steps for the motor to work int step_number = 0; #define motorPin1 1 #define motorPin2 2 #define motorPin3 3 #define motorPin4 4 #define APP_TIMER_PRESCALER 15 /**< Value of the RTC1 PRESCALER register. */ #define APP_TIMER_OP_QUEUE_SIZE 5 /**< Size of timer operation queues. */ //I add 4 different timers, one for each pin APP_TIMER_DEF(timer_step1); APP_TIMER_DEF(timer_step2); APP_TIMER_DEF(timer_step3); APP_TIMER_DEF(timer_step4); . . . //the code already defined in the existing project//Timeout handler for the repeated timer //I need 4 timeout handler, one foreach motorPin static void timer_a_handler(void * p_context) { nrf_drv_gpiote_out_toggle(motorPin1); } static void timer_b_handler(void * p_context) { nrf_drv_gpiote_out_toggle(motorPin2); } static void timer_c_handler(void * p_context) { nrf_drv_gpiote_out_toggle(motorPin3); } static void timer_d_handler(void * p_context) { nrf_drv_gpiote_out_toggle(motorPin4); } //Then I create the timers // Create timers static void create_timers() { uint32_t err_code1; uint32_t err_code2; uint32_t err_code3; uint32_t err_code4; // Create timers err_code1 = app_timer_create(&timer;_step1, APP_TIMER_MODE_REPEATED, timer_a_handler); APP_ERROR_CHECK(err_code1); err_code2 = app_timer_create(&timer;_step2, APP_TIMER_MODE_REPEATED, timer_b_handler); APP_ERROR_CHECK(err_code2); err_code3 = app_timer_create(&timer;_step3, APP_TIMER_MODE_REPEATED, timer_c_handler); APP_ERROR_CHECK(err_code3); err_code4 = app_timer_create(&timer;_step4, APP_TIMER_MODE_REPEATED, timer_c_handler); APP_ERROR_CHECK(err_code4); } //And here is my main //with the loop to make work the motor the same way I did with the arduino, but adapting the code int main(void) { uint32_t err_code; uint32_t err_code1; uint32_t err_code2; uint32_t err_code3; uint32_t err_code4; bool erase_bonds; uint8_t start_string[] = START_STRING; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); uart_init(); buttons_leds_init(&erase;_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); printf("%s",start_string); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); create_timers(); nrf_gpio_pin_dir_set(motorPin1, NRF_GPIO_PIN_DIR_OUTPUT); nrf_gpio_pin_dir_set(motorPin2, NRF_GPIO_PIN_DIR_OUTPUT); nrf_gpio_pin_dir_set(motorPin3, NRF_GPIO_PIN_DIR_OUTPUT); nrf_gpio_pin_dir_set(motorPin4, NRF_GPIO_PIN_DIR_OUTPUT); // Enter main loop. for (;;) { uint8_t str1[1] = "1"; uint8_t str2[1] = "2"; uint8_t str3[1] = "3"; uint8_t str4[1] = "4"; switch(step_number){ case 0: err_code1 = app_timer_start(timer_step1, APP_TIMER_TICKS(200, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code1); err_code2 = app_timer_stop(timer_step2); APP_ERROR_CHECK(err_code2); err_code3 = app_timer_stop(timer_step3); APP_ERROR_CHECK(err_code3); err_code4 = app_timer_stop(timer_step4); APP_ERROR_CHECK(err_code4); ble_nus_string_send(&m;_nus, str1, strlen((char*)str1)); break; case 1: err_code1 = app_timer_stop(timer_step1); APP_ERROR_CHECK(err_code1); err_code2 = app_timer_start(timer_step2, APP_TIMER_TICKS(200, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code2); err_code3 = app_timer_stop(timer_step3); APP_ERROR_CHECK(err_code3); err_code4 = app_timer_stop(timer_step4); APP_ERROR_CHECK(err_code4); ble_nus_string_send(&m;_nus, str2, strlen((char*)str2)); break; case 2: err_code1 = app_timer_stop(timer_step1); APP_ERROR_CHECK(err_code1); err_code2 = app_timer_stop(timer_step2); APP_ERROR_CHECK(err_code2); err_code3 = app_timer_start(timer_step3, APP_TIMER_TICKS(200, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code3); err_code4 = app_timer_stop(timer_step4); APP_ERROR_CHECK(err_code4); ble_nus_string_send(&m;_nus, str3, strlen((char*)str3)); break; case 3: err_code1 = app_timer_stop(timer_step1); APP_ERROR_CHECK(err_code1); err_code2 = app_timer_stop(timer_step2); APP_ERROR_CHECK(err_code2); err_code3 = app_timer_stop(timer_step3); APP_ERROR_CHECK(err_code3); err_code4 = app_timer_start(timer_step4, APP_TIMER_TICKS(200, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code4); ble_nus_string_send(&m;_nus, str4, strlen((char*)str4)); break; } step_number++; if(step_number > 3){ step_number = 0; } power_manage(); } }Probably I am doing Something wrong with the timer, because when I modify it and decide to use it with a led for testing like in the tutorial, the motor makes noise but doesn't move and the led works. If someone can help, it's been hours I am on this problem and I can't find my mistakes.

Topic by BenjaminP106  

techy w00tness - a day of computer tech guy

Some1 brought the following quote to another forum i am inits sure been copy pasted alot of times before me. the original author is unknownI was working in a job running the campus email system some years ago when I got a call from the chairman of the statistics department. "We're having a problem sending email out of the department." "What's the problem?" I asked. "We can't send mail more than 500 miles," the chairman explained. I choked on my latte. "Come again?" "We can't send mail farther than 500 miles from here," he repeated. "A little bit more, actually. Call it 520 miles. But no farther." "Um... Email really doesn't work that way, generally," I said, trying to keep panic out of my voice. One doesn't display panic when speaking to a department chairman, even of a relatively impoverished department like statistics. "What makes you think you can't send mail more than 500 miles?" "It's not what I *think*," the chairman replied testily. "You see, when we first noticed this happening, a few days ago--" "You waited a few DAYS?" I interrupted, a tremor tinging my voice. "And you couldn't send email this whole time?" "We could send email. Just not more than--" "--500 miles, yes," I finished for him, "I got that. But why didn't you call earlier?" "Well, we hadn't collected enough data to be sure of what was going on until just now." Right. This is the chairman of *statistics*. "Anyway, I asked one of the geostatisticians to look into it--" "Geostatisticians..." "--yes, and she's produced a map showing the radius within which we can send email to be slightly more than 500 miles. There are a number of destinations within that radius that we can't reach, either, or reach sporadically, but we can never email farther than this radius." "I see," I said, and put my head in my hands. "When did this start? A few days ago, you said, but did anything change in your systems at that time?" "Well, the consultant came in and patched our server and rebooted it. But I called him, and he said he didn't touch the mail system." "Okay, let me take a look, and I'll call you back," I said, scarcely believing that I was playing along. It wasn't April Fool's Day. I tried to remember if someone owed me a practical joke. I logged into their department's server, and sent a few test mails. This was in the Research Triangle of North Carolina, and a test mail to my own account was delivered without a hitch. Ditto for one sent to Richmond, and Atlanta, and Washington. Another to Princeton (400 miles) worked. But then I tried to send an email to Memphis (600 miles). It failed. Boston, failed. Detroit, failed. I got out my address book and started trying to narrow this down. New York (420 miles) worked, but Providence (580 miles) failed. I was beginning to wonder if I had lost my sanity. I tried emailing a friend who lived in North Carolina, but whose ISP was in Seattle. Thankfully, it failed. If the problem had had to do with the geography of the human recipient and not his mail server, I think I would have broken down in tears. Having established that--unbelievably--the problem as reported was true, and repeatable, I took a look at the file. It looked fairly normal. In fact, it looked familiar. I diffed it against the in my home directory. It hadn't been altered--it was a I had written. And I was fairly certain I hadn't enabled the "FAIL_MAIL_OVER_500_MILES" option. At a loss, I telnetted into the SMTP port. The server happily responded with a SunOS sendmail banner. Wait a minute... a SunOS sendmail banner? At the time, Sun was still shipping Sendmail 5 with its operating system, even though Sendmail 8 was fairly mature. Being a good system administrator, I had standardized on Sendmail 8. And also being a good system administrator, I had written a that used the nice long self-documenting option and variable names available in Sendmail 8 rather than the cryptic punctuation-mark codes that had been used in Sendmail 5. The pieces fell into place, all at once, and I again choked on the dregs of my now-cold latte. When the consultant had "patched the server," he had apparently upgraded the version of SunOS, and in so doing *downgraded* Sendmail. The upgrade helpfully left the alone, even though it was now the wrong version. It so happens that Sendmail 5--at least, the version that Sun shipped, which had some tweaks--could deal with the Sendmail 8, as most of the rules had at that point remained unaltered. But the new long configuration options--those it saw as junk, and skipped. And the sendmail binary had no defaults compiled in for most of these, so, finding no suitable settings in the file, they were set to zero. One of the settings that was set to zero was the timeout to connect to the remote SMTP server. Some experimentation established that on this particular machine with its typical load, a zero timeout would abort a connect call in slightly over three milliseconds. An odd feature of our campus network at the time was that it was 100% switched. An outgoing packet wouldn't incur a router delay until hitting the POP and reaching a router on the far side. So time to connect to a lightly-loaded remote host on a nearby network would actually largely be governed by the speed of light distance to the destination rather than by incidental router delays. Feeling slightly giddy, I typed into my shell: $ units 1311 units, 63 prefixes You have: 3 millilightseconds You want: miles 558.84719 / 0.0017893979 "500 miles, or a little bit more."

Topic by 11010010110  

Help for realising a linefollower tankbot

Hello, I want to realize a linefollowing tank bot. I got this following parts: - Arduino Mega 2560 - Arduino MotorShield Rev03 - Pololu QTR-8RC Array - Pololu RP5 Tankchassis (6V DC Motors) Now all parts are together and the code must be completed. Therefore I found a really nice PID-based tutorial for linefollower: I create a program, but after calibrating the sensors, the bot doesn't drive on the line. It makes no sense were it drives. Most time it do 90° turns and so on. Do you find a better solution for my code? [code] #include #include   /////////////////////////// // define constants   // /////////////////////////// #define AUTO_CALIB  false      // Autokalibrierung aktivieren #define DEBUG_ENABLE   true               // false=keine Serial Ausgaben #define NUM_SENSORS    8                  // Anzahl der verwendeten Sensoren #define TIMEOUT        2500               // waits for 2500 microseconds for sensor outputs to go low #define EMITTER_PIN    QTR_NO_EMITTER_PIN         // Default: kein Emitterpin definiert #define MOTOR_SPEED    100               // PWM Signal 0-255 (Basismotorgeschwindigkeit) #define MOTOR_MAX_SPEED 255       // PWM Signal für Maximalgeschwindigkeit #define KP     0.2                    // KP-Wert für PID Regler #define KD     5                     // KD-Wert für PID Regler ( Beachte: Kp < Kd) #define SERVO_PIN1  11       // PWM Ausgang für Servo1 #define SERVO_PIN2  12       // PWM Ausgang für Servo2 #define CALIB_LED   13       // LED Ausgang für Kalibrierungsphase ////////////////////////// // define variables     // ////////////////////////// // Zuweisung der Sensoren 0-7 an die digitalen IO's 22-29 QTRSensorsRC qtrrc((unsigned char[]) {22, 23, 24, 25, 26, 27, 28, 29}, NUM_SENSORS, TIMEOUT, EMITTER_PIN); unsigned int sensorValues[NUM_SENSORS]; int MotorLeftSpeed=3;                  // PWM pin for speed control left int MotorRightSpeed=11;                // PWM pin for speed control right int MotorLeftDirection=12;            // digital pin for direction control left int MotorRightDirection=13;            // digital pin for direction control right int MotorLeftBrake=9;                  // digital pin for brake control left int MotorRightBrake=8;                 // digital pin for brake control right int lastError = 0; ///////////////////// // Initialisierung // ///////////////////// void setup() {     // Initialisierung verschiedner IOs   pinMode(CALIB_LED, OUTPUT);    // Definiert LED Ausgang für Kalibierungsphase       // Initialisierung linker Motor   pinMode(MotorLeftDirection, OUTPUT);      // Definiert Ausgang für den linken Motor   pinMode(MotorLeftBrake, OUTPUT);          // Definiert Bremse für den linken Motor   pinMode(MotorLeftSpeed, OUTPUT);   // Definiert Geschwindigkeitsausgang für linken Motor   // Initialisierung rechter Motor   pinMode(MotorRightDirection, OUTPUT);     // Definiert Ausgang für den rechten Motor   pinMode(MotorRightBrake, OUTPUT);         // Definiert Bremse für den rechten Motor     // Initialisierung Servo Motoren   servo1.attach(SERVO_PIN1);     // Zuweisung PWM PIN für Servo1   servo2.attach(SERVO_PIN2);     // Zuweisung PWM PIN für Servo2   if (DEBUG_ENABLE)   {    Serial.begin(9600);    Serial.print("Debug Modus aktiviert:\n");     }     delay(500);     digitalWrite(CALIB_LED, HIGH);    // turn on Arduino's LED to indicate we are in calibration mode   for (int i = 0; i < 400; i++)   // make the calibration take about 10 seconds   {     qtrrc.calibrate();           // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call)   } delay(20);      // The 20 ms delay in the calibration code is intended to make the routine take a reasonable amount of time.     digitalWrite(CALIB_LED, LOW);     // turn off Arduino's LED to indicate we are through with calibration       if (DEBUG_ENABLE)    {    // print the calibration minimum values measured when emitters were on       for (int i = 0; i < NUM_SENSORS; i++)    {   Serial.print(qtrrc.calibratedMinimumOn[i]);   Serial.print(' ');    }    Serial.println();       // print the calibration maximum values measured when emitters were on    for (int i = 0; i < NUM_SENSORS; i++)    {   Serial.print(qtrrc.calibratedMaximumOn[i]);   Serial.print(' ');    }    Serial.println();    Serial.println();   }   delay(1000);   } /////////////////// // Main Program  // /////////////////// void loop() {   // read calibrated sensor values and obtain a measure of the line position from 0 to 5000 // To get raw sensor values, call: //; instead of unsigned int position = qtrrc.readLine(sensorValues); // Variable positon zeigt die genaue Position (0-7000) an   unsigned int position = qtrrc.readLine(sensorValues); // get calibrated readings along with the line position, refer to the QTR Sensors Arduino Library for more details on line position. int error = position - 3500;  // 3500 is the desired position   if (DEBUG_ENABLE)   {    // print the sensor values as numbers from 0 to 1000, where 0 means maximum reflectance and    // 1000 means minimum reflectance, followed by the line position    for (unsigned char i = 0; i < NUM_SENSORS; i++)    {     Serial.print(sensorValues[i]);     Serial.print('\t');    }    Serial.print(position);    // comment this line out if you are using raw values   } int motorSpeed = KP * error + KD * (error - lastError); lastError = error; int rightMotorSpeed = MOTOR_SPEED + motorSpeed; int leftMotorSpeed  = MOTOR_SPEED - motorSpeed;     if (rightMotorSpeed > MOTOR_MAX_SPEED ) rightMotorSpeed = MOTOR_MAX_SPEED;    // Verhindert dass die Maximalgeschwindigkeit überschritten wird if (leftMotorSpeed > MOTOR_MAX_SPEED ) leftMotorSpeed  = MOTOR_MAX_SPEED;    // Verhindert dass die Maximalgeschwindigkeit überschritten wird if (rightMotorSpeed < 0) rightMotorSpeed  = 0;          // Verhindert einen negativen Geschwindigkeitswert if (leftMotorSpeed < 0) leftMotorSpeed   = 0;          // Verhindert einen negativen Geschwindigkeitswert   {   // Ansteuerung der Motoren durch PID Berechnung   digitalWrite(MotorRightBrake, LOW);     // Motorbremse rechts deaktivieren   digitalWrite(MotorLeftBrake, LOW);     // Motorbremse links deaktivieren   digitalWrite(MotorRightDirection, HIGH);   // Motor rechts im Uhrzeigersinn  --> fährt vorwärts   digitalWrite(MotorLeftDirection, LOW);    // Motor links gegen den Uhrzeigersinn  --> fährt vorwärts   analogWrite(MotorRightSpeed, rightMotorSpeed);  // Motorgeschwindigkeit rechts in Abhängigkeit des PID Reglers   analogWrite(MotorLeftSpeed, leftMotorSpeed);  // Motorgeschwindigkeit links in Abhängigkeit des PID Reglers }           } [/code]

Topic by julianpe    |  last reply

A advanced Arduino calculator?

So I thought about a new project: make an "advanced" calculator since online there are plenty of tutorials of simple ones. I have done already the circuit and I have only some problems with the code since this is only my third project on Arduino and I don't  know programming in C. So basically: when I switch on the device it shows me a long text which I can scroll using a pair of pushbuttons(when the text can't scroll anymore a led switches on). When I push them contemporanealy the device switches to calculator. And this is the code I made (I know there are plenty of errors): #include #include long num1,num2 ; double total; char operation,button; const byte ROWS = 4; const byte COLS = 4; char keys[ROWS][COLS] = {   {'1','2','3','+'},   {'4','5','6','-'},   {'7','8','9','*'},   {'C','0','=','/'} }; byte rowPins[ROWS] = {A0,A1,A2,A3}; //connect to the row pinouts of the keypad byte colPins[COLS] = {A4,A5,0,1}; //connect to the column pinouts of the keypad Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); // === CONSTANTS AND GLOBALS === // -- PINS -- const int PIN_LCD_LED = 6;  // analog const int PIN_ERR_LED = 7;  // digital const int PIN_BUTTON1 = 8;  // digital const int PIN_BUTTON2 = 9;  // digital // -- LCD -- // PIN 12   -> RS // PIN 11   -> Enable // PINS 2-5 -> D4-7 LiquidCrystal lcd(12, 11, 2, 3, 4, 5); // number of columns in the LCD const int LCD_COLS = 16; // LCD brightness [0, 255] const int LCD_BRIGHTNESS = 128; // LCD ON or OFF int state_lcd = LOW; // start position for text int lcd_start = 0; // -- LED -- // LOW -> LED is OFF - HIGH -> LED is ON int state_led = LOW; // stores time when turned LED on unsigned long t0_led; // timeout to turn the LED off const int LED_TIMEOUT = 500; // -- text to print -- // ASSUMPTION: text always longer than LCD_COLS, if not add a check in loop const char TEXT[] = "After trying Helloworld I made this more advanced version..."; const int TEXT_LEN = (sizeof(TEXT) / sizeof(char)) - 1; const int LCD_LIMIT = TEXT_LEN - LCD_COLS; // === CONSTANTS AND GLOBALS END === // === INITIALIZATION === void setup() {   // -- SET DIGITAL PINS --   pinMode(PIN_BUTTON1, INPUT);   pinMode(PIN_BUTTON2, INPUT);   pinMode(PIN_ERR_LED, OUTPUT);   // -- SET UP LCD --   lcd.begin(16,2);   lcd.noDisplay();   digitalWrite(PIN_LCD_LED, state_lcd);   // ERROR LED is off when starting   digitalWrite(PIN_ERR_LED, state_led);   // -- read buttons --   int state_button1 = digitalRead(PIN_BUTTON1);   int state_button2 = digitalRead(PIN_BUTTON2);     // pushed button 1 -> try to scroll left or turn LED on if can't     if(HIGH == state_button1)     {       if(lcd_start > 0)       {         lcd_start--;         state_led = LOW;         digitalWrite(PIN_ERR_LED, state_led);         delay(200);       }       else       {         state_led = HIGH;         digitalWrite(PIN_ERR_LED, state_led);         t0_led = millis();       }     }     // pushed button 2 -> try to scroll right or turn LED on if can't     if(HIGH == state_button2)     {       if(lcd_start < LCD_LIMIT)       {         lcd_start++;         state_led = LOW;         digitalWrite(PIN_ERR_LED, state_led);         delay(200);       }       else       {         state_led = HIGH;         digitalWrite(PIN_ERR_LED, state_led);         t0_led = millis();       }     }     // -- print text on the LCD --     for(int i = 0; i < LCD_COLS; i++)     {       lcd.setCursor(i, 0);       lcd.print(TEXT[lcd_start + i]);     }     // ERROR LED is ON     if(HIGH == state_led)     {       unsigned long td = millis() - t0_led;       // LED has been ON for more than LED_TIMEOUT ms. -> turn it OFF       if(td > LED_TIMEOUT)       {         state_led = LOW;         digitalWrite(PIN_ERR_LED, state_led);       }     }   }   // normally 20FPS   // === INITIALIZATION END === // === MAIN LOOP === void loop() {   // == LCD STILL OFF ==   if(HIGH == state_lcd)   {     // pushing both buttons -> turn LCD on     int state_button1 = digitalRead(PIN_BUTTON1);     int state_button2 = digitalRead(PIN_BUTTON2);         if(HIGH == state_button1 && HIGH == state_button2)     {       analogWrite(PIN_LCD_LED, LCD_BRIGHTNESS);       lcd.display();       state_lcd = HIGH;       delay(250);     }   }     else  // == LCD ON ==   {     // Loops are convenient for reading key press from keypad     while(1) // First loop. Here we read keypad and compose our first number. It does so untill we press operation button and break's out of loop or 'C' and it starts from beginning of this loop     {                 button = customKeypad.getKey(); // Button read         if (button=='C') // If user wants to resset while he is writing first number         {           num1=0;           num2=0;           total=0;           operation=0;           lcd.clear();         }                 if (button >='0' && button <='9') // If user pressed numeric value, 1 character at a time.         {           num1 = num1*10 + (button -'0'); // Our numeric values are 0-9 witch means they are in first decade, when we multiply with 10 we basicaly add zero after number,           // than we add a new number entered to that zero spot. As for (button -'0') this is simple ASCII table "trick" 0...9 in ASCII table are 48 ... 57,           // so by subtracting '0' from any of them we get their value in decade system ex. char '5' = 53 in decade numeric system minus 48 for zero char gives us value of actual 5,           // if our previous number was ex. 25 we get 250 by multiplying it with 10 and then we add 5 and we get 255 witch gets printed on LCD.           lcd.setCursor(0,0); // Select first row on lcd           lcd.print(num1); // Print current number1         }         if (num1 !=0 && (button=='-' || button=='+' || button=='*' || button=='/')) // If user is done inputing numbers         {           operation = button; // operation remembers what mathematical operation user wants on numbers           lcd.setCursor(0,1); // set cursor to row 2           lcd.print(operation); // print our operator           break;         }     }         while(1) // Second while loop, it loops untill user has pressed '=' or 'C'. so it either prints total or ressets program     {         if (button =='C'){break;} // This covers case where user pressed operator and still wants to reset         button = customKeypad.getKey();         if (button=='C') // Making sure user wants to reset at anytime         {           num1=0;           num2=0;           total=0;           operation=0;           lcd.clear();           break;         }         if (button >='0' && button <='9') // Getting chars from keypad for number 2         {           num2 = num2*10 + (button -'0');           lcd.setCursor(1,1);           lcd.print(num2);         }         if (button == '=' && num2 !=0)// If button pressed was '=' its the end of the road. Calls domath() subroutine does calculation and print our results         {           domath();                              break;          }     }     while(1)     {       // After all is done this loop waits for 'C' key to be pressed so it can reset program and start over.       if (button =='C'){break;} // This line is side effect of previous loop since if user pressed 'C' it breaks out of previous loop and continues here.So we need to break this one aswell or user would need to press 'C' 2 times       button = customKeypad.getKey();       if (button =='C')         {            lcd.clear();            lcd.setCursor(0,0);            num1=0;            num2=0;            total=0;            operation=0;            break;         }     } } void domath() // Simple switch case to pick what operation to do, based on button pressed by user. {   switch(operation)     {       case '+': // Addition           total = num1+num2;           break;             case '-': // Subtraction           total = num1-num2;           break;             case '/': // Division. Could add error for division by zero, or change line in second loop where it waits for '=' char to if (button == '=' && num2 != 0) this will halt program untill num2 is not zero and then continue           total = (float)num1/(float)num2;           break;             case '*': // Multiplication           total = num1*num2;           break;               }     // Based on case selected print our total and     lcd.setCursor(0,1);     lcd.print('=');     lcd.setCursor(1,1);     lcd.print(total);       } } // === MAIN LOOP END === Waiting your answers, Cristian

Question by IlirD2    |  last reply