Hello,
I have a problem on the 1.8 "TFT Adafruit Shield microSD joystick from adafruit.
I have a program but the problem is that the joystick does not work, you can not move while with the joystick test program so it works it does not come to that.
I give you so the program.
Thank you.
problem programing
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: problem programing
Does the joystick work with the adafruit shieldtest example sketch?
Please post clear, detailed pictures of both sides of the shield, showing your soldering.
Please post clear, detailed pictures of both sides of the shield, showing your soldering.
- Antoine51
- Posts: 10
- Joined: Mon Mar 09, 2015 11:11 am
Re: problem programing
Hello ,
Yes the joystick work with the adafruit shieldtest example sketch.
Yes the joystick work with the adafruit shieldtest example sketch.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: problem programing
Post your sketch
- Antoine51
- Posts: 10
- Joined: Mon Mar 09, 2015 11:11 am
Re: problem programing
Here is the program
- Attachments
-
- TFT_Shield.zip
- (5.04 KiB) Downloaded 22 times
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: problem programing
Are you using an Adafruit shield? The Adafruit Shield reads the joystick on analog 3, and it has a completely different range of values for the joystick positions.
- Antoine51
- Posts: 10
- Joined: Mon Mar 09, 2015 11:11 am
Re: problem programing
Yes , I use an Arduino Uno AND That the 1.8 "TFT microSD and joystick from Adafruit
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: problem programing
Alright, then you're going to have to change your sketch to read the joystick the same way that our shieldtest example sketch does. I suggest using the same readButton function as the example, and modifying your code to use the symbolic constants for button presses:
Code: Select all
#define BUTTON_NONE 0
#define BUTTON_DOWN 1
#define BUTTON_RIGHT 2
#define BUTTON_SELECT 3
#define BUTTON_UP 4
#define BUTTON_LEFT 5
uint8_t readButton(void) {
float a = analogRead(3);
a *= 5.0;
a /= 1024.0;
Serial.print("Button read analog = ");
Serial.println(a);
if (a < 0.2) return BUTTON_DOWN;
if (a < 1.0) return BUTTON_RIGHT;
if (a < 1.5) return BUTTON_SELECT;
if (a < 2.0) return BUTTON_UP;
if (a < 3.2) return BUTTON_LEFT;
else return BUTTON_NONE;
}
- Antoine51
- Posts: 10
- Joined: Mon Mar 09, 2015 11:11 am
Re: problem programing
Hello ,
I get an error when I run the program :
core.a(main.cpp.o): In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:43: undefined reference to `loop'
I get an error when I run the program :
core.a(main.cpp.o): In function `main':
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/main.cpp:43: undefined reference to `loop'
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: problem programing
You don't have a loop function in your sketch.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: problem programing
Yes.
Even if you don't put any code in it, the Arduino sketch environment wants at least:
Even if you don't put any code in it, the Arduino sketch environment wants at least:
Code: Select all
void loop () {}
- Antoine51
- Posts: 10
- Joined: Mon Mar 09, 2015 11:11 am
Re: problem programing
It's good his work! Thank you !
Please be positive and constructive with your questions and comments.