Hello, I am a newbie to Arduino. So happy to be on this forum between you intellectual people. Below is my arduino code generated by Firefly (Rhino Grasshopper Plugin). When I try to upload it to my board it generates series of errors. Can somebody please look into the matter and guide me to the correct path
/*
Firefly Code Generator by Andy Payne
Copyright 2011 All Rights Reserved
Code Generated on 07/30/2021 12:38:09
Special thanks to Panagiotis Michalatos.
For more information visit: www.fireflyexperiments.com
*/
#include "FFCasts.h"
#include <Servo.h>
//******************* Begin Function Definitions *******************
//Remap Number Function: Remap a value into a new numeric domain.
double Remap_Numbers(double x, Interval _in, Interval _out) {
return (x - _in.t0) * (_out.t1 - _out.t0) / (_in.t1 - _in.t0) + _out.t0;
}
//Multiplication Function: Multiply two numbers.
inline double Multiplication(double _v1, double _v2){
return _v1 * _v2;
}
//Constrain Function: Constrains a number to a specific numeric range.
double Constrain(double _v1, Interval _in){
double _min, _max, result;
if (_in.t0 < _in.t1){
_min = _in.t0;
_max = _in.t1;
}else{
_min = _in.t1;
_max = _in.t0;
}
if (_v1 < _min){
result = _min;
}else if (_v1 > _max){
result = _max;
}else{
result = _v1;
}return result;
}
double smoothlist_0[1];
int smoothindex_0 = 0;
double smoothtotal_0 = 0.0;
//Smoothing Function: Smooth (or average) an incoming value based on (N) number of samples.
double Smoothing_Moving_Average(double _v1, int _n, double *_list, int *_index, double *_total){
*_total -= _list[*_index];
*_total += _v1;
_list[*_index] = _v1;
(*_index)++;
if (*_index >= _n) *_index = 0;
return *_total/(double)_n;
}
//******************** End Function Definitions ********************
Servo servo-1;
void setup() {
int smi;
for(smi = 0; smi < 1; ++smi) {
smoothlist_0[smi] = 0.0;
}
servo-1.attach(-1);
}
void loop() {
digitalWrite(-1, Multiplication(Remap_Numbers(Analog_Pin_0,Interval(100,250),Interval(1,0)),0));
digitalWrite(-1, Multiplication(Remap_Numbers(Analog_Pin_0,Interval(100,250),Interval(0,1)),0));
servo-1.write(Smoothing_Moving_Average(Remap_Numbers(Constrain(Analog_Pin_0,Interval(100,250)),Interval(100,250),Interval(85,99)),1, smoothlist_0, &smoothindex_0, &smoothtotal_0));
}
struct Interval {
Interval(double _t0, double _t1) {
t0=_t0;
t1=_t1;
}
Interval(double _t1) {
t0=0.0;
t1=_t1;
}
Interval(const Interval &_i) {
t0=_i.t0;
t1=_i.t1;
}
double t0, t1;
};
Errors
Arduino: 1.8.15 (Windows Store 1.8.49.0) (Windows 10), Board: "Arduino Uno"
Firefly:59:12: error: expected initializer before '-' token
Servo servo-1;
^
D:\SCET\Academics\5th Year\Research\Firefly\Firefly.ino: In function 'void setup()':
Firefly:66:3: error: 'servo' was not declared in this scope
servo-1.attach(-1);
^~~~~
D:\SCET\Academics\5th Year\Research\Firefly\Firefly.ino:66:3: note: suggested alternative: 'Servo'
servo-1.attach(-1);
^~~~~
Servo
Firefly:66:9: error: unable to find numeric literal operator 'operator""attach'
servo-1.attach(-1);
^~~~~~~~
D:\SCET\Academics\5th Year\Research\Firefly\Firefly.ino: In function 'void loop()':
Firefly:70:49: error: 'Analog_Pin_0' was not declared in this scope
digitalWrite(-1, Multiplication(Remap_Numbers(Analog_Pin_0,Interval(100,250),Interval(1,0)),0));
^~~~~~~~~~~~
D:\SCET\Academics\5th Year\Research\Firefly\Firefly.ino:70:49: note: suggested alternative: 'analogWrite'
digitalWrite(-1, Multiplication(Remap_Numbers(Analog_Pin_0,Interval(100,250),Interval(1,0)),0));
^~~~~~~~~~~~
analogWrite
Firefly:72:3: error: 'servo' was not declared in this scope
servo-1.write(Smoothing_Moving_Average(Remap_Numbers(Constrain(Analog_Pin_0,Interval(100,250)),Interval(100,250),Interval(85,99)),1, smoothlist_0, &smoothindex_0, &smoothtotal_0));
^~~~~
D:\SCET\Academics\5th Year\Research\Firefly\Firefly.ino:72:3: note: suggested alternative: 'Servo'
servo-1.write(Smoothing_Moving_Average(Remap_Numbers(Constrain(Analog_Pin_0,Interval(100,250)),Interval(100,250),Interval(85,99)),1, smoothlist_0, &smoothindex_0, &smoothtotal_0));
^~~~~
Servo
Firefly:72:9: error: unable to find numeric literal operator 'operator""write'
servo-1.write(Smoothing_Moving_Average(Remap_Numbers(Constrain(Analog_Pin_0,Interval(100,250)),Interval(100,250),Interval(85,99)),1, smoothlist_0, &smoothindex_0, &smoothtotal_0));
^~~~~~~
Multiple libraries were found for "Servo.h"
Used: C:\Users\Dell\Documents\Arduino\libraries\Servo
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries\Servo
exit status 1
expected initializer before '-' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.