Errors with example sketches

Hi all,

Sorry if I'm posting this in the wrong place, but I'm new to Arduino code and don't know where to start with working out why the examples won't run.

I have a sainsmart built AT Mega 2560 with a sainsmart 7" touch screen and shield.
I have managed to play with the blink sketch and alter that with no issues. I have also uploaded the demo sketch for the 7" screen supplied by sainsmart.
What I haven't got to work is the Utouch_calibrate sketch also supplied by sainsmart for this screen and sheild and also the eeprom_clear sketch that came with the driver download won't work either.

Can someone please cast their eye over the codes and see if there is anything wrong with them. I know the mega has 4096 of memory not 512, I had been changing that before upload but it still wouldn't go.

Thank you all.

Damn can't put the code up, keeps saying it's to big to upload. Any work arounds?

Add it as an attachment. There should be an option under the text entry box when you post.

Cheers thanks for that.

Right, the Utouch_calibration does load to the board. But the screen has the text displayed back to front and upside down? When I did eventualy manage to work out what it said, "touch middle of screen to continue". Nothing happened when I did touch the screen.
eeprom_clear won't load to the board.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Mega 2560 or Mega ADK"
eeprom_clear.pde: In function 'void setup()':
eeprom_clear:11: error: redefinition of 'void setup()'
eeprom_clear:11: error: 'void setup()' previously defined here
eeprom_clear.pde: In function 'void loop()':
eeprom_clear:21: error: redefinition of 'void loop()'
eeprom_clear:21: error: 'void loop()' previously defined here

eeprom_clear.ino (344 Bytes)

UTouch_Calibration.ino (9.71 KB)

The EEPROM clear routine compiles OK for me. The error messages that you get would suggest that you have 2 functions called loop() and 2 functions called setup() in your copy of the program, almost as if the program is duplicated in the IDE.

Presumably you uploaded the program from your PC but what have you got in the IDE ? In the IDE Select All then Copy what is selected into code tags in a new message.

Have you opened two programs at once in the Arduino IDE, so that they appear as two tabs in the code window?

Thanks for the responces guys.

I copied and pasted the screen library into the ide folder, then I did the same with the Utouch library but it had the one of the folders the screen had already. I told it to over write, but when I went back to demo after the calibrator loaded with back to front upside down text, the demo also had back to front upside down text.

I then went and replaced the duplicatefolder with the one from the screen library and this fixed the demo but the calibrator is still the same.

Is that the issue or is it I have loaded a sketch then a second with out eeprom_clearing first? Any ideas how to fix my balls up?

So, one program works OK and the other doesn't.
What do the parameters mean in these 2 lines and are they the same in both programs ?

UTFT        myGLCD(CTE50,38,39,40,41);   // Remember to change the model parameter to suit your display module!
UTouch      myTouch(6,5,4,3,2);

Is that the issue or is it I have loaded a sketch then a second with out eeprom_clearing first?

Unless a program expects to find particular values in the EEPROM it will not matter what is in it. Have you actually got the EEPROM clearing program to work yet ? Note that the programs are not held in the EEPROM so you don't need to clear it before loading another program. If fact, if you think about it that would be impossible because how would you load and run the program to clear the EEPROM ?

As we had talked previously, looking at the demo that worked and comparing to the non-working (inverted) calibration will show what points as programmed different. The demo does contain tough ability or just display?

I do not have the touch.h for that 7" model loaded, my touch is a different version I suspect so can not test compile.
But off the top have you tried changing orientation? #define TOUCH_ORIENTATION PORTRAIT

You are seeing the press center and hold center on the screen but just not getting reaction when pressed and held?
Have you seen any reaction when touching the screen?
If not then I would suggest adding a few lines for the serial monitor and a debug point to check that the touch is felt.

As for the EEPROM it complies OK for me. Are you loading as a single sketch as posted here, and you have the proper Arduino eeprom.h library in the libraries folder?

I think what he did was open the IDE and then cut-and-pasted the new code into the Source code window without deleting the shell code put there by the IDE.

What I did was put the library files in the library folders in C / program files / arduino / libraries and then loaded them by going through the ide / file / examples.

Demo worked fine first time.

Calibration loaded, but was messed up. Did not respond in anyway to touch input.

Demo is just prrety colours and pictures. No touch interface.

C / program files / arduino / libraries

That is not the normal place to install user contributed libraries because if/when you upgrade the Arduino software they will not be accessible to the upgraded version.

The normal place to install user contributed libraries is in the libraries folder of your sketches folder.

Well that's clearly my first balls up. Thanks for pointing that out. I'll try and start again reinstalling everything and using the right place to put user sketches and see what happens as well as try and spot whats wrong in the code.

Thanks for the help all.

In the IDE, Sketch - Import Library - Add Library will put user contributed library files in the right folder.

But first check in File - Preferences that the sketch folder is where you want it.

Ok so after finding an alternative calibration sketch and then going between the one provided by sainsmart that uploaded but back to front upside down, and the alternative that wouldn't compile to start with. I've managed to get a sketch that compiles and loads to the board with the text orentation correct. YAY!

However I still have no touch reponce when instructed to touch the screen. Is this likely to be a hardware fault or have I used the wrong pins in the u_touch code?

Many thanks again for all your help.

working_calibration.ino (8.76 KB)