Pages: [1]   Go Down
Author Topic: Newbie Scetch help  (Read 478 times)
0 Members and 1 Guest are viewing this topic.
Port Elizabeth, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino user South Africa
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good day

Please help me fix this code to maker it compile & work.

I get the following error when I compile my scetch: "ISO C++ forbids comparison between pointer and integer"

Here is the scetch:

Code:
int command = 0 ;

void setup() {
  // put your setup code here, to run once:
  delay(1000);          // wait a bit before starting
  Serial.begin(115200);   // set up Serial library at 9600 bps
}

void loop() {
  // put your main code here, to run repeatedly:
    if (Serial.available() > 0) {
    command = Serial.read();
    if (command == "1")
//pan left
    if (command == "2")
//pan center
    if (command == "3")
//pan right
    if (command == "4")
//tilt up
    if (command == "5")
//tilt center
    if (command == "6")
//tilt down
   
    command = 0; 
}
}

The error is displayed first on the following line:  if (command == "1")
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
(command == '1')
NB single quotes.

Quote
"ISO C++ forbids comparison between pointer and integer"
"command" is the integer, and in your version, "1" is a string, so is represented by a pointer.
« Last Edit: March 24, 2011, 03:02:23 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Port Elizabeth, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino user South Africa
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good day

Thank you very much for your help.
Will this change still be able to read the serial port data beeing sent to my Arduino?

Thanks
Riaan Deyzel
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.
'1' is the integer value 49 decimal, 0x31
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Port Elizabeth, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino user South Africa
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much.

I will try it this weekend.
I am busy playing around with apps that moves servo's around, and this code will be used for the following example.

http://arduino.cc/forum/index.php/topic,55429.0.html

Pitty the "Here is that example slightly modifed to have more buttons" project it is not in c# source code with scetch, but as they say, beggars can't be choosers.
 
Thanks again for the help.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use single quotes to read the ASCII value not double quotes...Double quotes are used to print or scan the string...
Logged

Pages: [1]   Go Up
Jump to: