Go Down

Topic: how would i code this (Read 1 time) previous topic - next topic

JimboZA

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.
My hovercraft is full of eels.

No PMs for help please.
DO NOT power servos from Arduino 5V: give them their own power and connect the grounds.

jareeb

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: [Select]
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);
}

Go Up