78Views2Replies

Author Options:

Temperature LED lights for motorcycle Answered

Hi I would like to build a temperature sensing leds for my rid to work on my motor cycle to check for black ice!.
I want have this circuit as small as possible (fit in a bike light so can mount on handle bars of my motor bike)
I have been able to do this via a Arduino board but when I convert this to work on a Attiny85 it will not read the same results.
I think this could be due to the way the Attiny85 converts the elec signal. I use a 4.5 volt battery (3 * 1.5) could this be the problem?
Here is the code I have used for both the Arduino (which works great) and also the Attiny85 (not working as should)

/*
temp lights using Uno & LM35 Arduino
*/
const int tempPin = A0;
const int Temperature= 0;


// declare the led pins 
const int led01 = 9;  
const int led02 = 10;  
const int led03 = 11; 
//declare the variable for the temp
int temp=0;//changed to = 0?
int AjustTheTemp= 0;

//Declare the leds as outputs
void setup() {
   Serial.begin(9600);
  
  pinMode (led01, OUTPUT);
  pinMode (led02, OUTPUT);
  pinMode (led03, OUTPUT);
}
 
  // Main Program
 
  void loop() {
   
    // read the voltage from the temp sensor
    // and change it to celsius
   
int reading = analogRead(Temperature);
float voltage = reading *5;
voltage /= 10;
float TemperatureC = (voltage - 0.5) ;

//show temp in monitor so can make changes
    
  Serial.print("TEMPRATURE = ");
  Serial.print(TemperatureC );
  Serial.print("*C");
  Serial.println();
 
  delay (1000);//delays the print to monitor
               // by 1 sec

  if (TemperatureC<(1-AjustTheTemp)) {
  digitalWrite(led01, HIGH);
  digitalWrite(led02, LOW);
  digitalWrite(led03, LOW);
  }
else if(TemperatureC<(4-AjustTheTemp)){
  digitalWrite(led01, LOW);
  digitalWrite(led02, LOW);
  digitalWrite(led03, HIGH); 
}
   else if(TemperatureC<(10-AjustTheTemp)){
  digitalWrite(led01, LOW);
  digitalWrite(led02, HIGH);
  digitalWrite(led03, LOW);
     } 
    }



/*
temp lights using Attiny & LM35
*/
//const int tempPin = 0;
const int Temperature= 3;


// declare the led pins (attiny)
const int led01 = 2;  
const int led02 = 1;  
const int led03 = 4; 
//declare the variable for the temp
int temp=0;//changed to = 0?
int AjustTheTemp= 0;

//Declare the leds as outputs
void setup() {
//  Serial.begin(9600);
  
  pinMode (led01, OUTPUT);
  pinMode (led02, OUTPUT);
  pinMode (led03, OUTPUT);
  pinMode (Temperature, INPUT);
}
 
  // Main Program
 
  void loop() {
   
    // read the voltage from the temp sensor
    // and change it to celsius
    // temp = analogRead(Temperature);
    // temp = temp * 0.48828125;
  
   

int reading = analogRead(Temperature);
float voltage = reading *5;
voltage /= 10;
float TemperatureC = (voltage - 0.5) ;


//show temp in monitor so can make changes
    
  // Serial.print("TEMPRATURE = ");
  //Serial.print(TemperatureC );
  // Serial.print("*C");
  // Serial.println();
 
  //delay (1000);//delays the print to monitor
               // by 1 sec

  if (TemperatureC<(27-AjustTheTemp)) {
  digitalWrite(led01, LOW);
  digitalWrite(led02, HIGH);
  digitalWrite(led03, LOW);
  }
else if(TemperatureC<(29-AjustTheTemp)){
  digitalWrite(led01, LOW);
  digitalWrite(led02, LOW);
  digitalWrite(led03, HIGH); 
}
   else if(TemperatureC<(31-AjustTheTemp)){
  digitalWrite(led01, LOW);
  digitalWrite(led02, HIGH);
  digitalWrite(led03, LOW);
     } 
    }

1 Replies

user
Downunder35m (author)2014-10-20

If you could check for black ice before hitting it you would be a hero in certain countries.

A detection once you are on ice is useless as you already noticed that you spind out of control.

Temp control does not help as you get roads with temps as low as minus 60 degrees celsius in certain parts of Russia.

The only true way would be to check if there is a layer of water on the road that is thicker than run off water (does not matter if frozen or not).

Combined with a simple temp check the only problem is how to read the road for ice as changing conditions would make it hard to impossible.
Maybe a laser would work as water has a better reflection than the road alone and ice even a bit better and usually with a smooth surface.

So once the reflection of the laser reaches a set intensity you could assume you are over ice...

Select as Best AnswerUndo Best Answer