Delta, PA USA
Offline
Newbie
Karma: 0
Posts: 30
I'm Lost !!
|
 |
« Reply #15 on: December 13, 2012, 08:17:52 pm » |
Folks... I APPRECIATE ALL OF THE INPUT... I am totally at a loss so please accept my appreciation for your knowledge..
Is there any tutorials for what I am trying to do?. I can say I have looked but with no success
|
|
|
|
|
Logged
|
I'm Lost !! At least on the Arduino...
|
|
|
|
Delta, PA USA
Offline
Newbie
Karma: 0
Posts: 30
I'm Lost !!
|
 |
« Reply #16 on: December 13, 2012, 08:21:05 pm » |
In layman's terms, what is this doing? if (key != '*'){ keyIn += key;
|
|
|
|
|
Logged
|
I'm Lost !! At least on the Arduino...
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 29
Posts: 1574
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #17 on: December 13, 2012, 08:25:02 pm » |
If key does not see * then it is going to keep adding the pressed digits to the string, and when it does see * then it puts out the data.
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Delta, PA USA
Offline
Newbie
Karma: 0
Posts: 30
I'm Lost !!
|
 |
« Reply #18 on: December 13, 2012, 08:26:58 pm » |
Ok..I learned something today... THANKS.. for some reason I can not get any digits to appear except when the * is pushed I get a 0 on the LCD
|
|
|
|
|
Logged
|
I'm Lost !! At least on the Arduino...
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 29
Posts: 1574
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #19 on: December 13, 2012, 08:32:55 pm » |
I think the reason you get 0 on the LCD is because of the NoKey function, I think it is constantly filling and overfilling the string with zeros, when nothing is pressed.
I could be wrong.
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Delta, PA USA
Offline
Newbie
Karma: 0
Posts: 30
I'm Lost !!
|
 |
« Reply #20 on: December 13, 2012, 08:35:31 pm » |
HazardsMind... For what it's worth... When I look on the term, I see about 30 seconds worth of 0's then random characters.. all this time, the TX LED is lit on the Mega
|
|
|
|
|
Logged
|
I'm Lost !! At least on the Arduino...
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 29
Posts: 1574
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #21 on: December 13, 2012, 10:47:27 pm » |
Here this is what I tried to do, it does not have anything to do with KEYPAD, but it may give you a little push. int currentCommand = 0; char Data[256];
void setup() { Serial.begin(9600); }
void loop() { if( Serial.available()) // if data is available to read { char c= Serial.read(); if (c == '.'){ long i=atol(Data); Serial.println(i); Serial.println(currentCommand); while(currentCommand !=0){ Data[currentCommand--] = 0; } } else { Data[currentCommand++] = c; } } }
Im still trying to figure out the Keypad code, myself.
|
|
|
|
« Last Edit: December 14, 2012, 05:55:34 am by HazardsMind »
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35519
Seattle, WA USA
|
 |
« Reply #22 on: December 14, 2012, 01:14:09 am » |
The getKey() method is NOT a blocking function. Most of the time when it is called, no key is being pressed, so the return value is NO_KEY. You need to add another if statement after the call to getKey(): char key = keypad.getKey(); if(key != NO_KEY) // Do nothing is no key is pressed { if (key != '*') { keyIn += key; } else { // The else stuff } }
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 29
Posts: 1574
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #23 on: December 14, 2012, 08:10:39 am » |
Ok this should work with the added NO_KEY condition //these two need to go at the top of the screen int currentCommand = 0; char Data[2];
void loop(){ if(key != NO_KEY) // Do nothing if no key is pressed, incorporated from PaulS's example. { char key = keypad.getKey(); if (key != '*'){ Data[currentCommand++] = key; }
else { int keyIn = atoi(Data); lcd.begin(16,0); lcd.setCursor(6,0); lcd.print(keyIn); lcd.print(" "); Serial.println(keyIn); while(currentCommand !=0){ // This can be used for any array size, Data[currentCommand--] = 0; //clear for new data } } } }
|
|
|
|
« Last Edit: December 14, 2012, 09:19:06 am by HazardsMind »
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35519
Seattle, WA USA
|
 |
« Reply #24 on: December 14, 2012, 11:24:45 am » |
Ok this should work with the added NO_KEY condition Did you even try compiling this? if(key != NO_KEY) // Do nothing if no key is pressed, incorporated from PaulS's example. { char key = keypad.getKey(); if (key != '*'){ Data[currentCommand++] = key; } You can't test a variable before you have valued it, or even declared it.
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 29
Posts: 1574
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #25 on: December 14, 2012, 11:46:59 am » |
what is not declaired? oh I see, I put the char key = keypad.getKey(); inside the if statement. Yea I didn't compile it, I dont have my laptop with me today, but im sure he would have caught and fixed it himself. @dcr_inc change it to this: char key = keypad.getKey(); // put it above the nokey if statement.
if(key != NO_KEY) // Do nothing if no key is pressed, incorporated from PaulS's example. { if (key != '*'){ Data[currentCommand++] = key; }
|
|
|
|
« Last Edit: December 14, 2012, 11:53:24 am by HazardsMind »
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Delta, PA USA
Offline
Newbie
Karma: 0
Posts: 30
I'm Lost !!
|
 |
« Reply #26 on: December 14, 2012, 09:39:02 pm » |
Thanks again for all of your help...
I will upload this code and see if I can make it do what I need..
I only wish I could get the hang of this language... I can do ladder logic but cant seem to grasp this..
Thanks again
|
|
|
|
|
Logged
|
I'm Lost !! At least on the Arduino...
|
|
|
|
Malaysia
Offline
Sr. Member
Karma: 7
Posts: 385
|
 |
« Reply #27 on: December 14, 2012, 09:42:27 pm » |
i understand your problem dcr_inc. i am also well verse in PLC programming.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35519
Seattle, WA USA
|
 |
« Reply #28 on: December 15, 2012, 11:17:38 am » |
I can do ladder logic Climb a ladder. It wobbles and tilts. Where's the logic in that?
|
|
|
|
|
Logged
|
|
|
|
|
Malaysia
Offline
Sr. Member
Karma: 7
Posts: 385
|
 |
« Reply #29 on: December 15, 2012, 11:26:31 am » |
actually dcr_inc after almost a half a year of trying to study arduino and how to relate it back to PLC, i think had found the solution, I am now able to make all the basic input ,output, keep, delay on, counter with arduino as we could use in PLC. I have also just recently discovered that a State diagram and Timing diagram could be easily implemented in arduino other then that, Shift function in PLC can also be use in arduino
this however is slightly different that just using the ladder diagram,it use words but hay I'm trying to make function that we(PLC programmer) could use to help use the same logic use in PLC to be use in arduino.
|
|
|
|
|
Logged
|
|
|
|
|
|