0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« on: February 06, 2013, 09:27:45 am » |
Hi,
I have a tft lcd touch and rtc on my arduino, i drew 0 to 9 numbers on the lcd and have the x,y touch coordinates to define the 10 numbers. I want to do is afther pressing to numbers ex 1 and 3 (13) send them to rtc ( ds1307setup(); ) i change the numers in ds1307set(DS1307_....,mi); to diferent int in order to geting the touch data but dont now how to transform the x,y to a int. I need to "store" 5 "var" before send the ds1307setup(); (year = int y, month = int m, day = int d....)
ds1307set(DS1307_SEG,1); ds1307set(DS1307_MIN,mi); // mi ds1307set(DS1307_HR,h); // h ds1307set(DS1307_DdS,ds); // ds ds1307set(DS1307_DMES,dm); // dm ds1307set(DS1307_MTH,me); // me ds1307set(DS1307_ANO,a); // a
Please help me or if there is a example made point me there.
Thankz
Paulo
|
|
|
|
« Last Edit: February 07, 2013, 07:22:47 pm by camolas »
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #1 on: February 06, 2013, 09:44:52 am » |
You mean the x and y coordinates? Just use IF/ELSE statements.
Example: if x == 0 and y == 3, button 3 was pressed. if x == 1 and y == 5, button 7 was pressed.
You have to map out where each button its and set it in the IF/ELSE statements. You will need 2 X coords(left / right of button) and 2 Y coords(top / bottom of button) to do it properly.
|
|
|
|
|
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
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« Reply #2 on: February 06, 2013, 09:53:29 am » |
Hi,
Thanks, coordinates part i have done just dont no how i can put it in a int to send to the rtc.
Thankz
Paulo
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #3 on: February 06, 2013, 10:08:18 am » |
Arrays and the atoi() function will help you.
|
|
|
|
|
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
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« Reply #4 on: February 06, 2013, 10:11:58 am » |
Im new to this can you please write a small example?
Thankz
Paulo
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Online
Edison Member
Karma: 47
Posts: 1397
May all of your blinks be without delay
|
 |
« Reply #5 on: February 06, 2013, 10:14:56 am » |
Google atoi() and you will get plenty of examples
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« Reply #6 on: February 06, 2013, 10:18:45 am » |
I have done but cant put it to work 
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Online
Edison Member
Karma: 47
Posts: 1397
May all of your blinks be without delay
|
 |
« Reply #7 on: February 06, 2013, 10:22:34 am » |
Post the code that does not work and describe what should happen and what actually happens.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« Reply #8 on: February 06, 2013, 10:46:46 am » |
I dont have now with me, later at home i will posted but i think i used string not array ( i cant understand how fill arrays..)
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){ tft.setTextSize(3); tft.fillRect(82, 201, 25, 25, BLUE); tft.setCursor(82, 201); tft.println ("0"); myString +=0; } else if (page == 70 && p.y > 290 && p.y < 310 && p.x > 190 && p.x <215){ tft.setTextSize(3); tft.fillRect(110, 201, 25, 25, BLUE); tft.setCursor(110, 201); tft.println ("1"); myString +=1; }
if (page == 70 && p.y > 126 && p.y < 146 && p.x > 83 && p.x <103){ tft.fillRect(30, 201, 220, 21, BLUE); tft.drawString(100, 201, "VALIDADO", WHITE, 3); tft.fillRect(1, 50, 25, 25, RED); tft.setTextSize(3); tft.setCursor(1, 50);
a=atoi(myString); ds1307setup(); }
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #9 on: February 06, 2013, 10:49:41 am » |
|
|
|
|
« Last Edit: February 06, 2013, 10:52:10 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
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« Reply #10 on: February 06, 2013, 10:59:54 am » |
Please teach me,
I need example 4 bytes i declare:
int myInts[4];
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){ tft.setTextSize(3); tft.fillRect(82, 201, 25, 25, BLUE); tft.setCursor(82, 201); tft.println ("0"); myInts[0] == 0, } else if (page == 70 && p.y > 290 && p.y < 310 && p.x > 190 && p.x <215 && q==1){ tft.setTextSize(3); tft.fillRect(110, 201, 25, 25, BLUE); tft.setCursor(110, 201); tft.println ("1"); myInts[1] == 1, }
if (page == 70 && p.y > 126 && p.y < 146 && p.x > 83 && p.x <103){ tft.fillRect(30, 201, 220, 21, BLUE); tft.drawString(100, 201, "VALIDADO", WHITE, 3); tft.fillRect(1, 50, 25, 25, RED); tft.setTextSize(3); tft.setCursor(1, 50);
a=atoi( myInts[0] ,myInts[1]); ds1307setup(); }
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Online
Edison Member
Karma: 47
Posts: 1397
May all of your blinks be without delay
|
 |
« Reply #11 on: February 06, 2013, 11:11:48 am » |
int myInts[4]; does declare an array of 4 ints but myInts[0] == 0, does not store a value in the array
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #12 on: February 06, 2013, 11:12:18 am » |
a = atoi(myInts);
You should check for a special character button like * or # and if any of those are pressed it convert the array to an int. If those are NOT pressed, use a variable (int counter;) to add number to the array.
Example.
if(press != '*' || press != '#') { myInts[counter++] = press; } else { a = atoi(myInts); }
|
|
|
|
|
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
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 89
Arduino rocks
|
 |
« Reply #13 on: February 06, 2013, 11:24:25 am » |
Thanks master,
One question how do i store a value in the array afther number 0 is pressed?
if (page == 70 && p.y > 211 && p.y < 231 && p.x > 84 && p.x <104 ){ tft.setTextSize(3); tft.fillRect(82, 201, 25, 25, BLUE); tft.setCursor(82, 201); tft.println ("0"); myInts ???? }
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #14 on: February 06, 2013, 11:28:50 am » |
Same way. the only time it stops entering number is when one of those special characters are pressed. You should also clear the array afterwards with a while loop.
while(counter != 0) { // this can be used for any size array. myInts[counter--] = 0; }
|
|
|
|
|
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
|
|
|
|
|