hi everybody!
i am experimenting a dificulty trying do something that i can't find any solution
i am trying to get a pwm output vary from a multiple of input but not only with fixed percentage
value from each other, example :
analogue input 1 : input 0 -5v but count for 10% of total output
analogue input 2 : input 0- 5v but count for 25% of total output
analogue input 3 : input 0 -5v but count for 45% of total output
analogue input 4 : input 0 -5v but count for 55% of total output
analogue input 5 : input 0 -5v but count for 35% of total output
analogue input 6 : input 0 -5v but count for 20% of total output
digital input read : input i-o but count for -45% of total output
digital input read : input i-o but count for -25% of total output
and most dificult to do for me its when another digital input read is activated
by a momentary shitch the mapping is only depended a 100% from 1 analogue input
and if you clic again its returning to the multi input mapping
i have already try a solution but i am pretty sure i am in the wrong way !!
const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogOutPin = 9;
const int automanu = A3;
const int hbk = 2;
int sensorValue0 = 0;
int sensorValue1 = 0;
int outputValue0 = 0;
int outputValue1 = 0;
int outputValue2 = 0;
int sensorValue2 = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue0 = analogRead(analogInPin0);
sensorValue1 = analogRead(analogInPin1);
sensorValue2 = analogRead(automanu);
outputValue0 = map(sensorValue0, 0, 1800, 0, 255);
outputValue1 = map(sensorValue1, 0%1, 2046%50, 0%1, 255%50);
outputValue2 = map(sensorValue2, 0, 2046, 0, 255);
analogWrite(analogOutPin, outputValue0 + outputValue1);
if (sensorValue2 > 1)
analogWrite(analogOutPin, 0);
Serial.print("sensor = " );
Serial.print(sensorValue0 + sensorValue1);
Serial.print("\t output = ");
Serial.println(outputValue0 + outputValue1 - outputValue2);
Serial.print("automanu = " );
Serial.print(sensorValue2);
delay(50);
}
i am gonna put you in situation
this is for a transmition controller for a car !!
i need several input like : throttle position , boost pressure , potentiometer input, 2 axis accelerometer, hand brake,
foot brake, switch to activate or deactivate.
the output is controlling a 70amp mosfet to put powerr into the transmition for 4wd control
i have already tested the board and this simple programation its working fine but i think i am gone in the wrong way of programing the good way
if you can suggest me a way of programing this i will be very happy
thank you