Stray 302

Arduino specifieke Software
Berichten: 5
Geregistreerd: 16 Jan 2015, 23:29

Stray 302

Berichtdoor dorustd » 15 Okt 2016, 19:33

na compileren krijg ik telkens onderstaande fout:

exit status 1
stray '\302' in program

waar ligt dit aan?

Advertisement

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: Stray 302

Berichtdoor nicoverduin » 15 Okt 2016, 19:39

Het lijkt erop dat er iets raars in je code staat die niet op het scherm zichtbaar is. Dat komt regelmatig voor als je code kopieert van een html pagina. Zet je sketch anders ff hier dan lokaliseren de regel ff. De oplossing is meestal:
de regel deleten en dan overnieuw intikken. Niet kopieren en plakken. Dan kopieer je gewoon de ellende weer in de sketch.
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 5
Geregistreerd: 16 Jan 2015, 23:29

Re: Stray 302

Berichtdoor dorustd » 16 Okt 2016, 20:46

Ik probeer werkend te krijgen via http://www.instructables.com/id/Arduino ... -joystick/
cpp code
#include <Servo.h>

const int servo1 = 3;       // first servo
const int servo2 = 10;       // second servo
const int joyH = 3;        // L/R Parallax Thumbstick
const int joyV = 4;        // U/D Parallax Thumbstick

int servoVal;           // variable to read the value from the analog pin

Servo myservo1;  // create servo object to control a servo
Servo myservo2;  // create servo object to control a servo



void setup() {

  // Servo  
  myservo1.attach(servo1);  // attaches the servo
  myservo2.attach(servo2);  // attaches the servo

  // Inizialize Serial
  Serial.begin(9600);
}


void loop(){

    // Display Joystick values using the serial monitor
    outputJoystick();

    // Read the horizontal joystick value  (value between 0 and 1023)
    servoVal = analogRead(joyH);          
    servoVal = map(servoVal, 0, 1023, 0, 180);     // scale it to use it with the servo (result  between 0 and 180)

    myservo2.write(servoVal);                         // sets the servo position according to the scaled value    

    // Read the horizontal joystick value  (value between 0 and 1023)
    servoVal = analogRead(joyV);           
    servoVal = map(servoVal, 0, 1023, 70, 180);     // scale it to use it with the servo (result between 70 and 180)

    myservo1.write(servoVal);                           // sets the servo position according to the scaled value

    delay(15);                                       // waits for the servo to get there

}


/**
* Display joystick values
*/
void outputJoystick(){

    Serial.print(analogRead(joyH));
    Serial.print ("---"); 
    Serial.print(analogRead(joyV));
    Serial.println ("----------------");
}

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: Stray 302

Berichtdoor nicoverduin » 16 Okt 2016, 21:24

Deze code compileert wel goed:
cpp code
#include <Servo.h>

const int servo1 = 3; // first servo
const int servo2 = 10; // second servo
const int joyH = 3; // L/R Parallax Thumbstick
const int joyV = 4; // U/D Parallax Thumbstick

int servoVal; // variable to read the value from the analog pin

Servo myservo1; // create servo object to control a servo
Servo myservo2; // create servo object to control a servo



void setup() {

// Servo
myservo1.attach(servo1); // attaches the servo
myservo2.attach(servo2); // attaches the servo

// Inizialize Serial
Serial.begin(9600);
}


void loop(){

// Display Joystick values using the serial monitor
outputJoystick();

// Read the horizontal joystick value (value between 0 and 1023)
servoVal = analogRead(joyH);
servoVal = map(servoVal, 0, 1023, 0, 180); // scale it to use it with the servo (result between 0 and 180)

myservo2.write(servoVal); // sets the servo position according to the scaled value

// Read the horizontal joystick value (value between 0 and 1023)
servoVal = analogRead(joyV);
servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with the servo (result between 70 and 180)

myservo1.write(servoVal); // sets the servo position according to the scaled value

delay(15); // waits for the servo to get there

}


/**
* Display joystick values
*/
void outputJoystick(){

Serial.print(analogRead(joyH));
Serial.print ("---");
Serial.print(analogRead(joyV));
Serial.println ("----------------");
}

Ik zou ff een nieuwe sketch maken en NIET terug kopieren in jouw vorige sketch
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 4067
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: Stray 302

Berichtdoor shooter » 16 Okt 2016, 21:29

zet de aanhalingstekens even opnieuw, dat wil nog wel eens fout gaan.
paul deelen
shooter@home.nl

Berichten: 5
Geregistreerd: 16 Jan 2015, 23:29

Re: Stray 302

Berichtdoor dorustd » 16 Okt 2016, 22:18

Code had ik Copy Paste uit html pagina van instructables.

is er geen tool om ongewenste onzichtbare HTML code eruit te halen?

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: Stray 302

Berichtdoor nicoverduin » 17 Okt 2016, 06:35

De sketch die ik heb neergezet is goed
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 5
Geregistreerd: 16 Jan 2015, 23:29

Re: Stray 302

Berichtdoor dorustd » 17 Okt 2016, 09:38

Dank je.

Terug naar Arduino software

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 84 gasten