Hi there, i am running this playground well http://playground.arduino.cc/ComponentLib/BarcodeScanner but i want make one change. In the code as you see, dataRead(); command always running in loop() . I want to run it when i want. But it doesn't work.

We've hired a psychic who will be able to determine what the code actually does without seeing it, and how that differs from what you want, without you having to describe that.

His start date is the 12th of never. If you need help before then, there are some things you need to do.

Here this point is not important maybe? Why not when i click a button wired to one of digital pins?The code is this http://playground.arduino.cc/uploads/ComponentLib/arduino-barcode-code.txt I just want to make run what have written in loop function (i.e. when i click a button) in the code above.I tried but it didn't work.

If you have written the code that reads a barcode when a button is pressed but it does not work please post it here with a description of what it does. In your skeleton code explaining what you want to do we do not know where the value of number comes from.

Please do not send me PMs asking for help. Post in the forum then everyone will benefit from seeing the questions and answers.

If you have written the code that reads a barcode when a button is pressed but it does not work please post it here with a description of what it does. In your skeleton code explaining what you want to do we do not know where the value of number comes from.

did you not understand ?

Please do not send me PMs asking for help. Post in the forum then everyone will benefit from seeing the questions and answers.

int dataRead() {byte val = 0; // Skip start state and start bit while (digitalRead(clockPin)); // Wait for LOW. // clock is high when idle while (!digitalRead(clockPin)); // Wait for HIGH. while (digitalRead(clockPin)); // Wait for LOW. for (int offset = 0; offset < 8; offset++) { while (digitalRead(clockPin)); // Wait for LOW val |= digitalRead(dataPin) << offset; // Add to byte while (!digitalRead(clockPin)); // Wait for HIGH } // Skipping parity and stop bits down here. while (digitalRead(clockPin)); // Wait for LOW. while (!digitalRead(clockPin)); // Wait for HIGH. while (digitalRead(clockPin)); // Wait for LOW. while (!digitalRead(clockPin)); // Wait for HIGH. return val; }void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do something about it: if (inChar == 'a') { number = 5; } if (inChar == 'b') { number = 1; } Serial.println(number); }}

And the problem is this, when i send 'a' to the arduino (so number being set to 5, i can see it via serial port viewer) screen freeze. When screen frozen if i use barcode scanner and make it scan a valid barcode code, screen blinks for 0.5 second (not exactly) then be frozen again.

int dataRead() { byte val = 0; // Skip start state and start bit while (digitalRead(clockPin)); // Wait for LOW. // clock is high when idle while (!digitalRead(clockPin)); // Wait for HIGH. while (digitalRead(clockPin)); // Wait for LOW. for (int offset = 0; offset < 8; offset++) { while (digitalRead(clockPin)); // Wait for LOW val |= digitalRead(dataPin) << offset; // Add to byte while (!digitalRead(clockPin)); // Wait for HIGH } // Skipping parity and stop bits down here. while (digitalRead(clockPin)); // Wait for LOW. while (!digitalRead(clockPin)); // Wait for HIGH. while (digitalRead(clockPin)); // Wait for LOW. while (!digitalRead(clockPin)); // Wait for HIGH. return val; }void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do something about it: //if user send 'a' command, set my lovely number 5 if (inChar == 'a') { number = 5; Serial.println(number); } if (inChar == 'b') { number = 1; Serial.println(number); }

}}

five is my lovely number. now its auto-formatted. now what i realised, draw2() never run. when number set 5, program get freeze. while screen frozen, if i scan a valid barcode with barcode scanner (it beep when read) Serial.println() works (prints 5) but draw2() doesn't work.