Is het op de 1 of andere manier mogelijk om de sensorcounter data weer te gebruiken in een andere void.
Ik weet het wel void returns no data.
bijvoorbeeld-
int sensorCounter = 0; // counter for the number of sensor puls
int sensorState = 0; // current state of the sensor
int lastsensorState = 0; // previous state of the sensor
const int sensorPin = 10; // the pin that the sensor is attached to
void setup()
{
LCDMenuLib_setup(_LCDMenuLib_cnt); /* Setup for LcdMenuLib */
Serial.begin(9600); /* start serial */
pinMode(sensorPin, INPUT); // initialize the sensor pin as a input:
void loop()
{
//LCDMenuLib_control_analog(); /* lcd menu control - config in tab "LCDML_control" */
//LCDMenuLib_control_digital(); /* lcd menu control - config in tab "LCDML_control" */
LCDMenuLib_control_serial(); /* lcd menu control */
LCDMenuLib_control_rotary();
LCDMenuLib_loop(); /* lcd function call */
FUNC_sensorCounter();
// Serial.println(LCDMenuLib_getActiveFuncId());
//other function
void FUNC_sensorCounter ()
{
// read the sensor input pin:
sensorState = digitalRead(sensorPin);
// compare the sensorState to its previous state
if (sensorState != lastsensorState) {
// if the state has changed, increment the counter
if (sensorState == HIGH) {
// if the current state is HIGH then the sensor
// wend from low to high:
sensorCounter++;
}
else { // if the current state is LOW then the sensor
// wend from high to low:
}
}
lastsensorState = sensorState;// save the current state as the last state,
//for next time through the loop
}
en dan weer te gebruiken in - en in meer void,s
void FUNC_Astra(void)
{
/* setup function */
if(!LCDML.FuncInit())
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(sensorCounter);
}
/* end function for callback */
if(LCDML.FuncEnd(0, 1, 1, 1, 1, 1)) /* (direct, up, down, left, right) */
{
/* do something befor this function is closed */
}
Het gaat mij alleen om de data van de sensorcounter de ik weer wil gebruiken in meerdere functie,s.
En dat is alleen maar het optellen bij elke beweging van de sensor (optical Rotary wheel) om een positie te bepalen.
En die on de fly te laten zien op het lcd.
Ik weet het wel void returns no data.
bijvoorbeeld-
int sensorCounter = 0; // counter for the number of sensor puls
int sensorState = 0; // current state of the sensor
int lastsensorState = 0; // previous state of the sensor
const int sensorPin = 10; // the pin that the sensor is attached to
void setup()
{
LCDMenuLib_setup(_LCDMenuLib_cnt); /* Setup for LcdMenuLib */
Serial.begin(9600); /* start serial */
pinMode(sensorPin, INPUT); // initialize the sensor pin as a input:
void loop()
{
//LCDMenuLib_control_analog(); /* lcd menu control - config in tab "LCDML_control" */
//LCDMenuLib_control_digital(); /* lcd menu control - config in tab "LCDML_control" */
LCDMenuLib_control_serial(); /* lcd menu control */
LCDMenuLib_control_rotary();
LCDMenuLib_loop(); /* lcd function call */
FUNC_sensorCounter();
// Serial.println(LCDMenuLib_getActiveFuncId());
//other function
void FUNC_sensorCounter ()
{
// read the sensor input pin:
sensorState = digitalRead(sensorPin);
// compare the sensorState to its previous state
if (sensorState != lastsensorState) {
// if the state has changed, increment the counter
if (sensorState == HIGH) {
// if the current state is HIGH then the sensor
// wend from low to high:
sensorCounter++;
}
else { // if the current state is LOW then the sensor
// wend from high to low:
}
}
lastsensorState = sensorState;// save the current state as the last state,
//for next time through the loop
}
en dan weer te gebruiken in - en in meer void,s
void FUNC_Astra(void)
{
/* setup function */
if(!LCDML.FuncInit())
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(sensorCounter);
}
/* end function for callback */
if(LCDML.FuncEnd(0, 1, 1, 1, 1, 1)) /* (direct, up, down, left, right) */
{
/* do something befor this function is closed */
}
Het gaat mij alleen om de data van de sensorcounter de ik weer wil gebruiken in meerdere functie,s.
En dat is alleen maar het optellen bij elke beweging van de sensor (optical Rotary wheel) om een positie te bepalen.
En die on de fly te laten zien op het lcd.
[ Voor 35% gewijzigd door Verwijderd op 28-07-2014 01:37 ]