0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« on: October 08, 2012, 02:37:56 pm » |
Hi all, I'm a beginner with Arduino and programming. I have a problem. I want to use a LCD dispay ( http://www.hobbytronics.co.uk/arduino-lcd-keypad-shield). I wrote a program in Arduino enviroment: /* Keypad Shield 1602 LCD
The circuit: * LCD RS pin to digital pin 8 * LCD Enable pin to digital pin 9 * LCD D4 pin to digital pin 4 * LCD D5 pin to digital pin 5 * LCD D6 pin to digital pin 6 * LCD D7 pin to digital pin 7 * LCD BL pin to digital pin 10 */
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
void setup() { lcd.clear(); lcd.begin(16, 2); lcd.setCursor(0,0); lcd.print("Hello world"); }
void loop() { }
It works. And now I have tried to do the same at the Atmel Studio, I have added a library for LCD dispaly (LiquidCrystal.h) at AVR/GNU C compiler and at AVR/GNU C++ compiler. I have set Atmel Studio by those videos: and Here is my code: #define F_CPU 16000000 #define ARDUINO 101 #include "Arduino.h" #include "LiquidCrystal.h"
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
void setup() { LiquidCrystal; // here is probably a mistake lcd.clear(); lcd.begin(16, 2); lcd.setCursor(0,0); lcd.print("Hello world"); lcd.setCursor(0,1); lcd.print("Welcome"); }
void loop() {
}
When I build this code, Atmel Studio write me: Error 1 expected unqualified-id before '.' token I think a problem is in void setup() part, I don't know what I have to do for correct function of this code. At he attachment you find my project (1602LCD.rar). Please, could you help me? Thank you.
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3465
|
 |
« Reply #1 on: October 08, 2012, 05:52:42 pm » |
Please, could you help me? I can give you a very broad outline of your problem but one of the more experienced C programmers will have to fill in the (very large) blanks.
Basically the Arduino uses a combination of C and C++ as its code basis but the Arduino IDE does a lot of the background work for you, including generating the main() function which is required by every C program.
If you poke around enough in your Arduino folders you should be able to find the actual C program created by the Arduini IDE and compare that to your sketch to see some of what has happened.
When you use the AVR Studio IDE you must do all the background work yourself and use libraries that are supported by that environment. I do not think that the Arduino libraries fall into that category but even if they do you still have to tell the IDE where to find them.Don
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5929
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #2 on: October 08, 2012, 09:36:28 pm » |
What do you intend to accomplish with the line you think is wrong?
Remove it and you should be fine.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #3 on: October 09, 2012, 02:25:57 pm » |
to liudr: I removed and a I get five errors: Error 1 undefined reference to `LiquidCrystal::clear()' Error 2 undefined reference to `LiquidCrystal::begin(unsigned char, unsigned char, unsigned char)' Error 3 undefined reference to `LiquidCrystal::setCursor(unsigned char, unsigned char)' Error 4 undefined reference to `LiquidCrystal::setCursor(unsigned char, unsigned char)' Error 5 undefined reference to `LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
any help?
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3465
|
 |
« Reply #4 on: October 09, 2012, 03:03:24 pm » |
From reply #1: "Basically the Arduino uses a combination of C and C++ as its code basis but the Arduino IDE does a lot of the background work for you, including generating the main() function which is required by every C program."
So, where is main() in your Atmel Studio version of the program?
"If you poke around enough in your Arduino folders you should be able to find the actual C program created by the Arduini IDE and compare that to your sketch to see some of what has happened."
Have you done this?
Don
|
|
|
|
« Last Edit: October 09, 2012, 03:07:00 pm by floresta »
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5929
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #5 on: October 10, 2012, 01:02:44 pm » |
OK, just realized you used double quotation instead of brackets
#include <LiquidCrystal.h>
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #6 on: October 10, 2012, 01:22:33 pm » |
Hi Don,
I understand what you mean, but I'm beginner with Arduino and C language. I don't know how to do it.
I poke in my Arduino folders, but I didn't the actual C program created by the Arduino IDE. Something I do wrong.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #7 on: October 10, 2012, 01:24:44 pm » |
Hi Liudr,
I did it, but I get the same errors:
Error 1 undefined reference to `LiquidCrystal::clear()' Error 2 undefined reference to `LiquidCrystal::begin(unsigned char, unsigned char, unsigned char)' Error 3 undefined reference to `LiquidCrystal::setCursor(unsigned char, unsigned char)' Error 4 undefined reference to `LiquidCrystal::setCursor(unsigned char, unsigned char)' Error 5 undefined reference to `LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3465
|
 |
« Reply #8 on: October 10, 2012, 01:33:40 pm » |
I poke in my Arduino folders, but I didn't the actual C program created by the Arduino IDE. Something I do wrong. My information is based on the older versions of the IDE. Check out this (http://smileymicros.com/blog/2011/02/10/where-is-the-arduino-hex-file/) and see if it helps. He is looking for the 'hex' file but the 'cpp' file should be nearby. Don't forget that you have to look for the file before you close the IDE.Don
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3465
|
 |
« Reply #9 on: October 10, 2012, 01:35:15 pm » |
@Liudr
Did you overlook the fact that he is trying to use the Arduino library from within Atmel Studio? Maybe (probably) I am the one who is confused.
Don
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5929
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #10 on: October 10, 2012, 02:18:41 pm » |
@Liudr
Did you overlook the fact that he is trying to use the Arduino library from within Atmel Studio? Maybe (probably) I am the one who is confused.
Don
My mistake. I suppose a generic IDE will need #include <Arduino.h> as well, assuming all the library files are in library folders. Then you also need the main(). I recommend you open a sample code with Atmel Studio, make sure it compiles and works, then add code to it to try the liquid crystal library.
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 131
Posts: 4675
|
 |
« Reply #11 on: October 11, 2012, 03:59:00 am » |
Hi Liudr,
I did it, but I get the same errors:
Error 1 undefined reference to `LiquidCrystal::clear()' Error 2 undefined reference to `LiquidCrystal::begin(unsigned char, unsigned char, unsigned char)' Error 3 undefined reference to `LiquidCrystal::setCursor(unsigned char, unsigned char)' Error 4 undefined reference to `LiquidCrystal::setCursor(unsigned char, unsigned char)' Error 5 undefined reference to `LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
Those look like linker errors, meaning that your program has compiled OK but the object code library file for the LiquidCrystal library was not found. Either locate the object code library and add it to the linker input list in your AVR Studio project, or add the LiquidCrystal.cpp file to the list of source files in your project.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5929
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #12 on: October 11, 2012, 11:10:41 am » |
Those look like linker errors, meaning that your program has compiled OK but the object code library file for the LiquidCrystal library was not found. Either locate the object code library and add it to the linker input list in your AVR Studio project, or add the LiquidCrystal.cpp file to the list of source files in your project.
I meant to say something like that but was incapable of expressing it in an accurate way like you did.
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3465
|
 |
« Reply #13 on: October 11, 2012, 11:19:06 am » |
"... you still have to tell the IDE where to find them." I think I did say something like that but didn't express it in an accurate way as you did.
Don
|
|
|
|
|
Logged
|
|
|
|
|
|