|
469
|
Using Arduino / Programming Questions / Re: convert serial string to long
|
on: March 11, 2013, 02:42:59 pm
|
Question, why are you doing it this way? decodeGS232(Serial.read()); //Serial read normally returns an int, but you want a char and not this way? char Data = Serial.read(); // Some way to store multiple chars in one array. // Use an array,store the chars if new data is available and have a terminating char to tell // it to stop storing data and send it out to the function. decodeGS232(Data);
Instead of doing process from int to char the long way, let the IDE do it. Just make the variable from the serial read a CHAR type and then manually insert a NULL char to then use atol() No?
|
|
|
|
|
474
|
Using Arduino / Project Guidance / Re: Switching Control Signal
|
on: March 10, 2013, 11:02:17 pm
|
|
Your circuit is so so, its not the correct way to do it, but it may work. I can tell you, you will need a pull down resistor. 4.7K should be enough.
Look up the proper way to use transistors.
|
|
|
|
|
477
|
Using Arduino / Project Guidance / Re: Ardunio with Android
|
on: March 10, 2013, 01:26:08 am
|
|
Well your not sending it directly to the Arduino, but to the Bluetooth or wifi adapter. Any Arduino will work, especially the Mega with ADK. You need to first learn Java and start with a simple sketch that will work in the serial monitor. If it works there, it will work with an android.
|
|
|
|
|
478
|
Using Arduino / Programming Questions / Re: LCD and Keypad help
|
on: March 10, 2013, 12:50:29 am
|
Here, /* || @version 1.0 || @author Andrew Mascolo || || @description || Simple use of keypad, password and LCD */ #include <Keypad.h> #include <Wire.h> #include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,20,4); char Data[20]; // 20 is the number of chars it can hold char Master[] = { '1','3','5','4','2','6'}; int currentCommand = 0; boolean good; char customKey;
const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS] = { { '1','2','3' } , { '4','5','6' } , { '7','8','9' } , { '*','0','#' } }; byte rowPins[ROWS] = { 2,3,4,5}; //connect to the row pinouts of the keypad byte colPins[COLS] = { 10,9,8}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup(){ lcd.init(); // initialize the lcd lcd.backlight(); }
void loop(){ lcd.setCursor(0,0); lcd.print("Enter Password"); customKey = customKeypad.getKey(); if (customKey){ Data[currentCommand] = customKey; lcd.setCursor(currentCommand,1); lcd.print(Data[currentCommand]); currentCommand++; }
if(currentCommand == 6){ delay(1000); for(int count = 0; count < currentCommand; count++){ if(Data[count] == Master[count]) { good = true; } else { good = false; break; } }
lcd.setCursor(0,0); if(good) { lcd.clear(); lcd.print("Password is good"); delay(1000); lcd.clear(); clearData(); } else { lcd.clear(); lcd.print("Password is bad"); delay(1000); lcd.clear(); clearData(); } } if(customKey == '*'){ lcd.clear(); lcd.setCursor(0,0); lcd.print("Change Password"); clearData(); while(customKey != '#'){ customKey = customKeypad.getKey(); if (customKey){ Master[currentCommand] = customKey; lcd.setCursor(currentCommand,1); lcd.print(Master[currentCommand]); currentCommand++; } } if(customKey == '#') { lcd.clear(); lcd.setCursor(0,0); lcd.print("Master is reset"); delay(1000); clearData(); lcd.clear(); } } } void clearData() { while(currentCommand !=0){ // This can be used for any array size, Data[currentCommand--] = 0; //clear for new data } return; }
|
|
|
|
|
479
|
Using Arduino / Programming Questions / Re: LCD and Keypad help
|
on: March 10, 2013, 12:06:59 am
|
|
It does not go in the loop, it goes outside the loop. And if you put it in there, it will not work. Just set current command back to when your done with it the first time. I'll post me updated code later, and just learn from that.
|
|
|
|
|