# rotary dail

hello i have a question

i have a rotary dail

and i use this to read it http://www.instructables.com/id/Interface-a-rotary-phone-dial-to-an-Arduino/

but now comes the problem i need to save 9 numbers in a variable and i cant seem to find out how to do this

i need this for an arduino phone i am building

in the end i have to dail +31 548 51**** (land city home)

can somone help me on this

rotary dail

Something to do with the Irish parliament on a turntable?

i dont get the joke ityped correctly right

or you just troll?

Yes, I’m just a troll, and no your typing is not good.

sorry i didnt ment to be harsh i am just realy dutch

i need to save 9 numbers in a variable and i cant seem to find out how to do this

Do some research on arrays.

somthing like

anArray[] = { var1,var2,var3 };

does that work?

if so

then i dont know how i can count 9 diverent variables

`char anArray[9];`gives you an array of 9 char variables from anArray[0] to anArray[8]

``````anArray[0] = '3';
anArray[1] = '5';
``````

puts characters into the first and second positions in the array and so on.

``````for (int x = 0; x< 9; x++)
{
Serial.println(anArray[x]);
}
``````

prints each of the elements of the array in turn.

mmm that will not be suficent

i need to sent the array as one complete number

i found this script it seems to store the complete number in one array

but i cant seem to print that

You're not making a great deal of sense. Send an array as a single number? You mean like a 19 decimal digit 64 bit number? Or as the ASCII representation of an arbitrary length number? You found what script?

i want to store single numbers as one giant aray

like i said i am dailing 1-2-3

arduino gives me 1 2 3

and i want it as 123

and then send it of to a gsm module and have it called this works but is verry verry crude

``````int needToPrint = 0;
int count;
// mine
const int try_it = 3;
const int in_from_dial = 2;
int test;

int buttonState = 0;         // variable for reading the pushbutton status
int firstnum = 0;
char played = 'N';
// end mine

int lastState = LOW;
int trueState = LOW;
long lastStateChangeTime = 0;
int cleared = 0;

// constants

int dialHasFinishedRotatingAfterMs = 100;
int debounceDelay = 10;

// strings
String newstring;

// --------------------------------------------

void setup()
{

Serial.begin(9600);

pinMode(in_from_dial, INPUT);  // 2
digitalWrite(in_from_dial, HIGH);
pinMode(try_it, INPUT);  // 3

pinMode(13, OUTPUT);    // 12

}

void loop(){
digitalWrite(13, HIGH);   // set the LED on
/*
user will dial numbers until they hit the "try it" buttonb
so need to create string until button is pressed
*/
// read the state of the tryit button

// try_it = HIGH;
if (buttonState == LOW)   {

if ((millis() - lastStateChangeTime) > dialHasFinishedRotatingAfterMs) {
// the dial isn't being dialed, or has just finished being dialed.
if (needToPrint) {
// if it's only just finished being dialed, we need to send the number down the serial
// line and reset the count. We mod the count by 10 because '0' will send 10 pulses.
Serial.println(count % 10, DEC);

// now need to add the count to the test string and then test it against the
// required string to get a hit
newstring.concat(count);

Serial.println(newstring);

needToPrint = 0;
count = 0;
cleared = 0;
}

}

lastStateChangeTime = millis();
}
if ((millis() - lastStateChangeTime) > debounceDelay) {
// debounce - this happens once it's stablized
// this means that the switch has either just gone from closed->open or vice versa.
if (trueState == HIGH) {
// increment the count of pulses if it's gone high.
count++;
needToPrint = 1; // we'll need to print this number (once the dial has finished rotating)
}
}
}
}

else
{
// now user wants to test his dialing
//
played = 'N';
//   Serial.println(newstring);
test_it();
newstring = "";

}
}
// --------------------- my functions -------------------------
// ------------------------------------------------------------

// --------------------------------------------------
// test the string

void test_it()
{

newstring = "";
loop();

}

// end of loop
``````

arduino gives me 1 2 3

and i want it as 123

So, don't use "println"

``````void test_it()
{

newstring = "";
loop();

}
``````

See recursion

yes but how does that work on the gsm module

it does not

the gsm module needs a full number

mySerial.println("ATD + +31611******;");//dial the number (this is in my call script)

I think you need to slow down, work through some basic examples, and start looking at your code after using the auto-format tool. You're misunderstanding some very basic programming constructs.

i have run trough all beginner courses

but non helps me in the way i want

OK, you need to point out the beginner course that suggested that recursion on a micro controller is a good idea, 'cos I'm going round to the author's house and I'm going to be jolly unpleasant to him.

please do come by if you want some coffie

i also found it out

how to dail-call and output

i am hooking up the gprs shield as we speak

and after testing it sends the corect caracter set
but it does not call
after adding a bit of line it suddenly works

onwards it should be not so hard anymore

``````#include <SoftwareSerial.h>
#include <String.h>

SoftwareSerial mySerial(7, 8);

int needToPrint = 0;
int count;
// mine
const int try_it = 3;
const int in_from_dial = 2;
int test;

int buttonState = 0;         // variable for reading the pushbutton status
int firstnum = 0;
char played = 'N';
// end mine

int lastState = LOW;
int trueState = LOW;
long lastStateChangeTime = 0;
int cleared = 0;

// constants

int dialHasFinishedRotatingAfterMs = 100;
int debounceDelay = 10;

// strings
String newstring;

void setup()
{

pinMode(in_from_dial, INPUT);  // 2
digitalWrite(in_from_dial, HIGH);
pinMode(try_it, INPUT);  // 3

pinMode(13, OUTPUT);    // 12
mySerial.begin(19200);               // the GPRS baud rate
Serial.begin(19200);    // the GPRS baud rate
delay(500);
}

void loop()
{

digitalWrite(13, HIGH);   // set the LED on
/*
user will dial numbers until they hit the "try it" buttonb
so need to create string until button is pressed
*/
// read the state of the tryit button

// try_it = HIGH;
if (buttonState == LOW)   {

if ((millis() - lastStateChangeTime) > dialHasFinishedRotatingAfterMs) {
// the dial isn't being dialed, or has just finished being dialed.
if (needToPrint) {
// if it's only just finished being dialed, we need to send the number down the serial
// line and reset the count. We mod the count by 10 because '0' will send 10 pulses.
Serial.println(count % 10, DEC);

// now need to add the count to the test string and then test it against the
// required string to get a hit
newstring.concat(count % 10);

Serial.println("ATD + +31" + newstring + ";");

needToPrint = 0;
count = 0;
cleared = 0;
}

}

lastStateChangeTime = millis();
}
if ((millis() - lastStateChangeTime) > debounceDelay) {
// debounce - this happens once it's stablized
// this means that the switch has either just gone from closed->open or vice versa.
if (trueState == HIGH) {
// increment the count of pulses if it's gone high.
count++;
needToPrint = 1; // we'll need to print this number (once the dial has finished rotating)
}
}
}
}

else
{
// now user wants to test his dialing
//
played = 'N';
//   Serial.println(newstring);
test_it();
newstring = "";

}

}

void test_it()
{
mySerial.println("ATD + +31" + newstring + ";");//dial the number
Serial.println("ATD + +31" + newstring + ";");//dial the number
delay(10000);
mySerial.println("ATH");
Serial.println("ATH");
newstring = "";
loop();

}

void ShowSerialData()
{
while(mySerial.available()!=0)
}
``````

sorry that i am such an pain in the ass somtimes

my learning proses involves learning from other people's work (why would we reinvent the wheel)

and that makes me a dick somtimes

the script i fabricated consists of 3 or 4 scripts made into one working (but crappy whole)

It's dial not dail and it's process not proses. Just helping your English spelling. ;)

You can't have "run through" even a few beginner courses if you don't understand a char array.

``````// this is an array of char. It is NULL permnated (the \0)
// make it big enough to hold one char more the largest number you will dial
// This one will hold 14 chars plus the NULL, so it's size is 15. You can also declare it as
//  char number[15];
// If you do, then you have to fill it and NULL terminate it with your code
char number[] = "+31 345 123456\0";

void setup() {
Serial.begin(115200);  // chage this baud rate to suit

Serial.print("ATDT ");
Serial.println(number);
}

void loop() {
}
``````

Copy this code, and paste it into your IDE. Compile/upload, the run the Serial Monitor. You should have listened to UKHeliBb.

Don't try to do too much at once. Start with putting numbers into a char array, thenwrite the code to send to the phone, and so on.