Pages: 1 [2]   Go Down
Author Topic: how would i code this  (Read 811 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you know the relationship well?

The look up matrix idea would require that you know the output value for pairs of inputs; alternatively if you know the output as a function of the inputs then that's a simple matter of coding something like on-time = (0.5 x pot-time) + (thermistor-value^1.3) + 24 or whatever.

On the other hand if the relationship is fuzzy, well fuzzy logic might be good and I see from this thread that there is an Arduino fuzzy logic library.
Logged

Retired from Arduino.
PMs are set to ignore all.

Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this is what i have so far. just coding for Serial feed back. it works good, now just need to get it to control and injector. but we can just use a led for testing right now.

Code:
int pot = A1; // pin for the potentiometer
int output = 10; // pin that the out put is on
int potval,tempval = 0; // variable for storing the valve from the potentiometer
int temp = A2; // pin for the 10k thermistor

void setup() {
  Serial.begin(9600);      // for debugging via the Serial Monitor
}

void loop() {
  potval = analogRead(pot);  // read the value from the sensor
  tempval = analogRead(temp);
 
  Serial.print("temp                 ");
  Serial.print("pot");
  Serial.println(potval);
  delay(500);
  Serial.println(tempval);
}
Logged

Pages: 1 [2]   Go Up
Jump to: