Go Down

Topic: exit status 1 (Read 107730 times) previous topic - next topic

jetdriver55

hello i am having a problem with dht11.h not being recognised by the ide. i have finally got it to be

recognised in dhttester. the library path is setup the same way for both programs yet it wont pickup dht11.h in the following program. i have tried all ways of library setup firstly with way layed out in arduino site and various other ways but no luck i always restart the ide after any change and have restarted pc win7 several times no luck.
arduino ide is 1.6.12.

it has me stumped. ive been working with ibm compats since xt's and gwbasic etc long before c was invented. i can still work my way around in dos.

please tell me if im having a blonde moment here.

the code i am trying to verify is as follows

Code: [Select]



//Including Libs

#include "OneWire.h"
#include "VirtualWire.h"
#include "Wire.h" //Pressure sensor
#include "dht11.h"

//Defining Pins


#define DHTPIN 2
#define ONE_WIRE_BUS 10
#define DHTTYPE DHT11   // DHT 11
#define BMP085_ADDRESS 0x77  // I2C address of BMP085 //Pressure sensor

#define INTEGER_MAX (pow(2,31)-1)
#define E_MAX (pow(10, 7))
#define E_MIN (pow(10, -6))
#define EPSILON 0.000000119209

OneWire oneWire(ONE_WIRE_BUS);

int RF_TX_PIN = 12;

//Pressure sensor
const unsigned char OSS = 0;  // Oversampling Setting

// Calibration values
int ac1;
int ac2;
int ac3;
unsigned int ac4;
unsigned int ac5;
unsigned int ac6;
int b1;
int b2;
int mb;
int mc;
int md;

// b5 is calculated in bmp085GetTemperature(...), this variable is also used in bmp085GetPressure(...)
// so ...Temperature(...) must be called before ...Pressure(...).
long b5;

//Seting up
void setup()
{
  //For Debug
  Serial.begin(9600);
  Serial.println("Setup");

  //Pressure sensor
  Wire.begin();
  bmp085Calibration();

  // Setup transmit pin
  vw_set_tx_pin(RF_TX_PIN);
  vw_setup(2000); //

  //For Debug
  Serial.println("Start Pressure");
}

//Main Loop
void loop()
{
  Serial.println("\n");

  //First Sensor
  //Humidity
  int chk = DHT11.read(DHT11PIN);

  //Send Data #H is for Humidity
  SendData("#H"+ ((String)DHT11.humidity));



  //Seccond Sensor
  //Temp (Baro Pressure)
  float temperature = bmp085GetTemperature(bmp085ReadUT()); //MUST be called first

  //Send Data #C is for Celcious
  SendData("#C"+(String(temperature,2)));



  //Same seccond Sensor, next output
  //Baro Pressure
  float pressure = bmp085GetPressure(bmp085ReadUP());

  //Send Data #P is for pressure
  SendData("#P"+(String(pressure/100,2)));


  //Wait for Next Loop
  delay(5000);
}

void SendData(String Data)
{
  //Debug
  Serial.println("-->"+ Data + "<-- ");

  //Making char Array of String
  const char* rawdata = Data.c_str();

  digitalWrite(13, true); // Flash a light to show transmitting
  vw_send((uint8_t *)rawdata, strlen(rawdata)); //Send Data
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(13, false);
}

//Calabration of Barometic sensor
void bmp085Calibration()
{
  ac1 = bmp085ReadInt(0xAA);
  ac2 = bmp085ReadInt(0xAC);
  ac3 = bmp085ReadInt(0xAE);
  ac4 = bmp085ReadInt(0xB0);
  ac5 = bmp085ReadInt(0xB2);
  ac6 = bmp085ReadInt(0xB4);
  b1 = bmp085ReadInt(0xB6);
  b2 = bmp085ReadInt(0xB8);
  mb = bmp085ReadInt(0xBA);
  mc = bmp085ReadInt(0xBC);
  md = bmp085ReadInt(0xBE);
}

// Calculate temperature in deg C
float bmp085GetTemperature(unsigned int ut){
  long x1, x2;

  x1 = (((long)ut - (long)ac6)*(long)ac5) >> 15;
  x2 = ((long)mc << 11)/(x1 + md);
  b5 = x1 + x2;

  float temp = ((b5 + 8)>>4);
  temp = temp /10;

  return temp;
}

// Calculate pressure given up
// calibration values must be known
// b5 is also required so bmp085GetTemperature(...) must be called first.
// Value returned will be pressure in units of Pa.
long bmp085GetPressure(unsigned long up){
  long x1, x2, x3, b3, b6, p;
  unsigned long b4, b7;

  b6 = b5 - 4000;
  // Calculate B3
  x1 = (b2 * (b6 * b6)>>12)>>11;
  x2 = (ac2 * b6)>>11;
  x3 = x1 + x2;
  b3 = (((((long)ac1)*4 + x3)<<OSS) + 2)>>2;

  // Calculate B4
  x1 = (ac3 * b6)>>13;
  x2 = (b1 * ((b6 * b6)>>12))>>16;
  x3 = ((x1 + x2) + 2)>>2;
  b4 = (ac4 * (unsigned long)(x3 + 32768))>>15;

  b7 = ((unsigned long)(up - b3) * (50000>>OSS));
  if (b7 < 0x80000000)
    p = (b7<<1)/b4;
  else
    p = (b7/b4)<<1;

  x1 = (p>>8) * (p>>8);
  x1 = (x1 * 3038)>>16;
  x2 = (-7357 * p)>>16;
  p += (x1 + x2 + 3791)>>4;

  long temp = p;
  return temp;
}

// Read 1 byte from the BMP085 at 'address'
char bmp085Read(unsigned char address)
{
  unsigned char data;

  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(address);
  Wire.endTransmission();

  Wire.requestFrom(BMP085_ADDRESS, 1);
  while(!Wire.available())
    ;

  return Wire.read();
}

// Read 2 bytes from the BMP085
// First byte will be from 'address'
// Second byte will be from 'address'+1
int bmp085ReadInt(unsigned char address)
{
  unsigned char msb, lsb;

  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(address);
  Wire.endTransmission();

  Wire.requestFrom(BMP085_ADDRESS, 2);
  while(Wire.available()<2)
    ;
  msb = Wire.read();
  lsb = Wire.read();

  return (int) msb<<8 | lsb;
}

// Read the uncompensated temperature value
unsigned int bmp085ReadUT(){
  unsigned int ut;

  // Write 0x2E into Register 0xF4
  // This requests a temperature reading
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(0xF4);
  Wire.write(0x2E);
  Wire.endTransmission();

  // Wait at least 4.5ms
  delay(5);

  // Read two bytes from registers 0xF6 and 0xF7
  ut = bmp085ReadInt(0xF6);
  return ut;
}

// Read the uncompensated pressure value
unsigned long bmp085ReadUP(){

  unsigned char msb, lsb, xlsb;
  unsigned long up = 0;

  // Write 0x34+(OSS<<6) into register 0xF4
  // Request a pressure reading w/ oversampling setting
  Wire.beginTransmission(BMP085_ADDRESS);
  Wire.write(0xF4);
  Wire.write(0x34 + (OSS<<6));
  Wire.endTransmission();

  // Wait for conversion, delay time dependent on OSS
  delay(2 + (3<<OSS));

  // Read register 0xF6 (MSB), 0xF7 (LSB), and 0xF8 (XLSB)
  msb = bmp085Read(0xF6);
  lsb = bmp085Read(0xF7);
  xlsb = bmp085Read(0xF8);

  up = (((unsigned long) msb << 16) | ((unsigned long) lsb << 8) | (unsigned long) xlsb) >> (8-OSS);

  return up;
}


jetdriver55

additional info

have found that whatever xxxx.h is on top in the include section then the ide cant find that in the folder in the weather program.
have now got the library files for this program in the weather transmitter folder and still got same problems.
desperate to sort this as ive bought 5 complete sets of components for presents to family.

Ruffnecks22

I am also having troubles with the exit status 1 error message. I copied the error message.
Arduino: 1.6.11 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope

 int RECV_PIN = TKD2; // the pin the IR receiver is connected to

                ^

exit status 1
Error compiling for board Arduino/Genuino Uno.


pert

PEOPLE, you need to understand that "exit status 1" is the most generic possible error message, it just means that there was an error while compiling. I do appreciate that you searched for the correct thread to post instead of creating a duplicate thread but in this case it really isn't helpful to group them all together by that specific error message(you should be looking at the specific compiler error message).

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope

 int RECV_PIN = TKD2; // the pin the IR receiver is connected to

                ^

exit status 1
Error compiling for board Arduino/Genuino Uno.
The problem is that the wrong IRremote library was included by the Arduino IDE. Try this:
  • Sketch > Include Library > Manage Libraries...
  • Type "IRremote" in the "Filter your search..." box.
  • Click on the "IRremote by shirriff" result.
  • Click "Install".
  • After the installation completes click "Close".
  • Try uploading or compiling your sketch again.


have now got the library files for this program in the weather transmitter folder and still got same problems.
Please describe the folder structure you're working with, either via text or screenshot from Windows Explorer.

PaulS

Quote
C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp
Do you have an official Arduino robot? If not, why do you need to keep this file? Delete it, and problems with compiling the file will go away.
The art of getting good answers lies in asking good questions.

pert

Do you have an official Arduino robot? If not, why do you need to keep this file? Delete it, and problems with compiling the file will go away.
The file included in the sketch is IRremote.h, so deleting the file IRremoteTools.cpp would cause a file not found error. Deleting the entire C:\Program Files (x86)\Arduino\libraries\RobotIRremote folder will do the trick, assuming the IRremote library has been installed but every time you update to a new version of the Arduino IDE you will need to delete the RobotIRremote library again so it's better to just properly install the IRremote library, which will give the correct IRremote.h file include priority over the one in the RobotIRremote folder. The Library Manager installation of the library will automatically do this by ensuring that the included file name matches the library folder name.

PaulS

Quote
The file included in the sketch is IRremote.h, so deleting the file IRremoteTools.cpp would cause a file not found error.
Total non-sequitor.

The FILE being compiled, when the error occurs, is IRremoteTools.cpp. Deleting that file will prevent it from being compiled.

When the sketch is compiled, the presence or absence of some other cpp file is completely irrelevant.

The absence of IRremoteTools.cpp might cause a linker error, but that will certainly not involve the phrase "file not found".
The art of getting good answers lies in asking good questions.

Abhishek_G

#37
Jan 07, 2017, 04:49 pm Last Edit: Jan 07, 2017, 05:02 pm by Abhishek_G
Total non-sequitor.

The FILE being compiled, when the error occurs, is IRremoteTools.cpp. Deleting that file will prevent it from being compiled.

When the sketch is compiled, the presence or absence of some other cpp file is completely irrelevant.

The absence of IRremoteTools.cpp might cause a linker error, but that will certainly not involve the phrase "file not found".
I too have the same error, but with the message:


"C:\Users\Abhishek Gaywala\Documents\Arduino\libraries\SoftwareServo/SoftwareServo.h:4:22: fatal error: WProgram.h: No such file or directory

#include <WProgram.h>"


And as far as I can understand, (from this link: https://www.arduino.cc/en/Hacking/BuildProcess) is that Wprogram is the core library.

I'm using a code to run two servos with a joystick, using a pair of NRF24L01 radio, using the RF24 library. this library calls for the use of SoftwareServo library (Downloaded from: http://playground.arduino.cc/uploads/ComponentLib/SoftwareServo.zip), because the regular servo library causes timer conflicts.


How do I replace/repair the Wprogram library? I can't even delete that library, right?

Abhishek_G

I too have the same error, but with the message:


"C:\Users\Abhishek Gaywala\Documents\Arduino\libraries\SoftwareServo/SoftwareServo.h:4:22: fatal error: WProgram.h: No such file or directory

#include <WProgram.h>"


And as far as I can understand, (from this link: https://www.arduino.cc/en/Hacking/BuildProcess) is that Wprogram is the core library.

I'm using a code to run two servos with a joystick, using a pair of NRF24L01 radio, using the RF24 library. this library calls for the use of SoftwareServo library (Downloaded from: http://playground.arduino.cc/uploads/ComponentLib/SoftwareServo.zip), because the regular servo library causes timer conflicts.


How do I replace/repair the Wprogram library? I can't even delete that library, right?
Okay, so I'm answering my own question.


I did a little bit of digging, and came to know that Wprogram.h is an outdated file. The newer versions of the IDE support the Arduino.h file.
So all I had to do was to replace the "#include Wprogram.h" with "#include Arduino.h" in the SoftwareServo header files, and then I was good to go.


Glad to have found this thread.

Mdzain

Had the same problem too. Need help with this coding. Currently using genuino 101 board.

Code: [Select]

/*
* The code is released under the GNU General Public License.
* Developed by www.codekraft.it
*/

#include "CurieImu.h"

// IMU
float FS_SEL = 131;                                  // IMU gyro values to degrees/sec
unsigned long last_read_time;
float angle_x, angle_y, angle_z;                     // These are the result angles
float last_x_angle, last_y_angle, last_z_angle;      // These are the filtered angles
float lGXA, lGYA, lGZA;                              // Store the gyro angles to compare drift

// FUNCTIONS
//Math
//Convert radians to degrees
double rtod(double fradians) {return(fradians * 180.0 / PI);}

void set_last_read_angle_data(unsigned long time, float x, float y, float z, float x_gyro, float y_gyro, float z_gyro) {
  last_read_time = time;
  last_x_angle = x; last_y_angle = y; last_z_angle = z;
  lGXA = x_gyro; lGYA = y_gyro; lGZA = z_gyro;
}

void setup() {
 
  Serial.begin(9600);
  while (!Serial);

  // init CurieImu
  CurieImu.initialize();
  // use the code below to calibrate accel/gyro offset values
  Serial.println("Internal sensor offsets BEFORE calibration...");
  Serial.print(CurieImu.getXAccelOffset());
  Serial.print("\t"); // -76
  Serial.print(CurieImu.getYAccelOffset());
  Serial.print("\t"); // -235
  Serial.print(CurieImu.getZAccelOffset());
  Serial.print("\t"); // 168
  Serial.print(CurieImu.getXGyroOffset());
  Serial.print("\t"); // 0
  Serial.print(CurieImu.getYGyroOffset());
  Serial.print("\t"); // 0
  Serial.println(CurieImu.getZGyroOffset());
  Serial.println("About to calibrate. Make sure your board is stable and upright");
  delay(1000);
  // The board must be resting in a horizontal position for
  // the following calibration procedure to work correctly!
  Serial.print("Starting Gyroscope calibration...");
  CurieImu.autoCalibrateGyroOffset();
  Serial.println(" Done");
  Serial.print("Starting Acceleration calibration...");
  CurieImu.autoCalibrateXAccelOffset(0);
  CurieImu.autoCalibrateYAccelOffset(0);
  CurieImu.autoCalibrateZAccelOffset(1);
  Serial.println(" Done");
  Serial.println("Enabling Gyroscope/Acceleration offset compensation");
  CurieImu.setGyroOffsetEnabled(true);
  CurieImu.setAccelOffsetEnabled(true);

  set_last_read_angle_data(millis(), 0, 0, 0, 0, 0, 0);
}
 
void loop() {
  unsigned long t_now = millis();
  int ax = CurieImu.getAccelerationX();
  int ay = CurieImu.getAccelerationY();
  int az = CurieImu.getAccelerationZ();
  int gx = CurieImu.getRotationX();
  int gy = CurieImu.getRotationY();
  int gz = CurieImu.getRotationZ();


  // Convert gyro values to degrees/sec
  float gyro_x = gx/FS_SEL;
  float gyro_y = gy/FS_SEL;
  float gyro_z = gz/FS_SEL;

   // Compute the accel angles
  float accelX = rtod(atan(ay / sqrt( pow(ax, 2) + pow(az, 2))));
  float accelY = rtod(-1 * atan(ax/sqrt(pow(ay,2) + pow(az,2))));
 
  // Compute the (filtered) gyro angles
  float dt =(t_now - last_read_time)/1000.0;
  float gyroX = gyro_x*dt + last_x_angle;
  float gyroY = gyro_y*dt + last_y_angle;
  float gyroZ = gyro_z*dt + last_z_angle; 

  // Compute the drifting gyro angles
  float unfiltered_gyro_angle_x = gyro_x*dt + lGXA;
  float unfiltered_gyro_angle_y = gyro_y*dt + lGYA;
  float unfiltered_gyro_angle_z = gyro_z*dt + lGZA;
 
  // Apply the complementary filter to figure out the change in angle
  // Alpha depends on the sampling rate...
  float alpha = 0.96;
  angle_x = alpha*gyroX + (1.0 - alpha)*accelX;
  angle_y = alpha*gyroY + (1.0 - alpha)*accelY;
  angle_z = gyroZ;  //Accelerometer doesn't give z-angle

  // Update the saved data with the latest values
  set_last_read_angle_data(t_now, angle_x, angle_y, angle_z, unfiltered_gyro_angle_x, unfiltered_gyro_angle_y, unfiltered_gyro_angle_z);

  Serial.print("Y:" );
  Serial.print(angle_y);
  Serial.print("  \t Z:" );
  Serial.print(angle_z);
  Serial.print("  \t X:" );
  Serial.println(angle_x);

}

pert

Had the same problem too. Need help with this coding. Currently using genuino 101 board.
"exit status 1" is the most generic possible error message. It is absolutely not helpful to group problems by this error message. You need to scroll up the black console window at the bottom of the Arduino IDE window and read the FULL compiler output, not just the last line. If you don't learn that then you will never have a chance of any success with Arduino.

When you encounter an error and want help from the forum you need to provide us the full error output. You will see a button on the right side of the orange bar "Copy error messages". Click that button then paste the error in a forum post using code tags.

In this case I can see the problem from looking at your code. The geniuses at Intel decided to rename the CurieImu library to CurieIMU. So you only need to change the line:
Code: [Select]
#include "CurieImu.h"
to:
Code: [Select]
#include "CurieIMU.h"

pert

Forgot to add, you need to do a search and replace to change all other instances of CurieImu with CurieIMU. Updated code:
Code: [Select]

/*
* The code is released under the GNU General Public License.
* Developed by www.codekraft.it
*/

#include "CurieIMU.h"

// IMU
float FS_SEL = 131;                                  // IMU gyro values to degrees/sec
unsigned long last_read_time;
float angle_x, angle_y, angle_z;                     // These are the result angles
float last_x_angle, last_y_angle, last_z_angle;      // These are the filtered angles
float lGXA, lGYA, lGZA;                              // Store the gyro angles to compare drift

// FUNCTIONS
//Math
//Convert radians to degrees
double rtod(double fradians) {return(fradians * 180.0 / PI);}

void set_last_read_angle_data(unsigned long time, float x, float y, float z, float x_gyro, float y_gyro, float z_gyro) {
  last_read_time = time;
  last_x_angle = x; last_y_angle = y; last_z_angle = z;
  lGXA = x_gyro; lGYA = y_gyro; lGZA = z_gyro;
}

void setup() {
 
  Serial.begin(9600);
  while (!Serial);

  // init CurieIMU
  CurieIMU.initialize();
  // use the code below to calibrate accel/gyro offset values
  Serial.println("Internal sensor offsets BEFORE calibration...");
  Serial.print(CurieIMU.getXAccelOffset());
  Serial.print("\t"); // -76
  Serial.print(CurieIMU.getYAccelOffset());
  Serial.print("\t"); // -235
  Serial.print(CurieIMU.getZAccelOffset());
  Serial.print("\t"); // 168
  Serial.print(CurieIMU.getXGyroOffset());
  Serial.print("\t"); // 0
  Serial.print(CurieIMU.getYGyroOffset());
  Serial.print("\t"); // 0
  Serial.println(CurieIMU.getZGyroOffset());
  Serial.println("About to calibrate. Make sure your board is stable and upright");
  delay(1000);
  // The board must be resting in a horizontal position for
  // the following calibration procedure to work correctly!
  Serial.print("Starting Gyroscope calibration...");
  CurieIMU.autoCalibrateGyroOffset();
  Serial.println(" Done");
  Serial.print("Starting Acceleration calibration...");
  CurieIMU.autoCalibrateXAccelOffset(0);
  CurieIMU.autoCalibrateYAccelOffset(0);
  CurieIMU.autoCalibrateZAccelOffset(1);
  Serial.println(" Done");
  Serial.println("Enabling Gyroscope/Acceleration offset compensation");
  CurieIMU.setGyroOffsetEnabled(true);
  CurieIMU.setAccelOffsetEnabled(true);

  set_last_read_angle_data(millis(), 0, 0, 0, 0, 0, 0);
}
 
void loop() {
  unsigned long t_now = millis();
  int ax = CurieIMU.getAccelerationX();
  int ay = CurieIMU.getAccelerationY();
  int az = CurieIMU.getAccelerationZ();
  int gx = CurieIMU.getRotationX();
  int gy = CurieIMU.getRotationY();
  int gz = CurieIMU.getRotationZ();


  // Convert gyro values to degrees/sec
  float gyro_x = gx/FS_SEL;
  float gyro_y = gy/FS_SEL;
  float gyro_z = gz/FS_SEL;

   // Compute the accel angles
  float accelX = rtod(atan(ay / sqrt( pow(ax, 2) + pow(az, 2))));
  float accelY = rtod(-1 * atan(ax/sqrt(pow(ay,2) + pow(az,2))));
 
  // Compute the (filtered) gyro angles
  float dt =(t_now - last_read_time)/1000.0;
  float gyroX = gyro_x*dt + last_x_angle;
  float gyroY = gyro_y*dt + last_y_angle;
  float gyroZ = gyro_z*dt + last_z_angle;

  // Compute the drifting gyro angles
  float unfiltered_gyro_angle_x = gyro_x*dt + lGXA;
  float unfiltered_gyro_angle_y = gyro_y*dt + lGYA;
  float unfiltered_gyro_angle_z = gyro_z*dt + lGZA;
 
  // Apply the complementary filter to figure out the change in angle
  // Alpha depends on the sampling rate...
  float alpha = 0.96;
  angle_x = alpha*gyroX + (1.0 - alpha)*accelX;
  angle_y = alpha*gyroY + (1.0 - alpha)*accelY;
  angle_z = gyroZ;  //Accelerometer doesn't give z-angle

  // Update the saved data with the latest values
  set_last_read_angle_data(t_now, angle_x, angle_y, angle_z, unfiltered_gyro_angle_x, unfiltered_gyro_angle_y, unfiltered_gyro_angle_z);

  Serial.print("Y:" );
  Serial.print(angle_y);
  Serial.print("  \t Z:" );
  Serial.print(angle_z);
  Serial.print("  \t X:" );
  Serial.println(angle_x);

}

hhofkhan

I have the same problem - I am trying to get the Trinket to work a servo and am not sure what part of the coder is wrong. Here is the code which I copied off the Adafruit Soft Servo Library- https://learn.adafruit.com/trinket-gemma-servo-control/code.

Can anyone help?

/*******************************************************************
  SoftServo sketch for Adafruit Trinket.  Turn the potentiometer knob
  to set the corresponding position on the servo
  (0 = zero degrees, full = 180 degrees)
 
  Required library is the Adafruit_SoftServo library
  available at https://github.com/adafruit/Adafruit_SoftServo
  The standard Arduino IDE servo library will not work with 8 bit
  AVR microcontrollers like Trinket and Gemma due to differences
  in available timer hardware and programming. We simply refresh
  by piggy-backing on the timer0 millis() counter
 
  Required hardware includes an Adafruit Trinket microcontroller
  a servo motor, and a potentiometer (nominally 1Kohm to 100Kohm
 
  As written, this is specifically for the Trinket although it should
  be Gemma or other boards (Arduino Uno, etc.) with proper pin mappings
 
  Trinket:        USB+   Gnd   Pin #0  Pin #2 A1
  Connection:     Servo+  -    Servo1   Potentiometer wiper
 
 *******************************************************************/

#include <Adafruit_SoftServo.h>  // SoftwareServo (works on non PWM pins)

#define SERVO1PIN 0   // Servo control line (orange) on Trinket Pin #0

#define POTPIN   1   // Potentiometer sweep (center) on Trinket Pin #2 (Analog 1)

Adafruit_SoftServo myServo1, myServo2;  //create TWO servo objects
   
void setup() {
  // Set up the interrupt that will refresh the servo for us automagically
  OCR0A = 0xAF;            // any number is OK
  TIMSK0 |= _BV(OCIE0A);    // Turn on the compare interrupt (below!)
 
  myServo1.attach(SERVO1PIN);   // Attach the servo to pin 0 on Trinket
  myServo1.write(90);           // Tell servo to go to position per quirk
  delay(15);                    // Wait 15ms for the servo to reach the position
}

void loop()  {
  int potValue;  // variable to read potentiometer
  int servoPos;  // variable to convert voltage on pot to servo position
  potValue=analogRead(POTPIN);                // Read voltage on potentiometer
  servoPos = map(potValue, 0, 1023, 0, 179);  // scale it to use it with the servo (value between 0 and 180)
  myServo1.write(servoPos);                    // tell servo to go to position

  delay(15);                              // waits 15ms for the servo to reach the position
}

// We'll take advantage of the built in millis() timer that goes off
// to keep track of time, and refresh the servo every 20 milliseconds
// The SIGNAL(TIMER0_COMPA_vect) function is the interrupt that will be
// Called by the microcontroller every 2 milliseconds
volatile uint8_t counter = 0;
SIGNAL(TIMER0_COMPA_vect) {
  // this gets called every 2 milliseconds
  counter += 2;
  // every 20 milliseconds, refresh the servos!
  if (counter >= 20) {
    counter = 0;
    myServo1.refresh();
  }
}

ramya_reddy

hello,
here is the error that i am getting when i am trying to compile my code in arduino. can you please help me to get through it????

C:\Users\Ramya\Desktop\Arduino\hardware\tools\avr/bin/avr-ar: unable to rename 'core\core.a'; reason: Permission denied

exit status 1
Error compiling for board Arduino/Genuino Uno.

PaulS

Quote
can you please help me to get through it?
backwards.
working
and
end
the
at
starting
by
problems
solving
start
not
does
One

Fix the first error listed FIRST. Mr Google positively does not bite.
The art of getting good answers lies in asking good questions.

Go Up