read value from function

Hai all

i have question how i want to read the value from other function and store to other function. here i attach the source code.

#include "Wire.h"
#define q1 37
#define q2 38
#define q4 39
#define q8 40
void setup()
{
 Serial.begin(9600);
 Wire.begin(); // join i2c bus (address optional for master)
 delay(500);
 pinMode(q1, INPUT); // thumbwheel '1'
 pinMode(q2, INPUT); // thumbwheel '2'
 pinMode(q4, INPUT); // thumbwheel '4'
 pinMode(q8, INPUT); // thumbwheel '8'
}

int readSwitch()
{
 int total=0;
 if (digitalRead(q1)==HIGH) { total+=1; }
 if (digitalRead(q2)==HIGH) { total+=2; }
 if (digitalRead(q4)==HIGH) { total+=4; }
 if (digitalRead(q8)==HIGH) { total+=8; }
 return total;
}
void loop()
{
 int cycleTimer(digitalRead(readSwitch()));
 int mulTimer = cycleTimer * 1000;
 Serial.println(readSwitch()); // sends switch value to serial monitor box
 delay(mulTimer);
 
}

delay value will equal with the mulTimer but i cannot get the exact value for delay. it give one second only. can anybody help me to solve this problem.

thanks

Saripdol

I don’t understand. This bit:

int cycleTimer(digitalRead(readSwitch()));

implies that readSwitch() will return a pin number to be used with digitalRead. But it looks like it actually reads a bunch of pins and comes up with some other number.

Did you mean

int cycleTimer = readSwitch();

maybe?

Delta_G:
I don't understand. This bit:

int cycleTimer(digitalRead(readSwitch()));

implies that readSwitch() will return a pin number to be used with digitalRead. But it looks like it actually reads a bunch of pins and comes up with some other number.

Did you mean

int cycleTimer = readSwitch();

maybe?

yes i want readSwitch () value store in cylceTimer.

OK, well I don't know what you had going on with that digitalRead and all then. If you just want the value returned to go into a variable then you just need the equal sign there.