//// LCD ////
int Demand_Speed; // To Store the Demand Speed in Rps // LCD
int Previous_Demand_Speed; // To Store the Previous Value of Demand Speed in Rps // LCD
#include <LiquidCrystal.h> // Library Adding // LCD
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); // Assigning the LCD Pins // LCD
char nul1 = 0x00;
//// Speed Controlling Switches(2) ////
int Left_Switch_Pin = 4; // Assigning the Left Switch Pin // Speed Controlling
int Right_Switch_Pin = 2; // Assigning the Right Switch Pin // Speed Controlling
bool Left_Switch_Status; // To Store Left Switch Read Value // Speed Controlling
bool Right_Switch_Status; // To Store Right Switch Read Value // Speed Controlling
int Actual_Speed; // To Store Actual Speed in Rps // Speed Controlling
void setup()
{
//// LCD ////
lcd.begin(16, 2); // LCD
lcd.setCursor(0, 0); // Set Print Starting point // LCD
lcd.print("EMBEDDED SYSTEMS"); // Startup Note // LCD
// lcd.print("!") is same as lcd.write(0x21)
delay(1000); // Startup Note Displaying Time // LCD
lcd.setCursor(0, 0);
lcd.write(0x21);
lcd.write(0x22);
lcd.write(0x08);
lcd.write(0x23);
delay(1000);
//lcd.clear(); // Clear LCD/Clear the Startup Note // LCD
//// Speed Controlling Switches(2) ////
Serial.begin(9600);
pinMode(Left_Switch_Pin, INPUT_PULLUP); // Assigning the Left Switch Pin // Speed Controlling
pinMode(Right_Switch_Pin, INPUT_PULLUP); // Assigning the Right Switch Pin // Speed Controlling
}
void loop()
{
/*
// LCD //
lcd.setCursor(0, 0);
lcd.print("Demnd Speed:");
Previous_Demand_Speed = Demand_Speed; // Previous Value should assign the current value,but before changing it
Demand_Speed = analogRead(A0);
if (Demand_Speed != Previous_Demand_Speed) // If value changed != means not equal
// if (~(Demand_Speed == Previous_Demand_Speed)) // If value changed ~ means not (inverter)
// if (not(Demand_Speed == Previous_Demand_Speed))
{
lcd.setCursor(12, 0);
lcd.print(" "); // printing
lcd.setCursor(12, 0);
lcd.print(Demand_Speed); // Print variable value of Demand speed // LCD
}
lcd.setCursor(0, 1);
lcd.print("Actl Speed:");
lcd.setCursor(12, 1);
lcd.print(Actual_Speed); // Print variable value of Actual speed // LCD
//// Speed Controlling Switches(2) ////
Left_Switch_Status = digitalRead(Left_Switch_Pin); // Assigning Left Switch Reading to Variable // Speed Controlling
Right_Switch_Status = digitalRead(Right_Switch_Pin); // Assigning Right Switch Reading to Variable // Speed Controlling
Serial.println(Actual_Speed); // Print the Actual Speed in this moment // Speed Controlling
if (Left_Switch_Status == 0 && Actual_Speed > 0) // And Operation(&&) is Using for Value limitation to 0 // Speed Controlling
{
Actual_Speed = Actual_Speed - 1;
Serial.println(Actual_Speed); // Print the Actual Speed in this moment // Speed Controlling
}
if (Right_Switch_Status == 0 && Actual_Speed < 500) // And Operation(&&) is Using for Value limitation to 500 // Speed Controlling
{
Actual_Speed = Actual_Speed + 1;
Serial.println(Actual_Speed); // Print the Actual Speed in this moment // Speed Controlling
}
*/
}