Hi. Im having trouble with this code. I'm getting a strange message: unexpected char: "i" when i try to run the code
              in 
             Integration and Hardware 
              •  
              3 months ago    
            
 
           
             Hi. Im having trouble with this code. I'm getting a strange message,
             unexpected char: "i" ,when i try to run the code. the program highlights that piece of code that is highlighted below, but i dont see the problem with it. also, im trying to download the code to an Arduino which I dont seem to be doing correctly. can someone help me out with that too. The code is below. Thanks for your help. 
            
             
            
            
             
              
             
             
                      
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
                
             
             
                  
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
              
             
             
                
             
             
              
             
             
                
             
             
              
             
             
              
             
             
              
             
             
            
             
             
           
 
            
           
              /*
             
             
              ////////////////////////////////////////////////
             
             
                 [ Arduino Cycle Computer ] Version A0.1
             
             
               >> Original written by Adam O'Hern
             
             
               >> Modified by Alexdlp for Instructables 2011
             
             
              ////////////////////////////////////////////////
             
             
              */
             
             
              #include <LiquidCrystal.h>
             
             
              #include <LcdBarGraph.h>
             
             
              // initialize the library with the numbers of the interface pins
             
             
              LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
             
             
              byte lcdNumCols = 15; // -- number of columns in the LCD
             
             
              LcdBarGraph lbg(&lcd, lcdNumCols);  // -- creating
             
             
              int LED = 13;                   //pin for the LED
             
             
              int SensorPin = A0;                 //input for REED SensorPin
             
             
              int rim = 2035;                  //circumference of wheel in mm
             
             
              int val = 0;                     // used to store input value
             
             
              int previousVal = 0;             // lets not be too repetitious
             
             
              int debounce = 10;               // the debounce time, increase if the output flickers
             
             
              int cycles = 1;                  // total number of revolutions
             
             
              float currentSpeed = 0;          // current speed in MPH
             
             
              float averageSpeed = 0;          // average speed since "newRide" was true
             
             
              unsigned long revTimer;          // create a timer that tells us how long we go between pulses,
             
             
              unsigned long serialTimer;       // and one for how long it's been since we sent anything over serial
             
             
              unsigned long rideTimer;         // total time since "newRide" was true
             
             
              boolean activeRiding = false;    // is the bike moving?
             
             
              boolean activityChange = true;   // just a way of keeping track of how long we're inactive
             
             
              long inactivityTimer;            // millis() on which we began inactivity
             
             
              long activeRidingOffset = 0;     // time subtracted from total riding time when calculating average speed
             
             
              boolean newRide = true;          // true if we haven't moved in half an hour or more
             
             
              float rideDistance = 0;          // total distance traveled since "newRide" was true
             
             
              void setup() {
             
             
                lcd.begin(16, 2);  
             
             
                pinMode(LED, OUTPUT);           // tell arduino LED port is an output,
             
             
                pinMode(SensorPin, INPUT);         // and SensorPin port is input
             
             
                Serial.begin(9600);             // start a serial session
             
             
                revTimer = millis();            // start pulse timer
             
             
                serialTimer = millis();         // start serial timer
             
             
                rideTimer = millis();           // start ride timer
             
             
              }
             
             
              void loop(){
             
             
                if(!activeRiding) {
             
             
                  if(activityChange) {
             
             
                    inactivityTimer = millis();
             
             
                    activityChange = false;
             
             
                  }
             
             
                } 
             
             
                else {
             
             
                  if(activityChange) {
             
             
                    activeRidingOffset += millis() - inactivityTimer;
             
             
                    activityChange = false;
             
             
                  }
             
             
                }
             
             
                if (analogRead(SensorPin) > 600) { 
             
             
                  val = HIGH;
             
             
                }
             
             
                else { 
             
             
                  val = LOW; 
             
             
                }
             
             
                if (val==LOW) {                 // check whether input is LOW (magnet is NOT in range of reed SensorPin)
             
             
                  digitalWrite(LED, LOW);       // turn LED off
             
             
                  previousVal = LOW;            // allow the next "pulse" to be counted
             
             
                } 
             
             
                else{
             
             
                  digitalWrite(LED, HIGH);        // turn LED off
             
             
                  lcd.setCursor(15, 0);         // Set cursor to the top right of LCD
             
             
                  lcd.print("*");               // Print a blank character or 'space'
             
             
                  delay(100);
             
             
                  lcd.setCursor(15, 0);         // Set cursor to the top right of LCD
             
             
                  lcd.print(" ");               // Print a blank character or 'space'
             
             
                  if (previousVal != HIGH && millis() - revTimer > debounce) { // we've got a pulse!
             
             
                    pulse(); 
             
             
                  } 
             
             
                  previousVal = HIGH;             // (in case the magnet is in range of the SensorPin while sitting still)
             
             
                }
             
             
                // if it's been too long since the last pulse, assume we're not moving.
             
             
                if(millis()-revTimer > 2000) { 
             
             
                  currentSpeed = 0;  
             
             
                  if(activeRiding) { 
             
             
                    activityChange = true; 
             
             
                    activeRiding = false; 
             
             
                  }
             
             
                }
             
             
                // if it's been more than fifteen minutes...
             
             
                if (millis() - revTimer > 15*60*1000) {   
             
             
                  // we'll assume it's a new riding session & zero everything out at next pulse.
             
             
                  newRide = true;                         
             
             
                }
             
             
              }
             
             
              void pulse() {
             
             
                if(newRide) {
             
             
                  cycles = 0;
             
             
                  averageSpeed = 0;
             
             
                  rideTimer = millis();
             
             
                  rideDistance = 0;
             
             
                }
             
             
                cycles++;                                             // The wheel has obviously turned another revolution
             
             
                rideDistance = (float) rim*cycles/1000;               // distance in meters, 
             
             
                rideDistance = rideDistance * 0.000621371192;         // converted to miles
             
             
                currentSpeed = (float) (millis() - revTimer)*0.001;   // Convert time elapsed to milliseconds to seconds
             
             
                currentSpeed = rim/currentSpeed;                      // S = d/t: Rim circumference divided by time elapsed
             
             
                currentSpeed = currentSpeed*0.002237;                 // MPH Conversion: 1 mm/s = 0.001 m/s * 3600 s/hr * 1 mile / 1609 m = 0.002237 mi/hr
             
             
                // time ridden since "newRide", in hours, not including inactive time
             
             
                unsigned long activeRidingMillis = millis() - rideTimer - activeRidingOffset;  
             
             
                float activeRidingHours = (float) activeRidingMillis / 1000/60/60; // convert to hours
             
             
                averageSpeed = rideDistance / activeRidingHours;
             
             
                revTimer = millis();       // remember the current moment for speed calculations next time around
             
             
                sendStats();               // Tell Processing what's going on
             
             
                newRide = false;
             
             
                if(!activeRiding) { 
             
             
                  activityChange = true; 
             
             
                  activeRiding = true; 
             
             
                }
             
             
              }
             
             
              void sendStats() {
             
             
                Serial.print("rideDistance=");
             
             
                Serial.print(rideDistance,2);
             
             
                Serial.print("¤tSpeed=");
             
             
                Serial.print(currentSpeed,1);
             
             
                lcd.setCursor(0, 1);
             
             
                lcd.print("Speed = ");
             
             
                lcd.print(currentSpeed,1);
             
             
                lcd.setCursor(13, 1);
             
             
                lcd.print("mph");
             
             
                lbg.drawValue(currentSpeed, 35);
             
             
                Serial.print("&averageSpeed=");
             
             
                Serial.print(averageSpeed,2);
             
             
                // send a linefeed character, telling Processing that we're done transmitting.
             
             
                Serial.print(10,BYTE);     
             
             
                serialTimer = millis();
             
             
              }
             
             
              
              1  
            
 
            