0
καλησπερα και παλι.
ποσο εφικτο ειναι σε εναν arduino mega να ''κουμπωσουν'' δυο διαφορετικες κατασκευες?????
το ενα ειναι ενα μπαρομετρο που μετραει την πιεση της τουρμπινας του αυτοκινητου και εχουμε απεικονηση σε μια οθονη lcd 20x4 χαρακτηρων και το αλλο ενας θερμοστατης που εχουμε απεικονηση σε μια οθονη lcd 16x2 χαρακτηρων.ανεβαζω και τους κωδικες
μπαρομετρο
// include libraries
#include <LiquidCrystal.h>
#include <LcdBarGraph.h>
float rawval = 0; // Setup raw sensor value
float kpaval = 0; // Setup kPa value
float boost = 0; // Setup boost value
float barboost = 0; // Setup value for boost bar
float vac = 0; // Setup vacuum value
float peak = 0; // Setup peak value
LiquidCrystal lcd(22, 23, 24, 25, 26, 27); // set LCD interface pins
byte lcdNumCols = 20; // number of columns in the LCD
LcdBarGraph lbg1(&lcd, 20, 0, 1); // setup bargraph with width 20 starting at column 0 on row 1
byte five[8] = { B01110, B01000, B01110, B00010, B01110, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
byte ten[8] = { B10111, B10101, B10101, B10101, B10111, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
byte fifteen[8] = { B10111, B10100, B10111, B10001, B10111, B00000, B00100, B00100 }; // Setup custom LCD character for bargraph legend
void setup() // Start setup
{
lcd.createChar(5, five); // Create custom character defined above
lcd.createChar(6, ten); // Create custom character defined above
lcd.createChar(7, fifteen); // Create custom character defined above
lcd.begin(20, 4); // set the LCD's columns and rows
// Setup static characters on the lcd
lcd.setCursor(0,2);
lcd.print("Boost:");
lcd.setCursor(0,3);
lcd.print("Peak:");
lcd.setCursor(13,3);
lcd.print("Psi");
lcd.setCursor(4,0);
lcd.write(5);
lcd.setCursor(9,0);
lcd.write(6);
lcd.setCursor(14,0);
lcd.write(7);
} // End setup
void loop() // Start loop
{
// some base calculations to get pressures
rawval = analogRead(0); // Read MAP sensor raw value on analog port 0
kpaval = (rawval*(0.005)/(0.022)+20); // Calculate kpa value from raw value for debugging
boost = ((rawval*(0.005)/(0.022)+20)*(0.145)-14.5); // Calculate psi from raw value ***(calculations need proving)***
barboost = (rawval-357); // Calculate boost value for the bargraph ***(not exact, needs investigation, currently uses higher raw value for a smoother bar but is not exact)
if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
{
lcd.setCursor(7,2);
lcd.print(boost,1); // Prints the boost figure
lcd.setCursor(13,2);
lcd.print("Boost "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'
lbg1.drawValue(barboost, 680); // Draw bar graph from the analog value read with a maxvalue of 500
}
if (boost < 0)
{
lcd.setCursor(7,2);
lcd.print(vac,1); // Prints the vacuum figure
vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
lcd.setCursor(13,2);
lcd.print("Vaccum"); // Changes the units to 'inHg' on the lcd
lcd.setCursor(0,1);
lcd.print(" "); // clears the boost bar if any characters are left after going below 0
}
if (boost > peak) // If current boost is higher than peak, store new value
{
peak = boost ; // Store new peak value in peak memory
}
lcd.setCursor(7,3);
lcd.print(peak,1); // Prints the peak value
} //end loop
και του θερμοστατη
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
const int LED_RED=10; //Red LED
const int LED_GREEN=11; //Green LED
const int RELAY=12; //Lock Relay or motor
//Key connections with arduino
const int up_key=3;
const int down_key=2;
int SetPoint=30;
//================================================== ===============
// SETUP
//================================================== ===============
void setup(){
pinMode(LED_RED,OUTPUT);
pinMode(LED_GREEN,OUTPUT);
pinMode(RELAY,OUTPUT);
pinMode(up_key,INPUT);
pinMode(down_key,INPUT);
//Pull up for setpoint keys
digitalWrite(up_key,HIGH);
digitalWrite(down_key,HIGH);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("circuits4you.com");
lcd.setCursor(0,1); //Move coursor to second Line
lcd.print("Temp. Controller");
digitalWrite(LED_GREEN,HIGH); //Green LED Off
digitalWrite(LED_RED,LOW); //Red LED On
digitalWrite(RELAY,LOW); //Turn off Relay
delay(2000);
}
//================================================== ===============
// LOOP
//================================================== ===============
void loop(){
double Temperature = ((5.0/1024.0) * analogRead(A0)) * 100; //10mV per degree 0.01V/C. Scalling
lcd.setCursor(0,0);
lcd.print("Temperature:"); //Do not display entered keys
lcd.print(Temperature);
//Get user input for setpoints
if(digitalRead(down_key)==LOW)
{
if(SetPoint>0)
{
SetPoint--;
}
}
if(digitalRead(up_key)==LOW)
{
if(SetPoint<150)
{
SetPoint++;
}
}
//Display Set point on LCD
lcd.setCursor(0,1);
lcd.print("Set Point:");
lcd.print(SetPoint);
lcd.print("C ");
//Check Temperature is in limit
if(Temperature > SetPoint)
{
digitalWrite(RELAY,LOW); //Turn off heater
digitalWrite(LED_RED,LOW);
digitalWrite(LED_GREEN,HIGH); //Turn on Green LED
}
else
{ι τετοι
digitalWrite(RELAY,HIGH); //Turn on heater
digitalWrite(LED_GREEN,LOW);
digitalWrite(LED_RED,HIGH); //Turn on RED LED
}
delay(100); //Update at every 100mSeconds
}
//================================================== ===============
δεν ξερω εαν ειναι δυνατο να γινει κατι τετοιο,το ευκολο για μενα θα ηταν να κανω δυο διαφορετικες κατασκευες αλλα αυτο σημενει δυο arduino και μεγαλυτερο κοστος