Hey guys, I was working on my code when I hit this stop which I do not really understand, the problem shown above has been annoying me the past days and I don't know what to do. Can you help me?
#include <CountUpDownTimer.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int FSRPin = A0; // force sensitive resistor
int ColorPin = 9; // ColorStat Sensor
int LedPin = 13; // OUTPUTPIN
CountUpDownTimer T(DOWN);
LiquidCrystal_I2C lcd(0x27, 16, 2);
// time values
int initial = 1;
int timeon = 0;
int mins = 0;
int secs = 10;
int start_time = 0;
int end_time = 0;
int elapased_time = 0;
// sensor values
int colorValue = 0;
int FSRValue = 0;
float temp = 0.0;
int sensorValue = 0;
// control values
int flag = 1;
int command = 0;
#define ONTIME 10
//Linear Actuator
int Threshold= 0; // Add more threshold integers based on different cases?
int ADULTbutton = 3; //Will input values either tomorrow or the day after
int TEENbutton = 4;
int KIDbutton = 5;
const int Extend = 7; // In1
const int Retract = 8; // In2
int RESISTOR_READING = 0;
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Started...");
Serial.begin(9600);
Serial.println("Initializing...");
Serial.println("Started...");
pinMode(FSRPin, INPUT);
pinMode(ColorPin, INPUT);
pinMode(LedPin, OUTPUT);
digitalWrite(LedPin, LOW);
T.SetTimer(0, 0, 0, 10);
T.StartTimer();
command = 0;
pinMode(ADULTbutton = INPUT);
pinMode(TEENbutton = INPUT);
pinMode(KIDbutton = INPUT);
pinMode(Extend, OUTPUT);
pinMode(Retract, OUTPUT);
}
void loop() {
FSRValue = smooth();
colorValue = digitalRead(ColorPin);
RESISTOR_READING = digitalRead(FSRValue);
if (ADULTbutton = HIGH) {
takeMeasurement("Adult");
delay(1000);
lcd.print("Starting");
(Extend = HIGH);
} else if (TEENbutton = HIGH) {
takeMeasurement("Teen");
delay(1000);
lcd.print("Starting");
(Extend = HIGH);
} else if (KIDbutton = HIGH) {
takeMeasurement("Kid");
delay(1000);
lcd.print("Starting");
(Extend = HIGH);
} else {
lcd.setCursor(0, 0);
lcd.print("Need More Pressure");
Serial.print(" -> Need More Pressure");
(Extend = LOW);
sensorValue = 0;
Threshold = 0
}
void takeMeasurement(String age){
if (age == "Kid"){
Threshold = 300;
lcd.setCursor(0, 0);
lcd.print("Kids 6-12 Years");
Serial.print(" -> Kids 6-12 Years");
sensorValue = 1;
if(RESISTOR_READING = 300){
(Extend = LOW);
(Retract = HIGH);
}
} else if (age == "Teen"){
Threshold = 400;
lcd.setCursor(0, 0);
lcd.print("Teen 13-19 Years");
Serial.print("-> Teens 13-19 Years");
sensorValue = 1;
if(RESISTOR_READING = 400){
(Extend = LOW);
(Retract = HIGH);
}
} else if (age == "Adult"){
Threshold = 600;
lcd.setCursor(0, 0);
lcd.print("Adult");
Serial.print("-> Adult");
sensorValue = 1;
}
if(RESISTOR_READING = 600){
(Extend = LOW);
(Retract = HIGH);
delay(1000);
}
if(sensorValue == 1) {
timeon = 1;
} else {
timeon = 0;
}
if (timeon == 1) {
T.Timer();
digitalWrite(LedPin, HIGH);
if (T.TimeHasChanged());
{
Serial.print(":");
Serial.print(T.ShowSeconds());
lcd.setCursor(0,1);
lcd.print(T.ShowSeconds());
}
if (T.ShowSeconds() == 0) {
T.ResetTimer();
lcd.clear();
lcd.print("Release Pressure");
Serial.println("Release the Pressure");
digitalWrite(LedPin, LOW);
command = 2;
// timeon=0;
// sensorValue=0;
break;
}
}
Serial.println("");
case 2:
//delay(10);
if (FSRValue == 0 && colorValue == 0) {
// T.ResetTimer();
// T.Timer(); // run the timer
Serial.print(" ");
Serial.print(millis());
Serial.println("");
T.SetTimer(0, 0, 0, 5);
lcd.clear();
lcd.print("Start Time");
command = 3;
start_time = millis();
break;
}
Serial.println("");
case 3:
if (FSRValue == 0 && colorValue == 1) // (flag==1)
{
// Serial.print(" ");
// Serial.print(millis());
// Serial.println("");
//Serial.println("State :3");
command = 4;
T.SetTimer(0, 0, 0, 5);
end_time = millis();
lcd.clear();
lcd.print("End Time");
flag = 0;
elapased_time = (end_time - start_time) / 1000;
Serial.print("Elapased Time : ");
Serial.println(elapased_time);
delay(1000);
lcd.clear();
lcd.print("elapased_time : "); // Added this print statement
lcd.print(elapased_time);
break;
} else {
Serial.print("");
}
Serial.println("");
case 4:
if (flag == 0) {
T.Timer(); // run the timer
if (T.TimeHasChanged()) // this prevents the time from being constantly shown.
{
Serial.print(":");
Serial.print(T.ShowSeconds());
// lcd.clear();
// lcd.print(T.ShowSeconds());
}
if (T.ShowSeconds() == 0) {
T.ResetTimer();
command = 0;
T.SetTimer(0, 0, 0, 10);
flag = 1;
break;
}
}
Serial.println("");
}
delay(1000);
}
They can be removed using regular expressions; it might work in IDE 2.0 (I never had the need to try), else you will need an external editor like e.g. Notepad++ in Windows or e.g. vi(m) or sed in Linux (and possibly Mac).
You still have a many incorrect pinMode() commands in the revised(?) sketch:
Also your code contains a lot of another errors - unpaired braces, case operators without switch and many others... To be honest, right now your code is a meaningless set of lines.
It seems that you understand the syntax of the language very poorly. I would advise you to put your code aside for a while and read some basic programming book.
I changed about 160 lines so that would take forever. Many of the changes are just formatting or good programming practices.
Use this online tool to compare the two versions. You should probably auto-format both first to minimize the differences only in formatting. Then look at each change and try to figure out why it was made. If you can't figure out a change, ask about it here and someone will likely be able to explain it to you.