Could someone please help, I would like to use the blink but its giving me some unwanted results. I have tried using the sample function "Blink withoutDelay" but have come up unsuccessful. Could you please let me know if the "Blink withoutDelay" can be used on the following code.
Thank you!!!!
// include the library code:
#include <LiquidCrystal.h>
#include <PID_v1.h>
#define aref_voltage 1.72
#define PPO1 inputReading1*aref_voltage/1024
#define PPO2 inputReading2*aref_voltage/1024
#define PPO3 inputReading3*aref_voltage/1024
double Setpoint, Input, Output; //Define Variables we'll be connecting to
PID myPID(&Input, &Output, &Setpoint, 5,7,2, REVERSE); //Specify the links and initial tuning parameters
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the lcd with the numbers of the interface pins
const int red1 =28;
const int blue1 =22;
const int green1 =24;
const int yellow1 =26;
int nr; // declare numbers of flashes
const int red2 =36;
const int blue2 =30;
const int green2 =32;
const int yellow2 =34;
const int red3 =44;
const int blue3 =38;
const int green3 =40;
const int yellow3 =42;
const int sensor1 = A0; // the analog pin the 02 Sensor Vout pin is connected to
int inputReading1; //declare a variable
const int sensor2 = A1; // the analog pin the 02 Sensor Vout pin is connected to
int inputReading2; // declare a variable
const int sensor3 = A2; // the analog pin the 02 sensor Vout pin is connected to
int inputReading3; // declare a variable
void setup ()
{
Input = analogRead(PPO1); // initialize PPO variable for PID function
Setpoint = 520; // initialize setpoint variable for PID function
myPID.SetMode(AUTOMATIC); // configure PID for auto control
analogReference(EXTERNAL); // set external analog Ref for PPO output
pinMode( red1, OUTPUT);
pinMode( green1, OUTPUT);
pinMode( blue1, OUTPUT);
pinMode( red2, OUTPUT);
pinMode( green2, OUTPUT);
pinMode( blue2, OUTPUT);
pinMode( red3, OUTPUT);
pinMode( green3, OUTPUT);
pinMode( blue3, OUTPUT);
/***************************************************************
*set up the LCD's number of columns and rows:
****************************************************************/
lcd.begin(20, 4);
lcd.setCursor(0, 0);//where to start cursor
lcd.print("PINA SYSYTEMS ");//print message
lcd.print("SOFTWARE VERSION 1.0");//print message
delay(2000);
lcd.clear();
lcd.setCursor(0, 0); // set the cursor to column 0, line 0
lcd.print("PP1"); // Print a message to the LCD.
lcd.setCursor(6, 0); // set the cursor to column 6, line 0
lcd.print("PP2"); // Print a message to the LCD
lcd.setCursor(12, 0); // set the cursor to column 12, line 0
lcd.print("PP3"); // Print a message to the LCD.
}
/****************************************************************/
void blinkRGB1(int nr) // number of blinks follwed by a delay
{
for(int i=0; i< nr; i++)
if( PPO1 <= .50)
{
digitalWrite(green1,LOW);
delay(250);
digitalWrite(green1, HIGH);
delay(250);
}
else digitalWrite(green1, HIGH);
for(int i=6; i< nr; i++)
if( PPO1 > .50 && PPO1 < 1.00)
{
digitalWrite(blue1,LOW);
delay(250);
digitalWrite(blue1, HIGH);
delay(250);
}
else digitalWrite(blue1, HIGH);
for(int i=11; i< nr; i++)
if(PPO1 >1.00)
{
digitalWrite(red1,LOW);
delay(250);
digitalWrite(red1, HIGH);
delay(250);
}
else digitalWrite(red1, HIGH);
}
void blinkRGB2(int nr) // number of blinks follwed by a delay
{
for(int i=1; i< nr; i++)
if( PPO2 <= .50)
{
digitalWrite(green2,LOW);
delay(250);
digitalWrite(green2, HIGH);
delay(250);
}
else digitalWrite(green2, HIGH);
for(int i=5; i< nr; i++)
if( PPO2 > .50 && PPO2 < 1.00)
{
digitalWrite(blue2,LOW);
delay(250);
digitalWrite(blue2, HIGH);
delay(250);
}
else digitalWrite(blue2, HIGH);
for(int i=10; i< nr; i++)
if(PPO2 >1.00)
{
digitalWrite(red2,LOW);
delay(250);
digitalWrite(red2, HIGH);
delay(250);
}
else digitalWrite(red2, HIGH);
}
void blinkRGB3(int nr) // number of blinks follwed by a delay
{
for(int i=1; i< nr; i++)
if( PPO3 <= .50)
{
digitalWrite(green3,LOW);
delay(250);
digitalWrite(green3, HIGH);
delay(250);
}
else digitalWrite(green3, HIGH);
for(int i=5; i< nr; i++)
if( PPO3 > .50 && PPO3 < 1.00)
{
digitalWrite(blue3,LOW);
delay(250);
digitalWrite(blue3, HIGH);
delay(250);
}
else digitalWrite(blue3, HIGH);
for(int i=10; i< nr; i++)
if(PPO3 >1.00)
{
digitalWrite(red3,LOW);
delay(250);
digitalWrite(red3, HIGH);
delay(250);
}
else digitalWrite(red3, HIGH);
}
void loop ()
{
blinkRGB1((int)(PPO1*10)); // flash RGB1
blinkRGB2((int)(PPO2*10)); // flash RGB2
blinkRGB3((int)(PPO3*10)); // flash RGB3
/**********************************************************************
* turn the output pin on/off based on pid output
***********************************************************************/
Input = analogRead(PPO1); // PID analog input for PPO
myPID.Compute(); // computing the out for setpoint control
analogWrite(7,Output); // the output to fire O2 solenoid
/**********************************************************************/
lcd.setCursor(0, 1); //sets the cursor to column 0, line 1
inputReading1 = analogRead(sensor1); //getting the voltage reading from the 02 sensor
float voltage1 = inputReading1 * aref_voltage; // converting that reading to voltage
voltage1 /= 1024.0;
lcd.print(voltage1, 2);//print actual voltage to lcd
delay(200);
lcd.setCursor(6, 1); //sets the cursor to column 6, line 1
inputReading2 = analogRead(sensor2); //getting the voltage reading from the temperature sensor
float voltage2 = inputReading2 * aref_voltage; // converting that reading to voltage
voltage2 /= 1024.0;
lcd.print(voltage2, 2); //print actual voltage to lcd
delay(200);
lcd.setCursor(12, 1); //sets the cursor to column 12, line 2
inputReading3 = analogRead(sensor3); //getting the voltage reading from the temperature sensor
float voltage3 = inputReading3 * aref_voltage; // converting that reading to voltage
voltage3 /= 1024.0;
lcd.print(voltage3, 2); //print actual voltage to lcd
delay(200);
}