Go Down

Topic: Servo Movement Using RTC exit status 1 stray '\302' in program on       Serial. (Read 2642 times) previous topic - next topic

JasmineMParham

/*
 Controlling a servo position using a potentiometer (variable resistor)
 by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

 modified on 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Knob
*/

#include <Wire.h>
#include "ds3231.h"
#include <Servo.h>
int potpin = 0; // Analog pin is used to connect the potentiometer
int val; // Variable to read the value from the analog pin
int pause = 800; // Delay in open feeders (feed amount)


Servo myservo;  // create servo object to control a servo

#define BUFF_MAX 256

// First Service
uint8_t wake_HOUR1 = 12;
uint8_t wake_MINUTE1 = 56;
uint8_t wake_SECOND1 = 0;

// Second Service
uint8_t wake_HOUR2 = 18;
uint8_t wake_MINUTE2 = 30;

// How often to update the information to the standard output (ms)
unsigned long prev = 5000, interval = 5000;


void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo.write (0); // Set the position to 0
 
  Serial.begin (9600);
  Wire.begin ();
  DS3231_init (DS3231_INTCN);
  DS3231_clear_a1f ();
  DS3231_clear_a2f ();
  set_alarm ();
}

void loop()
{
   char buff [BUFF_MAX];
  unsigned long now = millis ();
  struct ts t;

  // Output through time (5000ms) The time and alarm clocks ustanovlennnye
  if ((now - prev> interval) && (Serial.available () <= 0)) {
    DS3231_get (& t);

    // Display current time
    snprintf (buff, BUFF_MAX, ".% d% 02d% 02d% 02d:.% 02d:% 02d", t.year,
             t.mon, t.mday, t.hour, t.min, t.sec);
    Serial.println (buff);

    // Display a1 debug info
    DS3231_get_a1 (& buff
  • , 59);

    Serial.println (buff);
    DS3231_get_a2 (& buff
  • , 59);

    Serial.println (buff);

    if (DS3231_triggered_a1 ()) {
      // INT has been pulled low
      Serial.println ( "-> First Service load");

  myservo.write(10);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there
  myservo.write(170);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there

 
      // Clear a1 alarm flag and let INT go into hi-z
      DS3231_clear_a1f ();
    }
    if (DS3231_triggered_a2 ()) {
      // INT has been pulled low
      Serial.println ( "-> Second Service load");

  myservo.write(10);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there
  myservo.write(170);                  // sets the servo position according to the scaled value
  delay(1000); 
}

Cactusface

Hi JasmineMParham,
                             And what!! We are not mind-readers and my crystal ball is broken....  What do you want? were are we to look? what is the problem......

Regards

Mel.
Open your mind! But not too far, your brains might fall out.
Also like Photography, model building and my 300+ Cacti and Succs.

PaulS

Quote
// Display a1 debug info
    DS3231_get_a1 (& buff

    , 59);
I'm guessing your code does not really look like that. Code tags will solve that.

Post the COMPLETE error message.
The art of getting good answers lies in asking good questions.

MarkT

You have a non-ASCII character in the program.  UTF-8 coded I think, given the \302 (which is
C2 in hex).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

JasmineMParham

@MarkT @PaulS @Cactusface I retyped my code on a new sketch still the same code, and it successfully uploaded and the purpose of this code is to move my servo with RTC on a scheduled time. But now I have tried changing the codes set time as to test my RTC accuracy which has also uploaded successfully. and now i have a compiling error

PaulS

Quote
and now i have a compiling error
But, I'm not going to post the code or the error. I don't really need help. I just wanted to complain.

Got it.
The art of getting good answers lies in asking good questions.

JasmineMParham

#include <Wire.h>
#include "ds3231.h"
#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;
int pause = 800

#define BUFF_MAX 256


;uint8_t wake_HOUR1 = 10;
uint8_t wake_MINUTE1 = 53;
uint8_t wake_SECOND1 = 0;


uint8_t wake_HOUR2 = 4;
uint8_t wake_MINUTE2 = 30;

unsigned long prev = 5000, interval = 5000;

void set_alarm (void)
{
  uint8_t flags1 [5] = {0, 0, 0, 1, 1};
  uint8_t flags2 [4] = {0, 0, 1, 1};

  DS3231_set_a1 (wake_SECOND1, wake_MINUTE1, wake_HOUR1, 0, flags1);

  DS3231_set_a2 (wake_MINUTE2, wake_HOUR2, 0, flags2);

  DS3231_set_creg (DS3231_INTCN | DS3231_A1IE);

  DS3231_set_creg (DS3231_INTCN | DS3231_A2IE); 
}

void setup ()
{
  myservo.attach (14);
  myservo.write (0);

  Serial.begin (9600);
  Wire.begin ();
  DS3231_init (DS3231_INTCN);
  DS3231_clear_a1f ();
  DS3231_clear_a2f ();
  set_alarm ();
}

void loop ()
{
  char buff [BUFF_MAX];
  unsigned long now = millis ();
  struct ts t;

  if ((now - prev> interval) && (Serial.available () <=0)) {
    DS3231_get (& t);

    snprintf (buff, BUFF_MAX, ".% d% 02d% 02d% 02d%:.% 02d", t.year,
             t.mon, t.mday, t.hour, t.min, t.sec);
    Serial.println (buff);

            DS3231_get_a1 (& buff
  • , 59);

            Serial.println (buff);
            DS3231_get_a2 (& buff
  • , 59);

            Serial.println (buff);

            if (DS3231_triggered_a1 ()) {

              Serial.println ( "-> Frist Service load");

              myservo.write (120);
              delay (pause);
              myservo.write (0);

              DS3231_clear_a1f ();
            }
                if (DS3231_triggered_a2 ()) {
                 
              Serial.println ( "-> Second Service load");

              myservo.write (120);
              delay (pause);
              myservo.write (0);

              DS3231_clear_a2f ();
            }
            prev = now; 
  }
}



Sketch uses 9,178 bytes (28%) of program storage space. Maximum is 32,256 bytes.
Global variables use 648 bytes (31%) of dynamic memory, leaving 1,400 bytes for local variables. Maximum is 2,048 bytes.


@PaulS I just started using this so I dont really know if Im tagging people correctly or how to show the next coding error.. This code keeps switching back from compiling error to uploading succesfully, and now after looking up a few things that might be the problem like changing my port to COM1 instead of COM3 for my genuino uno board a couple more things like holding down the Shift while clicking on verify to upload the code, storage error pops up which is now copied at the end of my code, but it did get rid of the compling error.

pert

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

When your code requires a library that's not included with the Arduino IDE please always post a link to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.


This code keeps switching back from compiling error to uploading succesfully,
You need to post the error if you want us to help. When there is an error you will see a button on the right side of the orange bar in the Arduino IDE window "Copy error messages". Click that button and then paste the error in a message here USING CODE TAGS.

a couple more things like holding down the Shift while clicking on verify to upload the code
You don't click on verify to upload the code, you click on the Upload button. If you hold shift while you click that button it does an "Upload Using Programmer". If you're trying to do a standard upload via USB then you don't want to do Upload Using Programmer so don't hold the shift key while clicking the upload button.

storage error pops up which is now copied at the end of my code
What storage error? Do you mean this:
Sketch uses 9,178 bytes (28%) of program storage space. Maximum is 32,256 bytes.
Global variables use 648 bytes (31%) of dynamic memory, leaving 1,400 bytes for local variables. Maximum is 2,048 bytes.
That's not an error, it's just some helpful information about how much memory your sketch is using. Read what it says!

Go Up