problem programing

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

problem programing

Post by Antoine51 »

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.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: problem programing

Post by adafruit_support_rick »

Does the joystick work with the adafruit shieldtest example sketch?

Please post clear, detailed pictures of both sides of the shield, showing your soldering.

User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

Re: problem programing

Post by Antoine51 »

Hello ,

Yes the joystick work with the adafruit shieldtest example sketch.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: problem programing

Post by adafruit_support_rick »

Post your sketch

User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

Re: problem programing

Post by Antoine51 »

Here is the program
Attachments
TFT_Shield.zip
(5.04 KiB) Downloaded 22 times

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: problem programing

Post by adafruit_support_rick »

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.

User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

Re: problem programing

Post by Antoine51 »

Yes , I use an Arduino Uno AND That the 1.8 "TFT microSD and joystick from Adafruit

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: problem programing

Post by adafruit_support_rick »

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;
}

User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

Re: problem programing

Post by Antoine51 »

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'

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: problem programing

Post by adafruit_support_rick »

You don't have a loop function in your sketch.

User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

Re: problem programing

Post by Antoine51 »

I have to do?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: problem programing

Post by adafruit_support_mike »

Yes.

Even if you don't put any code in it, the Arduino sketch environment wants at least:

Code: Select all

void loop () {}

User avatar
Antoine51
 
Posts: 10
Joined: Mon Mar 09, 2015 11:11 am

Re: problem programing

Post by Antoine51 »

It's good his work! Thank you !

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”