Disabling relaxation: it will not work with multiple definitions - atmel

i'm a beginner to coding and yesterday i code a simple light up led in C programming , it works in Atmel Studio, however the next day it has these errors from the picture shown. My code is
#define F_CPU 1600000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB=0xFF;
while (1)
{
PORTB |= 0b0000100;
}
}
Can anyone help me? Thanks.Error
I'm not sure how as I keep trying to find help from internet, but it couldnt help me

Related

EspSoftwareSerial with ESP8266: error no matching function for call to 'SoftwareSerial::SoftwareSerial()'

i am trying to program with Arduino IDE 1.8.13 using EspSoftwareSerial library (target ESP8266).
Whatever example provided that I try to compile, I get an error (for example for the program "servoTester") :
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
SoftwareSerial swSer;
...
servoTester:4:16: error: no matching function for call to 'SoftwareSerial::SoftwareSerial()'
SoftwareSerial swSer;
I am not familiar with C ++ and Arduino (but I know C well on microcontrollers).
I'm a little bored, I've searched all over the place for solutions, and feel like I'm not the only one having this problem, but I haven't found a solution that works.
I tried to :
change the <> by ""
restart Arduino after installing the EspSoftwareSerial library
Reinstall Arduino
and various absurd things %-(
Does somebody have an idea ?

how to transmit with Nreadings>5

I am trying to set Nreadings in the Oscilloscope header file in tinyos above 5,say I set it at 6. When I do this, I notice that transmissions cease that is the green led does not blink signalling no transmissions are happening and instead I notice the red LED toggling telling me that there is an error. I went into the tos/types directory and opened message.h ,here I changed message length and set it to 56 from 28 as follows:
ifndef __MESSAGE_H__
#define __MESSAGE_H__
#include "platform_message.h"
#ifndef TOSH_DATA_LENGTH
#define TOSH_DATA_LENGTH 56
#endif
#ifndef TOS_BCAST_ADDR
#define TOS_BCAST_ADDR 0xFFFF
#endif
typedef nx_struct message_t {
nx_uint8_t header[sizeof(message_header_t)];
nx_uint8_t data[TOSH_DATA_LENGTH];
nx_uint8_t footer[sizeof(message_footer_t)];
nx_uint8_t metadata[sizeof(message_metadata_t)];
} message_t;
After making the above change I downloaded the Oscilloscope application onto my mote,yet the problem persists,am I missing something? After making the change to message_t, do I need to do compile something before i download the code?

Is there a #define _KEYWORD_ in arduino.h to check against?

I would prefer to use standard Arduino API's if they are available. I need a way to check if arduino.h is present. If it is not available (i.e. executing code on BeagleBone Black), then I can use my own functions.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
Taken from: http://www.arduino.cc/en/Main/ReleaseNotes [internals]

windows version of R package much slower than linux version

I'm running ubuntu, 64bit. I have this minimal test package that i made to learn how to do these things (I'm following this tutorial, except i also have some c code in the package).
The package build/runs in linux so i set about making it run in windows too.
I followed this answer and used the online windows package builder maintained by Uwe Ligges to get a (working) zip version of my package.
Now, when i install that .zip package on windows (7-64) the small demo code runs slower than the linux version. As in 30 times slower. I doubt the difference is always so large.
I'm wondering what i'm doing wrong and how i can fix this gap.
EDIT:
this is the source code (it's a minimal working example):
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <fstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <Eigen/Dense>
#include <Eigen/LU>
#include <Eigen/SVD>
using namespace std;
using namespace Eigen;
using Eigen::MatrixXf;
using Eigen::VectorXf;
float median(VectorXf& x) {
int n=x.rows();
int half=(n+1)/2;
half--;
float med;
nth_element(x.data(),x.data()+half,x.data()+x.size());
if((n%2)==1){
med=x(half);
} else {
float tmp0=x(half);
float tmp1=x.segment(half+1,half-1).minCoeff();
med=0.5*(tmp0+tmp1);
}
return med;
}
VectorXf fx01(MatrixXf& x){
int p=x.cols();
int n=x.rows();
VectorXf Recept(n);
VectorXf Result(p);
for(int i=0;i<p;i++){
Recept=x.col(i);
Result(i)=median(Recept);
}
return Result;
}
extern "C"{
void mse(int* n,int* p,float* x,float* medsout){
MatrixXf x_cen=Map<MatrixXf>(x,*n,*p);
VectorXf MedsOut=fx01(x_cen);
Map<VectorXf>(medsout,*p)=MedsOut.array();
}
}
EDIT2:
Following cbeleites suggestion i ran the code multiple times. Doing this I found
a strange thing: the function's timing are actually the same as linux except when
i call apply() before calling my function --I was always comparing the timing
of the colwise median my pack computes to the timing of doing apply(X,2,median)--
Ok, problem solved. For now. Still i'm curious now: why would a good old fashioned
call to apply() (on a huge matrix X) wreck things so badly (system.time went from
90sec to 3sec)?
One possibility that comes to my mind where calculations on different machines can differ about is the BLAS (if there are linear algebra calculations in the example).
Do you have an optimized BLAS installed on Ubuntu (e.g. libopenblas) but not on Windows?

How to include an already written library to a custom library in Arduino

I'm creating a new library to control the keypad and LCD together. Most of the code seems to compile, but when it reaches the line where I define the LiquidCristal variable, it says:
'LiquidCrystal' does not name a type when creating a custom library
This is the extract of content of my LCDKeypad.h
// Include types & constants of Wiring core API
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#include "WConstants.h"
#endif
// Include LCD library
#include <LiquidCrystal.h>
The error is in this line:
private:
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 ); // <<-- Error
Alright, I was reading a lot and I found a very interesting article about this subject:
Including multiple libraries
It says that the compiler does not search for libraries that are not included in the sketch file. The way to hack this is to force the compiler to link them before loading your libraries, including, in my case LiquidCrystal.h in the sketch.
Let's say my library "LCDkeypad" requires LiquidCrystal.
My main program (sketch) needs to include LiquidCrystal in order to load it for my library "LCDKeypad".
Now, one interesting thing is using forward declaration, so in my LCDKeypad.h I will declare
"Class LiquidCrystal" but not include the library. I will do it in LiquidCrystal.cpp and in the sketch.
I hope this is clear.
There are two ways of doing it
If you are writing your own code Just create header file .h extension and relevant c code as name_c.While adding into main program, you need to specify header file name in double quotes.
code:
#ifndef LCD_H
#define LCD_H
//Declaration of variable /functions
#endif
If you are trying to download from link. Then you need paste the code into D:\arduino\arduino\libraries
Error problem:
overlapping of multiple declaration of variable.
overlapping of library functions

Resources