Hi,
I am new to this environment. So a couple of questions about scope and options on storing things: First let me list this my first arduino program:
code
*
//#include <CmdMessenger.h> // CmdMessenger
//#include <printf.h>
#include <arduino.h>
//OUTPUTS
#define PIN_LED 6
#define Fan1 2
#define Fan2 3
#define Heater1 4
#define Heater2 5
#define UpButton 8
#define DownButton 9
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//Enable Inputs
pinMode(UpButton, INPUT);
pinMode(DownButton, INPUT);
pinMode(PIN_LED, OUTPUT);
pinMode(Heater1, OUTPUT);
pinMode(Heater2, OUTPUT);
pinMode(Fan1, OUTPUT);
pinMode(Fan2, OUTPUT);
//digitalWrite(PIN_LED, HIGH);
Serial.println(“Begin”);
}
void loop()
{
// put your main code here, to run repeatedly:
// get buttons
int timeTrackUp = 0; // used to keep track of how long the up button has been held down
int timeTrackDown = 0; // used to keep track of how long the down button has been held down
float tempSetPoint;
float tempActualA;
float tempActualB;
float averageTemp;
int analog1;
int analog2;
int tempChange;
int thermo1 = 14;
int thermo2 = 15;
int ledcount = 0;
digitalWrite(PIN_LED, HIGH);
#ifdef debug then
Serial.println(“Running”);
#endif
if (digitalRead(UpButton))
{
delay(10);
if (digitalRead(UpButton))
{
#ifdef debug then
Serial.println(“Up”);
#endif
}
}
if (digitalRead(DownButton))
{
delay(10);
if (digitalRead(DownButton))
{
#ifdef debug then
Serial.println(“Down”);
#endif
}
}
// read temps
analog1 = analogRead(thermo1);
analog2 = analogRead(thermo2);
// insert convert code here.
tempActualA = (float) analog1 / 760 * 450;
tempActualB = (float) analog2 / 760 * 450;
averageTemp = (tempActualA + tempActualB) / 2;
delay(1000);
digitalWrite(PIN_LED,LOW);
if (averageTemp < (tempSetPoint -2))
{
digitalWrite(Fan1,HIGH);
digitalWrite(Fan2,HIGH);
digitalWrite(Heater1,HIGH);
digitalWrite(Heater2,HIGH);
}
if (averageTemp > (tempSetPoint +2))
{
digitalWrite(Fan1,LOW);
digitalWrite(Fan2,LOW);
digitalWrite(Heater1,LOW);
digitalWrite(Heater2,LOW);
}
if ((tempSetPoint <=1))
{
digitalWrite(Fan1,LOW);
digitalWrite(Fan2,LOW);
digitalWrite(Heater1,LOW);
digitalWrite(Heater2,LOW);
}
delay(1000);
}
void printtemps(int settemp, int temp1, int temp2)
// sends the set point and temps to the display
{
char st[10];
char tp1[10];
char tp2[10];
serial.write(254);
serial.write(128); //home the display
serial.write(“st: “);
serial.write(“t1: t2: “);
sprintf(st,”%3d”,settemp);
sprintf(tp1,”%3d”,temp1);
sprintf(tp2,"%3d",temp2);
serial.write(254);
serial.write(128); // first position on first line
serial.write(st); // write the setpoint
serial.write(254);
serial.write(192);// first position on second line
serial.write(st); // write the setpoint
serial.write(254);
serial.write(200);//eight position on second line
serial.write(st); // write the setpoint
}
*
end code
When I first started this not knowing any better I put the code in the main arduino folder (\program files (x86)\arduino) under a folder with the same name as the project. When I compiled I got an error that the function printtemps was out of scope. So I started to create a header file and then read some online files and discovered I should have put this in the default location which on my machine is \users\jeff\Documents\arduino. So I moved it and created a header file in a folder with the project name under the libraries folder in that area. Now when I compile it tells me serial is out of scope. Serial is of course part of the core arduino files so I’m wondering what I need to add/change to make this work.
Part 2 of this question is: I am starting to use arduino for many projects. I usually organize my files project centric, that is I make a folder with the project name and put everything associated with it including software in subfolders. Is this possible in this environment?
Thanks