Experts of the universe!!!!!!!!
I want to calc the speed of a rim bike, I have a code found in www.cadjunkie.com thanks works perfect, but only for one rim/bike
it reads a magnetic sensor each time were the magnet pass through the sensor (default open) and close the circuit, so the code calc the time in miliseconds and send by serial.write function to processing...
then, processing reads each "step" or delay between pulses and make all graphs and work..
the issue here is I wanna read differents rims speeds at the same time, so I need 2 digital read inputs to send the info by serial write function to processing, and in processing use the values of rim1 and rim2
right now, I think than the hard problem is in arduino, but maybe the clue is in the method of how to read the info in processing, but I don't have idea of how to do this or if there are other way than could work,
if someone can give me a little help, I will be greatfully
the code than i'm using in arduino is:
//credits to Adam of cadjunkie.com project
//
#define LED 13 //pin for the LED
#define SWITCH 0 //input for REED SWITCH
int val = 0; //used to store input value
int previousVal = 0; //lets not be too repetitious
unsigned long time = 0; // the last time the output pin was toggled
long debounce = 10; // the debounce time, increase if the output flickers
void setup() {
pinMode(LED, OUTPUT); //tell arduino LED is an output
pinMode(SWITCH, INPUT); //SWITCH is input
Serial.begin(9600);
}
void loop(){
val=digitalRead(SWITCH); //read input value and store it
//check whether input is HIGH (switch closed)
if (val==HIGH) {
digitalWrite(LED, HIGH); //turn LED on
if (previousVal != HIGH) Serial.write( byte(1)); //old versions of arduino must use this: Serial.print(1, BYTE)
previousVal = HIGH;
} else{
digitalWrite(LED, LOW);
if (previousVal != LOW && millis() - time > debounce) Serial.write( byte(0));
previousVal = LOW;
time = millis();
}
}